<div dir="ltr"><div dir="ltr"><div>I have this ready to commit. I am on public wifi and blocked from doing it. I had some modifications to the comment to also note that he original port was done in Christopher Kerl as part of GCI 2013.</div><div><br></div><div>We need a ticket to track the conversion of the Livermore pthread examples. <a href="https://computing.llnl.gov/tutorials/pthreads/">https://computing.llnl.gov/tutorials/pthreads/</a></div><div><br></div><div>--joel<br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 9, 2018 at 9:44 AM Marçal Comajoan Cara <<a href="mailto:mcomajoancara@gmail.com">mcomajoancara@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Closes #2087.<br>
<br>
This work was part of GCI 2018.<br>
---<br>
posix_api/Makefile | 1 +<br>
posix_api/livermore/Makefile | 8 +++<br>
posix_api/livermore/pthread/Makefile | 23 ++++++++<br>
posix_api/livermore/pthread/README | 5 ++<br>
posix_api/livermore/pthread/init.c | 80 ++++++++++++++++++++++++++++<br>
posix_api/livermore/pthread/wscript | 14 +++++<br>
posix_api/livermore/wscript | 10 ++++<br>
posix_api/wscript | 1 +<br>
8 files changed, 142 insertions(+)<br>
create mode 100644 posix_api/livermore/Makefile<br>
create mode 100644 posix_api/livermore/pthread/Makefile<br>
create mode 100644 posix_api/livermore/pthread/README<br>
create mode 100644 posix_api/livermore/pthread/init.c<br>
create mode 100644 posix_api/livermore/pthread/wscript<br>
create mode 100644 posix_api/livermore/wscript<br>
<br>
diff --git a/posix_api/Makefile b/posix_api/Makefile<br>
index 8af26dc..601246c 100644<br>
--- a/posix_api/Makefile<br>
+++ b/posix_api/Makefile<br>
@@ -14,4 +14,5 @@ ifeq ($(RTEMS_HAS_POSIX_API),yes)<br>
SUBDIRS += psx_pthread_report<br>
SUBDIRS += psx_rwlock_report<br>
SUBDIRS += psx_sched_report<br>
+ SUBDIRS += livermore<br>
endif<br>
diff --git a/posix_api/livermore/Makefile b/posix_api/livermore/Makefile<br>
new file mode 100644<br>
index 0000000..d8695a1<br>
--- /dev/null<br>
+++ b/posix_api/livermore/Makefile<br>
@@ -0,0 +1,8 @@<br>
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc<br>
+include $(RTEMS_CUSTOM)<br>
+include $(RTEMS_SHARE)/make/directory.cfg<br>
+<br>
+# If the POSIX API isn't enabled, we can't build these<br>
+ifeq ($(RTEMS_HAS_POSIX_API),yes)<br>
+ SUBDIRS = pthread<br>
+endif<br>
diff --git a/posix_api/livermore/pthread/Makefile b/posix_api/livermore/pthread/Makefile<br>
new file mode 100644<br>
index 0000000..fdd13dc<br>
--- /dev/null<br>
+++ b/posix_api/livermore/pthread/Makefile<br>
@@ -0,0 +1,23 @@<br>
+#<br>
+# RTEMS_MAKEFILE_PATH is typically set in an environment variable<br>
+#<br>
+<br>
+PGM=${ARCH}/pthread.exe<br>
+<br>
+# optional managers required<br>
+MANAGERS=all<br>
+<br>
+# C source names<br>
+CSRCS = init.c<br>
+COBJS = $(CSRCS:%.c=${ARCH}/%.o)<br>
+<br>
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc<br>
+include $(RTEMS_CUSTOM)<br>
+include $(PROJECT_ROOT)/make/leaf.cfg<br>
+<br>
+OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)<br>
+<br>
+all: ${ARCH} $(PGM)<br>
+<br>
+$(PGM): $(OBJS)<br>
+ $(make-exe)<br>
\ No newline at end of file<br>
diff --git a/posix_api/livermore/pthread/README b/posix_api/livermore/pthread/README<br>
new file mode 100644<br>
index 0000000..17cefd4<br>
--- /dev/null<br>
+++ b/posix_api/livermore/pthread/README<br>
@@ -0,0 +1,5 @@<br>
+This is a simple example which illustrates how to use the<br>
+pthreads adapted from the Lawrence Livermore POSIX Pthreads<br>
+tutorial: <a href="https://computing.llnl.gov/tutorials/pthreads/" rel="noreferrer" target="_blank">https://computing.llnl.gov/tutorials/pthreads/</a>.<br>
+<br>
+Thanks to Christopher Kerl for providing the code.<br>
diff --git a/posix_api/livermore/pthread/init.c b/posix_api/livermore/pthread/init.c<br>
new file mode 100644<br>
index 0000000..b77e733<br>
--- /dev/null<br>
+++ b/posix_api/livermore/pthread/init.c<br>
@@ -0,0 +1,80 @@<br>
+/*<br>
+ * COPYRIGHT (c) 1989-2012.<br>
+ * On-Line Applications Research Corporation (OAR).<br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.com/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.com/license/LICENSE</a>.<br>
+ */<br>
+<br>
+//Adapted from Lawrence Livermore Pthread Tutorial #1<br>
+//<a href="https://computing.llnl.gov/tutorials/pthreads" rel="noreferrer" target="_blank">https://computing.llnl.gov/tutorials/pthreads</a><br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <bsp.h> /* for device driver prototypes */<br>
+#include <stdio.h><br>
+#include <stdlib.h><br>
+#include <pthread.h><br>
+<br>
+#define NUM_THREADS 5<br>
+<br>
+/* forward declarations to avoid warnings */<br>
+void *POSIX_Init(void *argument);<br>
+void *Print_Hello(void *threadid);<br>
+<br>
+void *Print_Hello(void *threadid)<br>
+{<br>
+ long tid;<br>
+ tid = (long)threadid;<br>
+ printf("Hello World! It's me, thread #%ld!\n", tid);<br>
+<br>
+ //You must include the return 'NULL;' in your threads to make the compiler happy <br>
+ pthread_exit(NULL);<br>
+ return NULL;<br>
+}<br>
+<br>
+<br>
+void *POSIX_Init(void *argument)<br>
+{<br>
+ pthread_t threads[NUM_THREADS];<br>
+ int rc;<br>
+ long t;<br>
+ <br>
+ //Creates threads<br>
+ for(t=0; t<NUM_THREADS; t++){<br>
+ printf("In main: creating thread %ld\n", t);<br>
+ rc = pthread_create(&threads[t], NULL, Print_Hello, (void *)t);<br>
+ if (rc){<br>
+ printf("ERROR; return code from pthread_create() is %d\n", rc);<br>
+ exit(-1);<br>
+ }<br>
+ }<br>
+ <br>
+<br>
+ //Joins the child threads up to the main one.<br>
+ for(t=0; t<NUM_THREADS; t++){<br>
+ pthread_join(threads[t],NULL);<br>
+ }<br>
+ /* Last thing that main() should do */<br>
+ exit(NULL);<br>
+}<br>
+<br>
+/* NOTICE: the clock driver is explicitly disabled */<br>
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER<br>
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
+<br>
+#define CONFIGURE_MAXIMUM_TASKS 1<br>
+#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM<br>
+<br>
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
+//NOTICE: These configuration variable MUST be initialized before using Pthreads. The will not work if you do not.<br>
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 6 /////<br>
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE /////<br>
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
+<br>
+#define CONFIGURE_INIT<br>
+#include <rtems/confdefs.h><br>
diff --git a/posix_api/livermore/pthread/wscript b/posix_api/livermore/pthread/wscript<br>
new file mode 100644<br>
index 0000000..8e0f266<br>
--- /dev/null<br>
+++ b/posix_api/livermore/pthread/wscript<br>
@@ -0,0 +1,14 @@<br>
+# Copyright 2018 Marçal Comajoan Cara<br>
+#<br>
+# This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.<br>
+#<br>
+<br>
+import rtems_waf.rtems as rtems<br>
+<br>
+def build(bld):<br>
+ rtems.build(bld)<br>
+<br>
+ bld(features = 'c cprogram',<br>
+ target = 'pthread.exe',<br>
+ source = ['init.c'])<br>
+<br>
diff --git a/posix_api/livermore/wscript b/posix_api/livermore/wscript<br>
new file mode 100644<br>
index 0000000..da99c30<br>
--- /dev/null<br>
+++ b/posix_api/livermore/wscript<br>
@@ -0,0 +1,10 @@<br>
+# Copyright 2018 Marçal Comajoan Cara<br>
+#<br>
+# This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.<br>
+#<br>
+<br>
+import rtems_waf.rtems as rtems<br>
+<br>
+def build(bld):<br>
+ if rtems.check_posix(bld):<br>
+ bld.recurse('pthread')<br>
diff --git a/posix_api/wscript b/posix_api/wscript<br>
index 66a351f..912063b 100644<br>
--- a/posix_api/wscript<br>
+++ b/posix_api/wscript<br>
@@ -17,3 +17,4 @@ def build(bld):<br>
bld.recurse('psx_pthread_report')<br>
bld.recurse('psx_rwlock_report')<br>
bld.recurse('psx_sched_report')<br>
+ bld.recurse('livermore')<br>
-- <br>
2.19.2<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div>