diff --git a/core/sys/mt.c b/core/sys/mt.c index b59d9463d..d5bc10398 100644 --- a/core/sys/mt.c +++ b/core/sys/mt.c @@ -68,14 +68,13 @@ mt_start(struct mt_thread *thread, void (* function)(void *), void *data) stack with the correct parameters. */ mtarch_start(&thread->thread, function, data); - thread->state = MT_STATE_READY; + thread->state = MT_STATE_STARTED; } /*--------------------------------------------------------------------------*/ void mt_exec(struct mt_thread *thread) { - if(thread->state == MT_STATE_READY) { - thread->state = MT_STATE_RUNNING; + if(thread->state == MT_STATE_STARTED) { current = thread; /* Switch context to the thread. The function call will not return until the the thread has yielded, or is preempted. */ @@ -87,14 +86,11 @@ void mt_yield(void) { mtarch_pstop(); - current->state = MT_STATE_READY; - current = NULL; /* This function is called from the running thread, and we call the switch function in order to switch the thread to the main Contiki program instead. For us, the switch function will not return until the next time we are scheduled to run. */ mtarch_yield(); - } /*--------------------------------------------------------------------------*/ void @@ -102,7 +98,6 @@ mt_exit(void) { mtarch_pstop(); current->state = MT_STATE_EXITED; - current = NULL; mtarch_yield(); } /*--------------------------------------------------------------------------*/ diff --git a/core/sys/mt.h b/core/sys/mt.h index 6db215084..b472b3197 100644 --- a/core/sys/mt.h +++ b/core/sys/mt.h @@ -84,9 +84,8 @@ #include "contiki.h" -#define MT_STATE_READY 1 -#define MT_STATE_RUNNING 2 -#define MT_STATE_EXITED 5 +#define MT_STATE_STARTED 1 +#define MT_STATE_EXITED 2 /** * An opaque structure that is used for holding the state of a thread.