Change chx_ready_pop implementation.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2019-11-18 11:55:22 +09:00
parent 355482550b
commit b70de1b98d
4 changed files with 14 additions and 33 deletions

View File

@@ -1,3 +1,10 @@
2019-11-18 NIIBE Yutaka <gniibe@fsij.org>
* 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 <gniibe@fsij.org> 2019-11-18 NIIBE Yutaka <gniibe@fsij.org>
* chopstx-cortex-m.c (ticks_to_usec): New. * chopstx-cortex-m.c (ticks_to_usec): New.

View File

@@ -372,12 +372,6 @@ chx_sched (uint32_t yield)
} }
tp = chx_ready_pop (); 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. */ asm volatile (/* Now, r0 points to the thread to be switched. */
/* Put it to *running. */ /* Put it to *running. */
@@ -575,12 +569,6 @@ preempt (void)
/* Registers on stack (PSP): r0, r1, r2, r3, r12, lr, pc, xpsr */ /* Registers on stack (PSP): r0, r1, r2, r3, r12, lr, pc, xpsr */
tp = chx_ready_pop (); 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 ( asm volatile (
".L_CONTEXT_SWITCH:\n\t" ".L_CONTEXT_SWITCH:\n\t"
@@ -698,12 +686,6 @@ svc (void)
} }
tp = chx_ready_pop (); 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 ( asm volatile (
"b .L_CONTEXT_SWITCH" "b .L_CONTEXT_SWITCH"

View File

@@ -235,15 +235,7 @@ chx_request_preemption (uint16_t prio)
tp = running = chx_ready_pop (); tp = running = chx_ready_pop ();
if (tp) if (tp)
{ tcp = &tp->tc;
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);
}
}
else else
tcp = &idle_tc; tcp = &idle_tc;
@@ -306,12 +298,6 @@ chx_sched (uint32_t yield)
if (tp) if (tp)
{ {
v = tp->v; 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; tcp = &tp->tc;
} }
else else

View File

@@ -271,6 +271,12 @@ chx_ready_pop (void)
tp->state = THREAD_RUNNING; tp->state = THREAD_RUNNING;
chx_spin_unlock (&q_ready.lock); 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; return tp;
} }