//-------------------------------------------------------------------- void IThread::run(void* _mythread) { // try to cast the given parameter to IThread pointer IThread* mythread = static_cast<IThread*>(_mythread); if (mythread == NULL) { NR_Log(Log::LOG_KERNEL, Log::LL_ERROR, "IThread: not valid parameter was specified for IThread::run(void*) method"); return; } // now loop the thread until some messages occurs bool run = true; while (run){ // kernel requested to suspend the thread if (mythread->mThreadState == THREAD_NEXT_SUSPEND) { // notice about suspending and go into sleep mode mythread->changeState(THREAD_SLEEPING); mythread->_noticeSuspend(); // kernel requested to resume the execution }else if (mythread->mThreadState == THREAD_NEXT_RESUME) { // notice about resuming the work and start it again mythread->changeState(THREAD_RUNNING); mythread->_noticeResume(); // kernel does not requested anything, so run the task }else if (mythread->mThreadState == THREAD_RUNNING) { mythread->_noticeUpdate(); } // check for the stop message, then stop the thread // this is a reading mutex, so do not have to lock it run = mythread->mThreadState != THREAD_STOP; // we now yield the used timeslice for another threads yield(mythread); } // notice to stop the underlying task mythread->_noticeStop(); // exit the thread //return NULL; }