summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorTill Strauman <strauman@slac.stanford.edu>2013-12-17 18:01:11 -0600
committerGedare Bloom <gedare@rtems.org>2014-01-09 10:24:12 -0500
commita19a7077ee82a0189a45105df56029abd7804bd6 (patch)
tree8be0753bd3a7bbf198769dacd3ec8071f39386d1 /cpukit/posix
parentlibtests/termios01: Add tests for cfsetspeed() and cfmakeraw() (diff)
downloadrtems-a19a7077ee82a0189a45105df56029abd7804bd6.tar.bz2
posix: fix race condition between pthread_create and capture engine
Reproducable crashes occur when using pthreads and the capture engine at the same time. 'pthread_create()' is the culprit. It creates a SCORE thread and then calls Thread_Start( ) without disabling thread-dispatching.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/pthreadcreate.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 64270e94d9..b780eccfe9 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -196,6 +196,8 @@ int pthread_create(
api->schedpolicy = schedpolicy;
api->schedparam = schedparam;
+ _Thread_Disable_dispatch();
+
/*
* POSIX threads are allocated and started in one operation.
*/
@@ -216,6 +218,7 @@ int pthread_create(
* thread while we are creating it.
*/
if ( !status ) {
+ _Thread_Enable_dispatch();
_POSIX_Threads_Free( the_thread );
_RTEMS_Unlock_allocator();
return EINVAL;
@@ -229,6 +232,8 @@ int pthread_create(
);
}
+ _Thread_Enable_dispatch();
+
/*
* Return the id and indicate we successfully created the thread
*/