1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

Kernel: Stop using HashMap in Mutex

This commit removes the usage of HashMap in Mutex, thereby making Mutex
be allocation-free.

In order to achieve this several simplifications were made to Mutex,
removing unused code-paths and extra VERIFYs:
 * We no longer support 'upgrading' a shared lock holder to an
   exclusive holder when it is the only shared holder and it did not
   unlock the lock before relocking it as exclusive. NOTE: Unlike the
   rest of these changes, this scenario is not VERIFY-able in an
   allocation-free way, as a result the new LOCK_SHARED_UPGRADE_DEBUG
   debug flag was added, this flag lets Mutex allocate in order to
   detect such cases when debugging a deadlock.
 * We no longer support checking if a Mutex is locked by the current
   thread when the Mutex was not locked exclusively, the shared version
   of this check was not used anywhere.
 * We no longer support force unlocking/relocking a Mutex if the Mutex
   was not locked exclusively, the shared version of these functions
   was not used anywhere.
This commit is contained in:
Idan Horowitz 2022-01-29 01:47:18 +02:00 committed by Andreas Kling
parent 60aa4152e9
commit e28af4a2fc
9 changed files with 96 additions and 168 deletions

View file

@ -978,10 +978,10 @@ inline ProcessID Thread::pid() const
}
#define VERIFY_PROCESS_BIG_LOCK_ACQUIRED(process) \
VERIFY(process->big_lock().is_locked_by_current_thread());
VERIFY(process->big_lock().is_exclusively_locked_by_current_thread());
#define VERIFY_NO_PROCESS_BIG_LOCK(process) \
VERIFY(!process->big_lock().is_locked_by_current_thread());
VERIFY(!process->big_lock().is_exclusively_locked_by_current_thread());
inline static ErrorOr<NonnullOwnPtr<KString>> try_copy_kstring_from_user(const Kernel::Syscall::StringArgument& string)
{