summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-05-29 19:28:01 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-05-29 19:28:01 +0000
commitece8c9abd35c4da1386f68a7726360cb1dd9a158 (patch)
tree36dad78bc9349475fb5fe44db94ea75242655cd7 /c
parent9c877c0df6c700897e160c3f75cc127affb70ff5 (diff)
downloadrtems-ece8c9abd35c4da1386f68a7726360cb1dd9a158.tar.bz2
first cut at pthread_create
Diffstat (limited to 'c')
-rw-r--r--c/src/exec/posix/headers/pthread.h6
-rw-r--r--c/src/exec/posix/include/rtems/posix/pthread.h6
-rw-r--r--c/src/exec/posix/src/pthread.c76
3 files changed, 78 insertions, 10 deletions
diff --git a/c/src/exec/posix/headers/pthread.h b/c/src/exec/posix/headers/pthread.h
index 9dca4705b7..9c682c8dcf 100644
--- a/c/src/exec/posix/headers/pthread.h
+++ b/c/src/exec/posix/headers/pthread.h
@@ -80,7 +80,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void );
* inactive chain of free pthread control blocks.
*/
-STATIC INLINE void _POSIX_Threads_Free (
+STATIC INLINE void _POSIX_Threads_Free(
POSIX_Threads_Control *the_pthread
);
@@ -98,7 +98,7 @@ STATIC INLINE void _POSIX_Threads_Free (
* to OBJECTS_ERROR and the_pthread is undefined.
*/
-STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
+STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get(
Objects_Id *id,
Objects_Locations *location
);
@@ -111,7 +111,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
* This function returns TRUE if the_pthread is NULL and FALSE otherwise.
*/
-STATIC INLINE boolean _POSIX_Threads_Is_null (
+STATIC INLINE boolean _POSIX_Threads_Is_null(
POSIX_Threads_Control *the_pthread
);
diff --git a/c/src/exec/posix/include/rtems/posix/pthread.h b/c/src/exec/posix/include/rtems/posix/pthread.h
index 9dca4705b7..9c682c8dcf 100644
--- a/c/src/exec/posix/include/rtems/posix/pthread.h
+++ b/c/src/exec/posix/include/rtems/posix/pthread.h
@@ -80,7 +80,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void );
* inactive chain of free pthread control blocks.
*/
-STATIC INLINE void _POSIX_Threads_Free (
+STATIC INLINE void _POSIX_Threads_Free(
POSIX_Threads_Control *the_pthread
);
@@ -98,7 +98,7 @@ STATIC INLINE void _POSIX_Threads_Free (
* to OBJECTS_ERROR and the_pthread is undefined.
*/
-STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
+STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get(
Objects_Id *id,
Objects_Locations *location
);
@@ -111,7 +111,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
* This function returns TRUE if the_pthread is NULL and FALSE otherwise.
*/
-STATIC INLINE boolean _POSIX_Threads_Is_null (
+STATIC INLINE boolean _POSIX_Threads_Is_null(
POSIX_Threads_Control *the_pthread
);
diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c
index 2f26b5f58e..b68064aedc 100644
--- a/c/src/exec/posix/src/pthread.c
+++ b/c/src/exec/posix/src/pthread.c
@@ -14,6 +14,7 @@
#include <rtems/score/userext.h>
#include <rtems/score/wkspace.h>
#include <rtems/posix/pthread.h>
+#include <rtems/posix/priority.h>
#include <rtems/posix/config.h>
/*PAGE
@@ -172,12 +173,12 @@ void _POSIX_Threads_Manager_initialization(
_Objects_Initialize_information(
&_POSIX_Threads_Information,
OBJECTS_POSIX_THREADS,
- TRUE,
+ FALSE, /* does not support global */
maximum_pthreads,
sizeof( POSIX_Threads_Control ),
TRUE,
- _POSIX_PATH_MAX,
- TRUE
+ 5, /* length is arbitrary for now */
+ TRUE /* this class is threads */
);
/*
@@ -538,6 +539,11 @@ int pthread_create(
)
{
const pthread_attr_t *local_attr;
+ Priority_Control core_priority;
+ boolean is_fp;
+ boolean status;
+ Thread_Control *the_thread;
+ char *default_name = "psx";
local_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes;
@@ -561,7 +567,69 @@ int pthread_create(
int detachstate;
#endif
- return POSIX_NOT_IMPLEMENTED();
+ /*
+ * Validate the RTEMS API priority and convert it to the core priority range.
+ */
+
+ if ( !_POSIX_Priority_Is_valid( attr->schedparam.sched_priority ) )
+ return EINVAL;
+
+ core_priority = _POSIX_Priority_To_core( attr->schedparam.sched_priority );
+
+ /*
+ * Currently all POSIX threads are floating point.
+ */
+
+ is_fp = TRUE;
+
+ /*
+ * Disable dispatch for protection
+ */
+
+ _Thread_Disable_dispatch();
+
+ /*
+ * Allocate the thread control block.
+ *
+ * NOTE: Global threads are not currently supported.
+ */
+
+ the_thread = _POSIX_Threads_Allocate();
+
+ if ( !the_thread ) {
+ _Thread_Enable_dispatch();
+ return EINVAL;
+ }
+
+ /*
+ * Initialize the core thread for this task.
+ */
+
+ status = _Thread_Initialize(
+ &_POSIX_Threads_Information,
+ the_thread,
+ attr->stackaddr,
+ attr->stacksize,
+ is_fp,
+ core_priority,
+ TRUE, /* preemptible */
+ TRUE, /* timesliced */
+ 0, /* isr level */
+ &default_name /* posix threads don't have a name */
+ );
+
+ if ( !status ) {
+ _POSIX_Threads_Free( the_thread );
+ _Thread_Enable_dispatch();
+ return EINVAL;
+ }
+
+ *thread = the_thread->Object.id;
+
+ _Thread_Enable_dispatch();
+
+ return 0;
+
}
/*PAGE