mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-16 00:00:06 +01:00
check always, if sem_post has to wake up a task
- avoids a (stupid) deadlock
This commit is contained in:
parent
ee7d764ba2
commit
078091ef2d
1 changed files with 12 additions and 15 deletions
|
@ -187,15 +187,12 @@ timeout:
|
|||
* - -EINVAL on invalid argument
|
||||
*/
|
||||
inline static int sem_post(sem_t* s) {
|
||||
unsigned int k, i;
|
||||
|
||||
if (BUILTIN_EXPECT(!s, 0))
|
||||
return -EINVAL;
|
||||
|
||||
spinlock_irqsave_lock(&s->lock);
|
||||
if (s->value > 0) {
|
||||
s->value++;
|
||||
spinlock_irqsave_unlock(&s->lock);
|
||||
} else {
|
||||
unsigned int k, i;
|
||||
|
||||
s->value++;
|
||||
i = s->pos;
|
||||
|
@ -207,8 +204,8 @@ inline static int sem_post(sem_t* s) {
|
|||
}
|
||||
i = (i + 1) % MAX_TASKS;
|
||||
}
|
||||
|
||||
spinlock_irqsave_unlock(&s->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue