diff options
author | Richard Braun <rbraun@sceen.net> | 2019-01-10 23:27:59 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2019-01-10 23:27:59 +0100 |
commit | 9b40330cdc9399acb3687cbccb7696b4fd9feb0e (patch) | |
tree | 2b350482071be9fec8a0bd667a6df4936a33677a /test | |
parent | b4ab6ce08cf45939e640fdf3f9ba75bef8316320 (diff) |
kern/semaphore: rework
The previous implementation, which uses a combination of fast and slow
paths around accessing an atomic integer, suffers from a bug triggered
when two or more posts are performed back-to-back, without a waiter
decrementing the semaphore value in between. The first post would be
the only one signalling a waiter.
In addition, having a fast path that expects the absence of waiters
probably doesn't make sense, as semaphores are expected to be used for
signalling threads. As a result, it was decided to remove the fast path
altogether, and protect the semaphore value with sleep queues.
Finally, as part of the rework, semaphores now have a user-defined maximum
value, in order to make the implementation of, e.g. wrappers for binary
semaphores, convenient.
Thanks to Simon Venken for reporting the bug.
Diffstat (limited to 'test')
0 files changed, 0 insertions, 0 deletions