diff --git a/miosix/kernel/sync.cpp b/miosix/kernel/sync.cpp index 90f58212b8a66c3be46d36da52eae8d70c79d78e..e7d4541e7afaf1202a78591c2dee70b25be0723f 100644 --- a/miosix/kernel/sync.cpp +++ b/miosix/kernel/sync.cpp @@ -372,7 +372,7 @@ void ConditionVariable::wait(Mutex& m) { PauseKernelLock dLock; Thread *t=Thread::getCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); condList.push_back(&listItem); //Add entry to tail of list //Unlock mutex and wait @@ -393,7 +393,7 @@ void ConditionVariable::wait(pthread_mutex_t *m) { FastInterruptDisableLock dLock; Thread *t=Thread::IRQgetCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); condList.push_back(&listItem); //Putting this thread last on the list (lifo policy) t->flags.IRQsetCondWait(true); @@ -415,7 +415,7 @@ TimedWaitResult ConditionVariable::timedWait(Mutex& m, long long absTime) PauseKernelLock dLock; Thread *t=Thread::getCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); condList.push_back(&listItem); //Add entry to tail of list SleepData sleepData(t,absTime); { @@ -455,7 +455,7 @@ TimedWaitResult ConditionVariable::timedWait(pthread_mutex_t *m, long long absTi absTime=std::max(absTime,100000LL); FastInterruptDisableLock dLock; Thread *t=Thread::IRQgetCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); condList.push_back(&listItem); //Putting this thread last on the list (lifo policy) SleepData sleepData(t,absTime); IRQaddToSleepingList(&sleepData); //Putting this thread on the sleeping list too @@ -538,7 +538,7 @@ Thread *Semaphore::IRQsignalNoPreempt() count++; return nullptr; } - CondData *cd=fifo.front(); + WaitToken *cd=fifo.front(); Thread *t=cd->thread; fifo.pop_front(); t->flags.IRQsetCondWait(false); @@ -586,7 +586,7 @@ void Semaphore::wait() } //Otherwise put ourselves in queue and wait Thread *t=Thread::getCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); fifo.push_back(&listItem); //Add entry to tail of list t->flags.IRQsetCondWait(true); { @@ -614,7 +614,7 @@ TimedWaitResult Semaphore::timedWait(long long absTime) } //Otherwise put ourselves in queue... Thread *t=Thread::getCurrentThread(); - CondData listItem(t); + WaitToken listItem(t); fifo.push_back(&listItem); //...and simultaneously to sleep SleepData sleepData(t,absTime); diff --git a/miosix/kernel/sync.h b/miosix/kernel/sync.h index 972d0af7b19b3a243f243739705a677e0766f554..4ba757251753296fc23af580eb56aeeae40ee1b5 100644 --- a/miosix/kernel/sync.h +++ b/miosix/kernel/sync.h @@ -388,12 +388,13 @@ private: /** * \internal * This class is used to make a list of threads that are waiting on a condition - * variable. It is used by the kernel, and should not be used by end users. + * variable or on a semaphore. It is used by the kernel, and should not be used + * by end users. */ -class CondData : public IntrusiveListItem +class WaitToken : public IntrusiveListItem { public: - CondData(Thread *thread) : thread(thread) {} + WaitToken(Thread *thread) : thread(thread) {} Thread *thread; ///<\internal Thread that is waiting }; @@ -530,7 +531,7 @@ private: friend int ::pthread_cond_destroy(pthread_cond_t *cond); //Memory layout must be kept in sync with pthread_cond, see pthread.cpp - IntrusiveList<CondData> condList; + IntrusiveList<WaitToken> condList; }; /** @@ -634,7 +635,7 @@ private: inline Thread *IRQsignalNoPreempt(); volatile unsigned int count; ///< Counter of the semaphore - IntrusiveList<CondData> fifo; ///< List of waiting threads + IntrusiveList<WaitToken> fifo; ///< List of waiting threads }; /**