From b70de1b98d8dbd4ef2567b608eb01308ef76d095 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 18 Nov 2019 11:55:22 +0900 Subject: [PATCH] Change chx_ready_pop implementation. Signed-off-by: NIIBE Yutaka --- ChangeLog | 7 +++++++ chopstx-cortex-m.c | 18 ------------------ chopstx-gnu-linux.c | 16 +--------------- chopstx.c | 6 ++++++ 4 files changed, 14 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 554c49e..7888f86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-11-18 NIIBE Yutaka + + * chopstx.c (chx_ready_pop): Check flag_sched_rr here. + * chopstx-cortex-m.c (chx_sched) [__ARM_ARCH_6M__]: Use + new interface of chx_ready_pop. + (preempt,svc): Likewise. + 2019-11-18 NIIBE Yutaka * chopstx-cortex-m.c (ticks_to_usec): New. diff --git a/chopstx-cortex-m.c b/chopstx-cortex-m.c index ea824d9..e970076 100644 --- a/chopstx-cortex-m.c +++ b/chopstx-cortex-m.c @@ -372,12 +372,6 @@ chx_sched (uint32_t yield) } tp = chx_ready_pop (); - if (tp && tp->flag_sched_rr) - { - chx_spin_lock (&q_timer.lock); - tp = chx_timer_insert (tp, PREEMPTION_USEC); - chx_spin_unlock (&q_timer.lock); - } asm volatile (/* Now, r0 points to the thread to be switched. */ /* Put it to *running. */ @@ -575,12 +569,6 @@ preempt (void) /* Registers on stack (PSP): r0, r1, r2, r3, r12, lr, pc, xpsr */ tp = chx_ready_pop (); - if (tp && tp->flag_sched_rr) - { - chx_spin_lock (&q_timer.lock); - tp = chx_timer_insert (tp, PREEMPTION_USEC); - chx_spin_unlock (&q_timer.lock); - } asm volatile ( ".L_CONTEXT_SWITCH:\n\t" @@ -698,12 +686,6 @@ svc (void) } tp = chx_ready_pop (); - if (tp && tp->flag_sched_rr) - { - chx_spin_lock (&q_timer.lock); - chx_timer_insert (tp, PREEMPTION_USEC); - chx_spin_unlock (&q_timer.lock); - } asm volatile ( "b .L_CONTEXT_SWITCH" diff --git a/chopstx-gnu-linux.c b/chopstx-gnu-linux.c index d9f9876..c22810a 100644 --- a/chopstx-gnu-linux.c +++ b/chopstx-gnu-linux.c @@ -235,15 +235,7 @@ chx_request_preemption (uint16_t prio) tp = running = chx_ready_pop (); if (tp) - { - tcp = &tp->tc; - if (tp->flag_sched_rr) - { - chx_spin_lock (&q_timer.lock); - tp = chx_timer_insert (tp, PREEMPTION_USEC); - chx_spin_unlock (&q_timer.lock); - } - } + tcp = &tp->tc; else tcp = &idle_tc; @@ -306,12 +298,6 @@ chx_sched (uint32_t yield) if (tp) { v = tp->v; - if (tp->flag_sched_rr) - { - chx_spin_lock (&q_timer.lock); - tp = chx_timer_insert (tp, PREEMPTION_USEC); - chx_spin_unlock (&q_timer.lock); - } tcp = &tp->tc; } else diff --git a/chopstx.c b/chopstx.c index 74947d0..2c3667c 100644 --- a/chopstx.c +++ b/chopstx.c @@ -271,6 +271,12 @@ chx_ready_pop (void) tp->state = THREAD_RUNNING; chx_spin_unlock (&q_ready.lock); + if (tp && tp->flag_sched_rr) + { + chx_spin_lock (&q_timer.lock); + chx_timer_insert (tp, PREEMPTION_USEC); + chx_spin_unlock (&q_timer.lock); + } return tp; }