From 907cfb1e2fa46fed0d0812dc4295d91bfbe01892 Mon Sep 17 00:00:00 2001 From: Till Strauman Date: Tue, 17 Dec 2013 17:42:53 -0600 Subject: posix: fix race condition between pthread_create and capture engine Fix PR 2068: 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 file changed, 5 insertions(+) (limited to 'cpukit') diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index c5ca86d52e..054261b5ef 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -198,6 +198,8 @@ int pthread_create( */ the_thread->do_post_task_switch_extension = true; + _Thread_Disable_dispatch(); + /* * POSIX threads are allocated and started in one operation. */ @@ -217,6 +219,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; @@ -230,6 +233,8 @@ int pthread_create( ); } + _Thread_Enable_dispatch(); + /* * Return the id and indicate we successfully created the thread */ -- cgit v1.2.3