summaryrefslogtreecommitdiffstats
path: root/c/src/exec/posix/src/pthread.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-09-05 20:45:05 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-09-05 20:45:05 +0000
commit65c421ffc583a6d9babf2cd5de1019a70450cb3d (patch)
tree56f30bc34c853181468ee61a7cdf15cb7b6b835b /c/src/exec/posix/src/pthread.c
parentpthread_mutex_setprioceiling: fixed bug where returned priority was (diff)
downloadrtems-65c421ffc583a6d9babf2cd5de1019a70450cb3d.tar.bz2
default thread attributes: default value for inheritsched changed from
explicit to inherit scheduler to be consistent with FSU pthreads for gnat. _POSIX_Threads_Create_extension: now inherit signal blocked mask from creator if the new thread is a posix thread. _POSIX_Threads_Initialize_user_threads: make sure posix initialization threads start with a useful priority. If they inherit the priority of the creating thread, they will end up at the same priority as the idle thread. Since the idle thread does not yield, they will not run.
Diffstat (limited to 'c/src/exec/posix/src/pthread.c')
-rw-r--r--c/src/exec/posix/src/pthread.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c
index 07283f96e7..ff3171eb41 100644
--- a/c/src/exec/posix/src/pthread.c
+++ b/c/src/exec/posix/src/pthread.c
@@ -24,6 +24,10 @@
/*PAGE
*
* The default pthreads attributes structure.
+ *
+ * NOTE: Be careful .. if the default attribute set changes,
+ * _POSIX_Threads_Initialize_user_threads will need to be examined.
+ *
*/
const pthread_attr_t _POSIX_Threads_Default_attributes = {
@@ -31,7 +35,7 @@ const pthread_attr_t _POSIX_Threads_Default_attributes = {
NULL, /* stackaddr */
PTHREAD_MINIMUM_STACK_SIZE, /* stacksize */
PTHREAD_SCOPE_PROCESS, /* contentionscope */
- PTHREAD_EXPLICIT_SCHED, /* inheritsched */
+ PTHREAD_INHERIT_SCHED, /* inheritsched */
SCHED_FIFO, /* schedpolicy */
{ /* schedparam */
2, /* sched_priority */
@@ -127,6 +131,7 @@ boolean _POSIX_Threads_Create_extension(
)
{
POSIX_API_Control *api;
+ POSIX_API_Control *executing_api;
api = _Workspace_Allocate( sizeof( POSIX_API_Control ) );
@@ -150,9 +155,10 @@ boolean _POSIX_Threads_Create_extension(
/* XXX use signal constants */
api->signals_pending = 0;
- if ( _Objects_Get_class( created->Object.id ) == OBJECTS_POSIX_THREADS )
- api->signals_blocked = 0;
- else
+ if ( _Objects_Get_class( created->Object.id ) == OBJECTS_POSIX_THREADS ) {
+ executing_api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
+ api->signals_blocked = api->signals_blocked;
+ } else
api->signals_blocked = 0xffffffff;
/* XXX set signal parameters -- block all signals for non-posix threads */
@@ -232,6 +238,7 @@ void _POSIX_Threads_Initialize_user_threads( void )
unsigned32 maximum;
posix_initialization_threads_table *user_threads;
pthread_t thread_id;
+ pthread_attr_t attr;
user_threads = _POSIX_Threads_User_initialization_threads;
maximum = _POSIX_Threads_Number_of_initialization_threads;
@@ -239,10 +246,23 @@ void _POSIX_Threads_Initialize_user_threads( void )
if ( !user_threads || maximum == 0 )
return;
+ /*
+ * Be careful .. if the default attribute set changes, this may need to.
+ *
+ * Setting the attributes explicitly is critical, since we don't want
+ * to inherit the idle tasks attributes.
+ */
+
for ( index=0 ; index < maximum ; index++ ) {
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
+ assert( !status );
+
status = pthread_create(
&thread_id,
- NULL,
+ &attr,
user_threads[ index ].entry,
NULL
);