Fix threadMsleep for 0
This commit is contained in:
parent
dea0eba83d
commit
d6ab0da231
@ -232,17 +232,18 @@ int threadOnJieffiesTick()
|
|||||||
disable_IRQs(flags);
|
disable_IRQs(flags);
|
||||||
list_foreach(currentThread, nextThread, idx)
|
list_foreach(currentThread, nextThread, idx)
|
||||||
{
|
{
|
||||||
if (nextThread->state == SLEEPING && nextThread->jiffiesSleeping) {
|
if (nextThread->state == SLEEPING) {
|
||||||
nextThread->jiffiesSleeping--;
|
if (nextThread->jiffiesSleeping)
|
||||||
if (!nextThread->jiffiesSleeping) {
|
nextThread->jiffiesSleeping--;
|
||||||
|
if (!nextThread->jiffiesSleeping)
|
||||||
nextThread->state = READY;
|
nextThread->state = READY;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list_foreach_named(threadWithTimeout, nextThread, idx, timePrev, timeNext)
|
list_foreach_named(threadWithTimeout, nextThread, idx, timePrev, timeNext)
|
||||||
{
|
{
|
||||||
if (nextThread->state == WAITING && nextThread->jiffiesSleeping) {
|
if (nextThread->state == WAITING) {
|
||||||
nextThread->jiffiesSleeping--;
|
if (nextThread->jiffiesSleeping)
|
||||||
|
nextThread->jiffiesSleeping--;
|
||||||
if (!nextThread->jiffiesSleeping) {
|
if (!nextThread->jiffiesSleeping) {
|
||||||
nextThread->sleepHaveTimeouted = 1;
|
nextThread->sleepHaveTimeouted = 1;
|
||||||
list_delete_named(threadWithTimeout, nextThread, timePrev, timeNext);
|
list_delete_named(threadWithTimeout, nextThread, timePrev, timeNext);
|
||||||
@ -332,8 +333,6 @@ int threadUsleep(unsigned long usec)
|
|||||||
current->state = SLEEPING;
|
current->state = SLEEPING;
|
||||||
current->sleepHaveTimeouted = 0;
|
current->sleepHaveTimeouted = 0;
|
||||||
current->jiffiesSleeping = usecs_to_jiffies(usec);
|
current->jiffiesSleeping = usecs_to_jiffies(usec);
|
||||||
if (!current->jiffiesSleeping) // sleep at least 1 jiffies
|
|
||||||
current->jiffiesSleeping = 1;
|
|
||||||
next = threadSelectNext();
|
next = threadSelectNext();
|
||||||
|
|
||||||
assert(next != current);
|
assert(next != current);
|
||||||
|
Loading…
Reference in New Issue
Block a user