From 216eaec1e62bf374747c07a2a1ee0e32d92f8d2d Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 5 Jun 2013 13:41:53 +0900 Subject: [PATCH] chopstx_wakeup_usec_wait --- ChangeLog | 8 ++++++++ chopstx.c | 26 +++++++++++++++++++++++++- chopstx.h | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1cbdd80..73088d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-06-05 Niibe Yutaka + + * chopstx.c (sched, preempt, svc, chx_timer_expired, chx_exit) + (chopstx_usec_wait, chopstx_mutex_lock, chopstx_cond_wait) + (chopstx_intr_wait, chopstx_join): Implement SCHED_RR. + (chopstx_create): Change API. + (chopstx_wakeup_usec_wait): New. + 2013-06-04 Niibe Yutaka * chopstx.c (AIRCR): New. diff --git a/chopstx.c b/chopstx.c index c99c55d..62d0d9a 100644 --- a/chopstx.c +++ b/chopstx.c @@ -1187,7 +1187,10 @@ chopstx_join (chopstx_t thd, void **ret) chx_spin_unlock (&q_join.lock); tp->flag_join_req = 1; if (tp->prio < running->prio) - tp->prio = running->prio; + { + tp->prio = running->prio; + /*XXX: dequeue and enqueue with new prio. */ + } chx_sched (CHX_SLEEP); } else @@ -1199,6 +1202,27 @@ chopstx_join (chopstx_t thd, void **ret) } +void +chopstx_wakeup_usec_wait (chopstx_t thd) +{ + struct chx_thread *tp = (struct chx_thread *)thd; + int yield = 0; + + chx_cpu_sched_lock (); + if (tp->state == THREAD_WAIT_TIME) + { + chx_timer_dequeue (tp); + chx_ready_enqueue (tp); + if (tp->prio > running->prio) + yield = 1; + } + if (yield) + chx_sched (CHX_YIELD); + else + chx_cpu_sched_unlock (); +} + + void chopstx_cancel (chopstx_t thd) { diff --git a/chopstx.h b/chopstx.h index c047836..98c0531 100644 --- a/chopstx.h +++ b/chopstx.h @@ -122,3 +122,6 @@ struct chx_cleanup { /* NOTE: This signature is different to PTHREAD's one. */ void chopstx_cleanup_push (struct chx_cleanup *clp); void chopstx_cleanup_pop (int execute); + + +void chopstx_wakeup_usec_wait (chopstx_t thd);