Compare commits

...

2 Commits

Author SHA1 Message Date
Mathieu Maret f01f28f15f Fix tests 2024-03-13 22:02:04 +01:00
Mathieu Maret d6ab0da231 Fix threadMsleep for 0 2024-03-13 21:40:51 +01:00
2 changed files with 9 additions and 11 deletions

View File

@ -232,17 +232,18 @@ int threadOnJieffiesTick()
disable_IRQs(flags);
list_foreach(currentThread, nextThread, idx)
{
if (nextThread->state == SLEEPING && nextThread->jiffiesSleeping) {
nextThread->jiffiesSleeping--;
if (!nextThread->jiffiesSleeping) {
if (nextThread->state == SLEEPING) {
if (nextThread->jiffiesSleeping)
nextThread->jiffiesSleeping--;
if (!nextThread->jiffiesSleeping)
nextThread->state = READY;
}
}
}
list_foreach_named(threadWithTimeout, nextThread, idx, timePrev, timeNext)
{
if (nextThread->state == WAITING && nextThread->jiffiesSleeping) {
nextThread->jiffiesSleeping--;
if (nextThread->state == WAITING) {
if (nextThread->jiffiesSleeping)
nextThread->jiffiesSleeping--;
if (!nextThread->jiffiesSleeping) {
nextThread->sleepHaveTimeouted = 1;
list_delete_named(threadWithTimeout, nextThread, timePrev, timeNext);
@ -332,8 +333,6 @@ int threadUsleep(unsigned long usec)
current->state = SLEEPING;
current->sleepHaveTimeouted = 0;
current->jiffiesSleeping = usecs_to_jiffies(usec);
if (!current->jiffiesSleeping) // sleep at least 1 jiffies
current->jiffiesSleeping = 1;
next = threadSelectNext();
assert(next != current);

View File

@ -306,9 +306,8 @@ void sleepThread(void *arg)
}
unsigned long ellapsedTime = jiffies_to_msecs(jiffies - initialJiffies);
assertmsg(ellapsedTime >= 500 && ellapsedTime < 510, "ellapsedTime %lu\n", ellapsedTime);
threadMsleep(0);
printf("I should never be showed\n");
assert(1);
threadMsleep(ULONG_MAX);
assert(0);
}
struct mutex mutexTest;