summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2013-06-05 13:41:53 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2013-06-05 13:41:53 +0900
commit216eaec1e62bf374747c07a2a1ee0e32d92f8d2d (patch)
tree7fb54f79ab1fbdc556c81637e8aa5fc5c57857eb
parent2ccfe0732e2e51ccaeea6ff4b07ab6e1f05c01dd (diff)
chopstx_wakeup_usec_wait
-rw-r--r--ChangeLog8
-rw-r--r--chopstx.c26
-rw-r--r--chopstx.h3
3 files changed, 36 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cbdd80..73088d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-05 Niibe Yutaka <gniibe@fsij.org>
+
+ * 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 <gniibe@fsij.org>
* 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
@@ -1200,6 +1203,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)
{
struct chx_thread *tp = (struct chx_thread *)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);