diff options
author | Richard Braun <rbraun@sceen.net> | 2018-03-02 23:23:30 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-03-02 23:29:28 +0100 |
commit | 07c7d5d45c9bf7f95a027ed47a453cc6cb16b304 (patch) | |
tree | 46b3d76b3ecff1d99890f6ae352ffba240c5bc22 /kern/spinlock_types.h | |
parent | 43e07ea6df7f09b0a0853e3b9c55780aecaea393 (diff) |
kern/spinlock: fix and optimize
Making the unlock operation block allows tricky deadlocks to occur in
case a thread is interrupted right before announcing itself as the first
waiter in the queue.
Since locking is expected to block, the spinlock implementation is
reworked to move the hand-off performed by the unlock operation into
the lock operation.
As a side effect, the common case of a single waiter is also optimized.
Diffstat (limited to 'kern/spinlock_types.h')
-rw-r--r-- | kern/spinlock_types.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kern/spinlock_types.h b/kern/spinlock_types.h index 301b8933..fd160a5f 100644 --- a/kern/spinlock_types.h +++ b/kern/spinlock_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Richard Braun. + * Copyright (c) 2017-2018 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,8 @@ #ifndef KERN_SPINLOCK_TYPES_H #define KERN_SPINLOCK_TYPES_H +#include <stdint.h> + #ifdef CONFIG_SPINLOCK_DEBUG #define SPINLOCK_TRACK_OWNER #endif @@ -28,7 +30,7 @@ struct thread; struct spinlock { - unsigned int value; + uint32_t value; #ifdef SPINLOCK_TRACK_OWNER struct thread *owner; |