aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2017-06-21 20:48:50 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2017-06-21 20:48:50 +0900
commitca1b22c3eba3752927bb243aa6c33d082a515da0 (patch)
tree77539b9ba4c687316623b04f7b873d5ffc1fa78f
parent6c68c55301ff2b83a040a66975d3c44047a60b92 (diff)
Use ->V for the return value of chx_sched.
-rw-r--r--ChangeLog7
-rw-r--r--chopstx.c17
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 79b80fd..15e2f21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* chopstx.c (struct chx_pq): Use uintptr_t for V.
diff --git a/chopstx.c b/chopstx.c
index 410b841..94113ea 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -816,8 +816,11 @@ chx_sched (uint32_t yield)
/* Normal context switch */
"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!, {r1, r2, r3}\n\t"
"mov r8, r1\n\t"
@@ -906,7 +909,7 @@ chx_wakeup (struct chx_pq *pq)
tp = px->master;
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)
chx_timer_dequeue (tp);
chx_ready_enqueue (tp);
@@ -918,7 +921,7 @@ chx_wakeup (struct chx_pq *pq)
else
{
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);
if (!running || tp->prio > running->prio)
yield = 1;
@@ -1229,7 +1232,7 @@ chopstx_mutex_lock (chopstx_mutex_t *mutex)
if (tp0->state == THREAD_WAIT_TIME
|| 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)
chx_timer_dequeue (tp0);
@@ -1688,7 +1691,7 @@ chopstx_cancel (chopstx_t thd)
return;
}
- ((struct chx_stack_regs *)tp->tc.reg[REG_SP])->reg[REG_R0] = -1;
+ tp->v = (uintptr_t)-1;
chx_ready_enqueue (tp);
if (tp->prio > running->prio)
chx_sched (CHX_YIELD);
@@ -2111,6 +2114,10 @@ svc (void)
}
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"
: /* no output */ : "r" (tp) : "memory");
}