Use ->V for the return value of chx_sched.

This commit is contained in:
NIIBE Yutaka
2017-06-21 20:48:50 +09:00
parent 6c68c55301
commit ca1b22c3eb
2 changed files with 19 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
2017-06-22 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (chx_sched): Use ->V for return value.
(svc): Ditto.
(chx_wakeup): Set -> for the return value of chx_sched.
(chopstx_mutex_lock, chopstx_cancel): Likewise.
2017-06-21 NIIBE Yutaka <gniibe@fsij.org> 2017-06-21 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (struct chx_pq): Use uintptr_t for V. * chopstx.c (struct chx_pq): Use uintptr_t for V.

View File

@@ -816,8 +816,11 @@ chx_sched (uint32_t yield)
/* Normal context switch */ /* Normal context switch */
"0:\n\t" "0:\n\t"
"add r0, #16\n\t" /* ->V */
"ldr r1, [r0]\n\t"
"str r1, [sp]\n\t"
/**/ /**/
"add r0, #20\n\t" "add r0, #4\n\t"
"ldm r0!, {r4, r5, r6, r7}\n\t" "ldm r0!, {r4, r5, r6, r7}\n\t"
"ldm r0!, {r1, r2, r3}\n\t" "ldm r0!, {r1, r2, r3}\n\t"
"mov r8, r1\n\t" "mov r8, r1\n\t"
@@ -906,7 +909,7 @@ chx_wakeup (struct chx_pq *pq)
tp = px->master; tp = px->master;
if (tp->state == THREAD_WAIT_POLL) if (tp->state == THREAD_WAIT_POLL)
{ {
((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = 1; tp->v = (uintptr_t)1;
if (tp->parent == &q_timer.q) if (tp->parent == &q_timer.q)
chx_timer_dequeue (tp); chx_timer_dequeue (tp);
chx_ready_enqueue (tp); chx_ready_enqueue (tp);
@@ -918,7 +921,7 @@ chx_wakeup (struct chx_pq *pq)
else else
{ {
tp = (struct chx_thread *)pq; tp = (struct chx_thread *)pq;
((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = 1; tp->v = (uintptr_t)1;
chx_ready_enqueue (tp); chx_ready_enqueue (tp);
if (!running || tp->prio > running->prio) if (!running || tp->prio > running->prio)
yield = 1; yield = 1;
@@ -1229,7 +1232,7 @@ chopstx_mutex_lock (chopstx_mutex_t *mutex)
if (tp0->state == THREAD_WAIT_TIME if (tp0->state == THREAD_WAIT_TIME
|| tp0->state == THREAD_WAIT_POLL) || tp0->state == THREAD_WAIT_POLL)
{ {
((struct chx_stack_regs *)tp0->tc.reg[REG_SP])->reg[REG_R0] = 1; tp0->v = (uintptr_t)1;
if (tp0->parent == &q_timer.q) if (tp0->parent == &q_timer.q)
chx_timer_dequeue (tp0); chx_timer_dequeue (tp0);
@@ -1688,7 +1691,7 @@ chopstx_cancel (chopstx_t thd)
return; return;
} }
((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = -1; tp->v = (uintptr_t)-1;
chx_ready_enqueue (tp); chx_ready_enqueue (tp);
if (tp->prio > running->prio) if (tp->prio > running->prio)
chx_sched (CHX_YIELD); chx_sched (CHX_YIELD);
@@ -2111,6 +2114,10 @@ svc (void)
} }
asm volatile ( asm volatile (
"cbz r0, 0f\n\t"
"ldr r1, [r0, #16]\n\t" /* ->V */
"str r1, [sp]\n\t"
"0:\n\t"
"b .L_CONTEXT_SWITCH" "b .L_CONTEXT_SWITCH"
: /* no output */ : "r" (tp) : "memory"); : /* no output */ : "r" (tp) : "memory");
} }