diff --git a/ChangeLog b/ChangeLog index eaf1e12..da9b262 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-12-16 NIIBE Yutaka + + * chopstx.c (chx_timer_expired): Bug fix of wake up. + (chx_mutex_unlock): Avoid non-deterministic thing. + 2017-12-14 NIIBE Yutaka * board/board-st-nucleo-f103.h: Update. diff --git a/chopstx-cortex-m.c b/chopstx-cortex-m.c index b983f0c..28f1d3c 100644 --- a/chopstx-cortex-m.c +++ b/chopstx-cortex-m.c @@ -287,7 +287,7 @@ chx_request_preemption (uint16_t prio) * * Returns: * 1 on wakeup by others. - * 0 on normal wakeup. + * 0 on normal wakeup (timer expiration, getting lock). * -1 on cancellation. */ static uintptr_t __attribute__ ((naked, noinline)) diff --git a/chopstx.c b/chopstx.c index ca36560..5585d89 100644 --- a/chopstx.c +++ b/chopstx.c @@ -403,6 +403,7 @@ chx_timer_expired (void) tp = tp_next) { next_tick = tp->v; + tp->v = (uintptr_t)0; tp_next = (struct chx_thread *)tp->next; ll_dequeue ((struct chx_pq *)tp); chx_ready_enqueue (tp); @@ -575,6 +576,7 @@ chx_mutex_unlock (chopstx_mutex_t *mutex) uint16_t newprio = running->prio_orig; chopstx_mutex_t *m; + tp->v = (uintptr_t)0; chx_ready_enqueue (tp); /* Examine mutexes we hold, and determine new priority for running. */