base: add mutex as derivate of lock

The mutex class is more restrictive in usage compared to
Genode::Lock.

- At initialiation time it is ever unlocked.
- No thread is permitted to lock twice. Warn about it
  in case it happens.
- Only the lock onwer is permitted to unlock the mutex.
  Warn about it and don't unlock the mutex in case it happens.

Issue #3612
This commit is contained in:
Alexander Boettcher
2020-01-24 13:46:09 +01:00
committed by Christian Helmuth
parent d1609e771a
commit 00f69bc70d
15 changed files with 133 additions and 16 deletions

View File

@ -49,14 +49,13 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread *thread_base)
static inline void thread_switch_to(Genode::Thread *) { thread_yield(); }
static inline void thread_stop_myself()
static inline void thread_stop_myself(Genode::Thread *myself)
{
/*
* Just go to sleep without modifying the counter value. The
* 'thread_check_stopped_and_restart()' function will get called
* repeatedly until this thread has actually executed the syscall.
*/
Genode::Thread *myself = Genode::Thread::myself();
const int *futex_counter_ptr = myself ?
&myself->native_thread().futex_counter :
&main_thread_futex_counter;