From 4dcc1d1a17d177f73bdc411f394278d30bb15ccb Mon Sep 17 00:00:00 2001 From: Terraneo Federico <fede.tft@miosix.org> Date: Wed, 26 Apr 2023 00:07:23 +0200 Subject: [PATCH] Improve flags --- miosix/kernel/kernel.cpp | 10 +++++----- miosix/kernel/kernel.h | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/miosix/kernel/kernel.cpp b/miosix/kernel/kernel.cpp index c5ac40df..91c88e14 100755 --- a/miosix/kernel/kernel.cpp +++ b/miosix/kernel/kernel.cpp @@ -292,7 +292,7 @@ bool IRQwakeThreads(long long currentTime) { if(currentTime<(*it)->wakeupTime) break; //Wake both threads doing absoluteSleep() and timedWait() - (*it)->thread->flags.IRQexitSleepAndWait(); + (*it)->thread->flags.IRQclearSleepAndWait(); if(const_cast<Thread*>(runningThread)->getPriority()<(*it)->thread->getPriority()) result=true; it=sleepingList.erase(it); @@ -379,7 +379,7 @@ void Thread::nanoSleepUntil(long long absoluteTimeNs) //the timer isr will wake threads, modifying the sleepingList { FastInterruptDisableLock lock; - d.thread->flags.IRQsetSleep(true); //Sleeping thread: set sleep flag + d.thread->flags.IRQsetSleep(); //Sleeping thread: set sleep flag IRQaddToSleepingList(&d); } // NOTE: There is no need to synchronize the timer (calling IRQsetNextInterrupt) @@ -889,13 +889,13 @@ void Thread::ThreadFlags::IRQsetWait(bool waiting) Scheduler::IRQwaitStatusHook(this->t); } -void Thread::ThreadFlags::IRQsetSleep(bool sleeping) +void Thread::ThreadFlags::IRQsetSleep() { - if(sleeping) flags |= SLEEP; else flags &= ~SLEEP; + flags |= SLEEP; Scheduler::IRQwaitStatusHook(this->t); } -void Thread::ThreadFlags::IRQexitSleepAndWait() +void Thread::ThreadFlags::IRQclearSleepAndWait() { flags &= ~(WAIT | SLEEP); Scheduler::IRQwaitStatusHook(this->t); diff --git a/miosix/kernel/kernel.h b/miosix/kernel/kernel.h index 793dd4bb..876abdc9 100755 --- a/miosix/kernel/kernel.h +++ b/miosix/kernel/kernel.h @@ -938,16 +938,14 @@ private: /** * Set the sleep flag of the thread. * Can only be called with interrupts disabled or within an interrupt. - * \param sleeping if true the flag will be set, otherwise cleared */ - void IRQsetSleep(bool sleeping); + void IRQsetSleep(); /** - * Shorthand for IRQsetWait(false); IRQsetSleep(false); - * Used by IRQwakeThreads to wake both threads doing absoluteSleep() - * and timedWait() + * Used by IRQwakeThreads to clear both the sleep and wait flags, + * waking threads doing absoluteSleep() as well as timedWait() */ - void IRQexitSleepAndWait(); + void IRQclearSleepAndWait(); /** * Set the wait_join flag of the thread. -- GitLab