From b04ee63e3d855aab7fe2a84377bdff6674417e51 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 1 Mar 2002 17:49:57 +0000 Subject: 2002-03-01 Eric Norum * src/pthreadonce.c: Task is not preemptable while running a pthread_once init function. This is slightly less heavy handed than disabling dispatching and seems better than consuming a mutex. --- c/src/exec/posix/src/pthreadonce.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'c/src/exec/posix/src/pthreadonce.c') diff --git a/c/src/exec/posix/src/pthreadonce.c b/c/src/exec/posix/src/pthreadonce.c index 6026dfe7c0..94cbb005da 100644 --- a/c/src/exec/posix/src/pthreadonce.c +++ b/c/src/exec/posix/src/pthreadonce.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -29,15 +30,16 @@ int pthread_once( if ( !once_control || !init_routine ) return EINVAL; - _Thread_Disable_dispatch(); - if ( !once_control->init_executed ) { - once_control->is_initialized = TRUE; - once_control->init_executed = TRUE; - (*init_routine)(); + rtems_mode saveMode; + rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); + if ( !once_control->init_executed ) { + once_control->is_initialized = TRUE; + once_control->init_executed = TRUE; + (*init_routine)(); + } + rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode); } - - _Thread_Enable_dispatch(); return 0; } -- cgit v1.2.3