Implement chopstx_poll (2)
This commit is contained in:
@@ -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
|
||||
|
||||
4
NEWS
4
NEWS
@@ -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.
|
||||
|
||||
|
||||
26
chopstx.c
26
chopstx.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user