Fix GNU/Linux emulation.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2021-02-09 16:36:40 +09:00
parent af3ef1f93d
commit 7b7335bc5d
2 changed files with 21 additions and 7 deletions

View File

@@ -1,3 +1,8 @@
2021-02-09 NIIBE Yutaka <gniibe@fsij.org>
* chopstx-gnu-linux.c (voluntary_context_switch): Fix for the case
when chx_idle suggests no context switch (tp_prev == tp_next).
2021-02-08 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (chx_recv_irq): Bug fix when no waiter.

View File

@@ -2,7 +2,7 @@
* chopstx-gnu-linux.c - Threads and only threads: Arch specific code
* for GNU/Linux emulation
*
* Copyright (C) 2017, 2018, 2019 Flying Stone Technology
* Copyright (C) 2017, 2018, 2019, 2021 Flying Stone Technology
* Author: NIIBE Yutaka <gniibe@fsij.org>
*
* This file is a part of Chopstx, a thread library for embedded.
@@ -260,14 +260,23 @@ preempted_context_switch (struct chx_thread *tp_next)
static uintptr_t
voluntary_context_switch (struct chx_thread *tp_next)
{
struct chx_thread *tp, *tp_prev;
if (!tp_next)
tp_next = chx_idle ();
struct chx_thread *tp;
struct chx_thread *tp_prev;
tp_prev = chx_running ();
chx_set_running (tp_next);
swapcontext (&tp_prev->tc, &tp_next->tc);
if (!tp_next)
{
chx_set_running (NULL);
tp_next = chx_idle ();
chx_set_running (tp_next);
if (tp_prev != tp_next)
swapcontext (&tp_prev->tc, &tp_next->tc);
}
else
{
chx_set_running (tp_next);
swapcontext (&tp_prev->tc, &tp_next->tc);
}
chx_cpu_sched_unlock ();
tp = chx_running ();