diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-05 15:25:39 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-05 15:25:39 +0900 |
commit | 0ae3b2681fd3428baffc06cefadc40a90dcd5da4 (patch) | |
tree | f6bf5ab175a1dafaad9a69409be848ffba36cf33 | |
parent | 419094243a82b102599497f02bbe61d287682388 (diff) |
chopstx_usec_wait_internal with pointer
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | chopstx.c | 32 | ||||
-rw-r--r-- | chopstx.h | 4 |
3 files changed, 27 insertions, 10 deletions
@@ -6,6 +6,7 @@ (chopstx_create): Change API. (chopstx_wakeup_usec_wait): New. (chopstx_usec_wait): Accept wakeup to break. + (chopstx_usec_wait_internal): New. 2013-06-04 Niibe Yutaka <gniibe@fsij.org> @@ -844,25 +844,39 @@ chopstx_create (uint32_t flags_and_prio, void -chopstx_usec_wait (uint32_t usec) +chopstx_usec_wait_internal (uint32_t *arg) { - while (usec) - { - uint32_t usec0 = (usec > 200*1000) ? 200*1000: usec; - register int r8 asm ("r8") = 0; + register uint32_t *usec_p asm ("r8") = arg; + uint32_t usec; + uint32_t usec0 = 0; + while (1) + { chx_cpu_sched_lock (); + *usec_p -= usec0; + usec = *usec_p; + if (usec == 0) + break; + usec0 = (usec > 200*1000) ? 200*1000: usec; if (running->flag_sched_rr) chx_timer_dequeue (running); chx_spin_lock (&q_timer.lock); chx_timer_insert (running, usec0); chx_spin_unlock (&q_timer.lock); - asm ("" : "=r" (r8) : "r" (r8)); + asm ("" : "=r" (usec_p) : "r" (usec_p)); chx_sched (CHX_SLEEP); - if (r8) /* awakened */ + + if (!usec_p) /* awakened */ break; - usec -= usec0; } + + chx_cpu_sched_unlock (); +} + +void +chopstx_usec_wait (uint32_t usec) +{ + chopstx_usec_wait_internal (&usec); } @@ -1215,7 +1229,7 @@ chopstx_wakeup_usec_wait (chopstx_t thd) chx_cpu_sched_lock (); if (tp->state == THREAD_WAIT_TIME) { - tp->tc.reg[REG_EXIT] = 1; + tp->tc.reg[REG_EXIT] = 0; chx_timer_dequeue (tp); chx_ready_enqueue (tp); if (tp->prio > running->prio) @@ -39,7 +39,9 @@ chopstx_create (uint32_t flags_and_prio, #define CHOPSTX_SCHED_RR 0x20000 -void chopstx_usec_wait (uint32_t useconds); +void chopstx_usec_wait_internal (uint32_t *arg); + +void chopstx_usec_wait (uint32_t usec); struct chx_spinlock { /* nothing for uniprocessor. */ |