Fix calculation of ticks remained.

This commit is contained in:
NIIBE Yutaka
2018-12-08 10:06:33 +09:00
parent 1400e677e3
commit 1ef6256784
2 changed files with 8 additions and 6 deletions

View File

@@ -1,3 +1,7 @@
2018-12-08 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (chx_timer_dequeue): Fix calculation of return value.
2018-12-07 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (chx_timer_dequeue): Return ticks remained.

View File

@@ -361,20 +361,18 @@ chx_timer_dequeue (struct chx_thread *tp)
if (tp_prev == (struct chx_thread *)&q_timer.q)
{
if (tp->next == (struct chx_pq *)&q_timer.q)
chx_set_timer (tp_prev, 0); /* Cancel timer*/
chx_systick_reload (0); /* Cancel timer. */
else
{ /* Update timer. */
ticks_remained += tp->v;
chx_set_timer (tp_prev, ticks_remained);
}
chx_systick_reload (ticks_remained + tp->v); /* Update timer. */
}
else
{
struct chx_pq *p;
tp_prev->v += tp->v;
for (p = q_timer.q.next; p != (struct chx_pq *)tp; p = p->next)
ticks_remained += p->v;
tp_prev->v += tp->v;
}
ll_dequeue ((struct chx_pq *)tp);
tp->v = 0;