diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2016-04-21 16:10:06 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2016-04-21 16:10:06 +0900 |
commit | 5d40ffbffad4b3f102a6d4cf975d7a49a6dcdb92 (patch) | |
tree | 727f68f26c49fd815f9a447223df2c54e560c2d1 | |
parent | 06d28b62fbc146a18c6fac3e8c82da3f812fedfa (diff) |
Implement chopstx_poll (2)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | chopstx.c | 26 |
3 files changed, 12 insertions, 23 deletions
@@ -1,10 +1,11 @@ 2016-04-21 Niibe Yutaka <gniibe@fsij.org> - * chopstx.c (chx_snooze): New. + * chopstx.c (chx_snooze, chx_wakeup): New. (chopstx_cond_hook, chopstx_cond_unhook): New. (chopstx_cond_signal, chopstx_cond_broadcast): Fix for poll. (chx_proxy_init): Initialize with RUNNING. - (chopstx_poll): Fix with chx_sleep. + (chopstx_poll): Fix with chx_snooze. + (chx_exit): Use chx_wakeup. * example-fs-bb48/sample.c (main): Update with chopstx_poll. * example-fs-bb48/usb-cdc.c (stream_recv): Fix the loop clear @@ -5,6 +5,10 @@ NEWS - Noteworthy changes Released 2016-0X-XX +** New feature: polling +New function chopstx_poll is added to watch multiple condition +variables simultaneously with timeout. + ** FS-BB48: Kinetis L MCU Support for FS-BB48 board with Kinetis L MCU is added. @@ -934,24 +934,7 @@ chx_exit (void *retval) struct chx_thread *tp = (struct chx_thread *)p; ll_dequeue (p); - if (tp->flag_is_proxy) - { - struct chx_px *px = (struct chx_px *)p; - - (*px->counter_p)++; - tp = px->master; - if (tp->state == THREAD_WAIT_POLL) - { - chx_timer_dequeue (tp); - goto wakeup; - } - } - else - { - ((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = 0; - wakeup: - chx_ready_enqueue (tp); - } + chx_wakeup (tp); break; } chx_spin_unlock (&q_join.lock); @@ -1299,7 +1282,7 @@ chopstx_cond_wait (chopstx_cond_t *cond, chopstx_mutex_t *mutex) } static int -chx_wakeup_from_cond_wait (struct chx_thread *tp) +chx_wakeup (struct chx_thread *tp) { int yield = 0; @@ -1318,6 +1301,7 @@ chx_wakeup_from_cond_wait (struct chx_thread *tp) } else { + ((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = 0; wakeup: chx_ready_enqueue (tp); if (tp->prio > running->prio) @@ -1343,7 +1327,7 @@ chopstx_cond_signal (chopstx_cond_t *cond) chx_spin_lock (&cond->lock); tp = (struct chx_thread *)ll_pop (&cond->q); if (tp) - yield = chx_wakeup_from_cond_wait (tp); + yield = chx_wakeup (tp); chx_spin_unlock (&cond->lock); if (yield) chx_sched (CHX_YIELD); @@ -1367,7 +1351,7 @@ chopstx_cond_broadcast (chopstx_cond_t *cond) chx_cpu_sched_lock (); chx_spin_lock (&cond->lock); while ((tp = (struct chx_thread *)ll_pop (&cond->q))) - yield |= chx_wakeup_from_cond_wait (tp); + yield |= chx_wakeup (tp); chx_spin_unlock (&cond->lock); if (yield) chx_sched (CHX_YIELD); |