1
0
Fork 0
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:
Stefan Lankes 2016-01-16 23:24:30 +01:00
parent ee7d764ba2
commit 078091ef2d

View file

@ -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;
}