[rtems commit] posix: fix race condition between pthread_create and capture engine
Gedare Bloom
gedare at rtems.org
Thu Jan 9 15:17:01 UTC 2014
Module: rtems
Branch: master
Commit: a19a7077ee82a0189a45105df56029abd7804bd6
Changeset: http://git.rtems.org/rtems/commit/?id=a19a7077ee82a0189a45105df56029abd7804bd6
Author: Till Strauman <strauman at slac.stanford.edu>
Date: Tue Dec 17 18:01:11 2013 -0600
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.
---
cpukit/posix/src/pthreadcreate.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 64270e9..b780ecc 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
*/
More information about the vc
mailing list