]> granicus.if.org Git - esp-idf/commit
[pthread] Perform init_routine execution outside of the mutex
authorKedar Sovani <Kedar Sovani kedars@gmail.com>
Wed, 25 Oct 2017 06:42:10 +0000 (12:12 +0530)
committerKedar Sovani <Kedar Sovani kedars@gmail.com>
Wed, 25 Oct 2017 08:27:39 +0000 (13:57 +0530)
commit07992b08e89f575daf26f449e6e58f9191d38e75
tree2c319f1da499c01728fd87b5124cb0c16fd4d988
parent276551431461ce7b6d3d6fd638b39764ff8e5ff4
[pthread] Perform init_routine execution outside of the mutex

The mutex is common across all the threads. It needn't be held across
the init_routine() call as long as the 'once' behaviour is guaranteed

Saw a deadlock case, where init_routine of one thread was waiting for
the completion of init_routine in another thread.

t2: wait for command
t1: pthread_once:
         lock once_mux
         init_routine:
               inform thread t2
               wait for signal from t2
t2: received command
         pthread_once
             lock once_mux (already held by t1)
---- Deadlock ----
components/pthread/pthread.c