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);
lock.unlock();
scheduler::reschedule();
waiting = false;
}
}
@ -59,10 +57,11 @@ struct deferred_unique_semaphore {
* \brief Release the lock, from an IRQ handler.
*/
void notify() {
if (!waiting) {
++value;
} else {
if(waiting){
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
*/
void notify(size_t n) {
if (!waiting) {
value += n;
} else {
if (waiting) {
scheduler::unblock_process_hint(pid);
waiting = false;
--n;
if (n) {
value += n;
}
} else {
value += n;
}
}