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

@@ -44,14 +44,12 @@ static inline bool thread_check_stopped_and_restart(Genode::Thread *thread)
}
static inline void thread_stop_myself()
static inline void thread_stop_myself(Genode::Thread *myself)
{
Genode::Thread *myself = Genode::Thread::myself();
unsigned lock_sel = Genode::INITIAL_SEL_LOCK; /* main thread */
if (myself)
lock_sel = Genode::Thread::myself()->native_thread().lock_sel;
lock_sel = myself->native_thread().lock_sel;
seL4_Word sender = ~0U;
seL4_Wait(lock_sel, &sender);