Fix the lock

It was possible to loose some notifications
This commit is contained in:
Baptiste Wicht 2016-09-26 19:05:06 +02:00
parent 01f31441a1
commit 24b6eb4b1a
No known key found for this signature in database
GPG Key ID: C5566B6C7F884532

View File

@ -50,8 +50,6 @@ struct deferred_unique_semaphore {
scheduler::block_process_light(pid); scheduler::block_process_light(pid);
lock.unlock(); lock.unlock();
scheduler::reschedule(); scheduler::reschedule();
waiting = false;
} }
} }
@ -59,10 +57,11 @@ struct deferred_unique_semaphore {
* \brief Release the lock, from an IRQ handler. * \brief Release the lock, from an IRQ handler.
*/ */
void notify() { void notify() {
if (!waiting) { if(waiting){
++value;
} else {
scheduler::unblock_process_hint(pid); scheduler::unblock_process_hint(pid);
waiting = false;
} else {
++value;
} }
} }
@ -70,15 +69,17 @@ struct deferred_unique_semaphore {
* \brief Release the lock several times, from an IRQ * \brief Release the lock several times, from an IRQ
*/ */
void notify(size_t n) { void notify(size_t n) {
if (!waiting) { if (waiting) {
value += n;
} else {
scheduler::unblock_process_hint(pid); scheduler::unblock_process_hint(pid);
waiting = false;
--n; --n;
if (n) { if (n) {
value += n; value += n;
} }
} else {
value += n;
} }
} }