Compare commits
9 Commits
release/1.
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc49f4ef23 | ||
|
|
a0732c125a | ||
|
|
6be482413c | ||
|
|
9253777f5f | ||
|
|
63f47cede3 | ||
|
|
4c0c15588e | ||
|
|
e58e134b42 | ||
|
|
4cd47453ae | ||
|
|
89523f22bf |
30
ChangeLog
30
ChangeLog
@@ -1,3 +1,33 @@
|
||||
2019-12-30 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* VERSION: 1.18.
|
||||
* doc/chopstx.texi (VERSION): 1.18.
|
||||
|
||||
2019-12-27 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* chopstx.c (chopstx_poll): Call CHECK for condition
|
||||
valiable after woken up.
|
||||
|
||||
2019-12-20 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* mcu/usb-st-common.c (usb_lld_ctrl_recv): Fix receiving
|
||||
more than one packet.
|
||||
|
||||
2019-12-04 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* chopstx-gnu-linux.c (chx_thread_start): Fix return value.
|
||||
|
||||
2019-11-21 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* chopstx-cortex-m.c (chx_set_running): New.
|
||||
(chx_init_arch): Use chx_set_running.
|
||||
(preempt, svc): Remove set to running, not needed.
|
||||
|
||||
* chopstx-gnu-linux.c (chx_set_running): New.
|
||||
(chx_init_arch, chx_request_preemption, chx_sched): Use
|
||||
chx_set_running and chx_running.
|
||||
(chx_sched): Bug fix of return value handling.
|
||||
|
||||
2019-11-20 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* VERSION: 1.17.
|
||||
|
||||
19
NEWS
19
NEWS
@@ -1,6 +1,25 @@
|
||||
NEWS - Noteworthy changes
|
||||
|
||||
|
||||
* Major changes in Chopstx 1.18
|
||||
|
||||
Released 2019-12-30
|
||||
|
||||
** Fix of chopstx_poll
|
||||
When waiting for a condition variable, we supply CHECK method with a
|
||||
descriptor. Since a condition variable may be fired for multiple
|
||||
reasons, old implementation of chopstx_poll may return with wrong
|
||||
information saying a condition of CHECK were met but actually not. It
|
||||
should not return when condition is not satisfied and it should not
|
||||
give wrong information to application. Fixed by calling the CHECK
|
||||
method again when woken up, and don't return when no condition meet.
|
||||
|
||||
** Bug fix for GNU/Linux emulation
|
||||
When woken up, return value of chx_sched was wrong. Because of this,
|
||||
timeout handling had problem. Termination value of a thread was
|
||||
wrong.
|
||||
|
||||
|
||||
* Major changes in Chopstx 1.17
|
||||
|
||||
Released 2019-11-20
|
||||
|
||||
7
README
7
README
@@ -1,6 +1,6 @@
|
||||
Chopstx - Threads and only Threads
|
||||
Version 1.17
|
||||
2019-11-20
|
||||
Version 1.18
|
||||
2019-12-30
|
||||
Niibe Yutaka
|
||||
Flying Stone Technology
|
||||
|
||||
@@ -60,7 +60,8 @@ For STM32 Primer2, see the directory: example-primer2.
|
||||
Future Works
|
||||
============
|
||||
|
||||
RISC-V port (for GD32VF103) is under development.
|
||||
RISC-V port (for GD32VF103) is under development. Please have a look
|
||||
at the master branch.
|
||||
|
||||
Convenience function to determine the bottom of thread stack,
|
||||
configuration of thread size by compiler's output would be next things
|
||||
|
||||
@@ -36,6 +36,12 @@ chx_running (void)
|
||||
return running;
|
||||
}
|
||||
|
||||
static void
|
||||
chx_set_running (struct chx_thread *r)
|
||||
{
|
||||
running = r;
|
||||
}
|
||||
|
||||
|
||||
/* Data Memory Barrier. */
|
||||
static void
|
||||
@@ -287,7 +293,7 @@ static void
|
||||
chx_init_arch (struct chx_thread *tp)
|
||||
{
|
||||
memset (&tp->tc, 0, sizeof (tp->tc));
|
||||
running = tp;
|
||||
chx_set_running (tp);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -572,7 +578,6 @@ preempt (void)
|
||||
}
|
||||
else
|
||||
chx_ready_push (tp);
|
||||
running = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,7 +697,6 @@ svc (void)
|
||||
if (tp->flag_sched_rr)
|
||||
chx_timer_dequeue (tp);
|
||||
chx_ready_enqueue (tp);
|
||||
running = NULL;
|
||||
}
|
||||
|
||||
tp = chx_ready_pop ();
|
||||
|
||||
@@ -40,6 +40,13 @@ chx_running (void)
|
||||
return running;
|
||||
}
|
||||
|
||||
static void
|
||||
chx_set_running (struct chx_thread *r)
|
||||
{
|
||||
running = r;
|
||||
}
|
||||
|
||||
|
||||
/* Data Memory Barrier. */
|
||||
static void
|
||||
chx_dmb (void)
|
||||
@@ -214,20 +221,21 @@ chx_init_arch (struct chx_thread *tp)
|
||||
|
||||
getcontext (&tp->tc);
|
||||
|
||||
running = tp;
|
||||
chx_set_running (tp);
|
||||
}
|
||||
|
||||
static void
|
||||
chx_request_preemption (uint16_t prio)
|
||||
{
|
||||
struct chx_thread *tp, *tp_prev;
|
||||
ucontext_t *tcp;
|
||||
struct chx_thread *tp_prev;
|
||||
struct chx_thread *tp = chx_running ();
|
||||
|
||||
if (running && (uint16_t)running->prio >= prio)
|
||||
if (tp && (uint16_t)tp->prio >= prio)
|
||||
return;
|
||||
|
||||
/* Change the context to another thread with higher priority. */
|
||||
tp = tp_prev = running;
|
||||
tp_prev = tp;
|
||||
if (tp)
|
||||
{
|
||||
if (tp->flag_sched_rr)
|
||||
@@ -240,15 +248,15 @@ chx_request_preemption (uint16_t prio)
|
||||
}
|
||||
else
|
||||
chx_ready_push (tp);
|
||||
running = NULL;
|
||||
}
|
||||
|
||||
tp = running = chx_ready_pop ();
|
||||
tp = chx_ready_pop ();
|
||||
if (tp)
|
||||
tcp = &tp->tc;
|
||||
else
|
||||
tcp = &idle_tc;
|
||||
|
||||
chx_set_running (tp);
|
||||
if (tp_prev)
|
||||
{
|
||||
/*
|
||||
@@ -293,10 +301,9 @@ static uintptr_t
|
||||
chx_sched (uint32_t yield)
|
||||
{
|
||||
struct chx_thread *tp, *tp_prev;
|
||||
uintptr_t v;
|
||||
ucontext_t *tcp;
|
||||
|
||||
tp = tp_prev = running;
|
||||
tp = tp_prev = chx_running ();
|
||||
if (yield)
|
||||
{
|
||||
if (tp->flag_sched_rr)
|
||||
@@ -304,29 +311,28 @@ chx_sched (uint32_t yield)
|
||||
chx_ready_enqueue (tp);
|
||||
}
|
||||
|
||||
running = tp = chx_ready_pop ();
|
||||
tp = chx_ready_pop ();
|
||||
if (tp)
|
||||
{
|
||||
v = tp->v;
|
||||
tcp = &tp->tc;
|
||||
}
|
||||
tcp = &tp->tc;
|
||||
else
|
||||
{
|
||||
v = 0;
|
||||
tcp = &idle_tc;
|
||||
}
|
||||
tcp = &idle_tc;
|
||||
|
||||
chx_set_running (tp);
|
||||
swapcontext (&tp_prev->tc, tcp);
|
||||
chx_cpu_sched_unlock ();
|
||||
return v;
|
||||
|
||||
tp = chx_running ();
|
||||
return tp->v;
|
||||
}
|
||||
|
||||
static void __attribute__((__noreturn__))
|
||||
chx_thread_start (voidfunc thread_entry, void *arg)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
chx_cpu_sched_unlock ();
|
||||
thread_entry (arg);
|
||||
chopstx_exit (0);
|
||||
ret = thread_entry (arg);
|
||||
chopstx_exit (ret);
|
||||
}
|
||||
|
||||
static struct chx_thread *
|
||||
|
||||
18
chopstx.c
18
chopstx.c
@@ -1411,6 +1411,7 @@ chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *const pd_array[])
|
||||
for (i = 0; i < n; i++)
|
||||
chx_proxy_init (&px[i], &counter);
|
||||
|
||||
again:
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
pd = pd_array[i];
|
||||
@@ -1473,6 +1474,20 @@ chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *const pd_array[])
|
||||
ll_dequeue ((struct chx_pq *)&px[i]);
|
||||
chx_spin_unlock (&pc->cond->lock);
|
||||
}
|
||||
else
|
||||
{ /* Check the condition again after woken up. */
|
||||
if (pc->mutex)
|
||||
chopstx_mutex_lock (pc->mutex);
|
||||
|
||||
if ((*pc->check) (pc->arg) == 0)
|
||||
{ /* Condition doesn't met. */
|
||||
pc->ready = 0;
|
||||
counter--;
|
||||
}
|
||||
|
||||
if (pc->mutex)
|
||||
chopstx_mutex_unlock (pc->mutex);
|
||||
}
|
||||
}
|
||||
else if (pd->type == CHOPSTX_POLL_INTR)
|
||||
{
|
||||
@@ -1504,6 +1519,9 @@ chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *const pd_array[])
|
||||
if (r < 0)
|
||||
chopstx_exit (CHOPSTX_CANCELED);
|
||||
|
||||
if (counter == 0 && (usec_p == NULL || *usec_p))
|
||||
goto again;
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename chopstx.info
|
||||
@set VERSION 1.17
|
||||
@set VERSION 1.18
|
||||
@settitle Chopstx Reference Manual
|
||||
@c Unify some of the indices.
|
||||
@syncodeindex tp fn
|
||||
|
||||
@@ -768,7 +768,7 @@ tty_main (void *arg)
|
||||
&& t->flag_send_ready)
|
||||
{
|
||||
uint8_t line[32];
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (len));
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (line));
|
||||
|
||||
if (len)
|
||||
{
|
||||
|
||||
@@ -780,7 +780,7 @@ tty_main (void *arg)
|
||||
&& t->flag_send_ready)
|
||||
{
|
||||
uint8_t line[32];
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (len));
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (line));
|
||||
|
||||
if (len)
|
||||
{
|
||||
|
||||
@@ -768,7 +768,7 @@ tty_main (void *arg)
|
||||
&& t->flag_send_ready)
|
||||
{
|
||||
uint8_t line[32];
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (len));
|
||||
int len = get_chars_from_ringbuffer (t, line, sizeof (line));
|
||||
|
||||
if (len)
|
||||
{
|
||||
|
||||
@@ -864,6 +864,8 @@ usb_lld_ctrl_recv (struct usb_dev *dev, void *p, size_t len)
|
||||
struct ctrl_data *data_p = &dev->ctrl_data;
|
||||
data_p->addr = p;
|
||||
data_p->len = len;
|
||||
if (len > USB_MAX_PACKET_SIZE)
|
||||
len = USB_MAX_PACKET_SIZE;
|
||||
dev->state = OUT_DATA;
|
||||
ep_set_rx_status (ENDP0, EP_RX_VALID);
|
||||
return USB_EVENT_OK;
|
||||
|
||||
Reference in New Issue
Block a user