bug fixes around cancel/join/exit

This commit is contained in:
NIIBE Yutaka
2015-09-14 18:36:56 +09:00
parent 4705e2fb15
commit 8fed803085
2 changed files with 11 additions and 9 deletions

View File

@@ -1,3 +1,9 @@
2015-09-14 Niibe Yutaka <gniibe@fsij.org>
* chopstx.c (q_exit): Remove.
(chx_init, chx_exit): Remove access to Q_EXIT.
(chx_release_irq_thread): Fix removing form the list.
2015-09-11 Niibe Yutaka <gniibe@fsij.org> 2015-09-11 Niibe Yutaka <gniibe@fsij.org>
* chopstx.c (chx_init, chopstx_create): Fix the initial value * chopstx.c (chx_init, chopstx_create): Fix the initial value

View File

@@ -232,9 +232,6 @@ static struct chx_queue q_ready;
/* Queue of threads waiting for timer. */ /* Queue of threads waiting for timer. */
static struct chx_queue q_timer; static struct chx_queue q_timer;
/* Queue of threads which have been exited. */
static struct chx_queue q_exit;
/* Queue of threads which wait exit of some thread. */ /* Queue of threads which wait exit of some thread. */
static struct chx_queue q_join; static struct chx_queue q_join;
@@ -631,7 +628,6 @@ chx_init (struct chx_thread *tp)
memset (&tp->tc, 0, sizeof (tp->tc)); memset (&tp->tc, 0, sizeof (tp->tc));
q_ready.next = q_ready.prev = (struct chx_thread *)&q_ready; q_ready.next = q_ready.prev = (struct chx_thread *)&q_ready;
q_timer.next = q_timer.prev = (struct chx_thread *)&q_timer; q_timer.next = q_timer.prev = (struct chx_thread *)&q_timer;
q_exit.next = q_exit.prev = (struct chx_thread *)&q_exit;
q_join.next = q_join.prev = (struct chx_thread *)&q_join; q_join.next = q_join.prev = (struct chx_thread *)&q_join;
tp->next = tp->prev = tp; tp->next = tp->prev = tp;
tp->mutex_list = NULL; tp->mutex_list = NULL;
@@ -724,13 +720,10 @@ chx_exit (void *retval)
if (running->flag_sched_rr) if (running->flag_sched_rr)
chx_timer_dequeue (running); chx_timer_dequeue (running);
chx_spin_lock (&q_exit.lock);
ll_insert (running, &q_exit);
if (running->flag_detached) if (running->flag_detached)
running->state = THREAD_FINISHED; running->state = THREAD_FINISHED;
else else
running->state = THREAD_EXITED; running->state = THREAD_EXITED;
chx_spin_unlock (&q_exit.lock);
asm volatile ("" : : "r" (r8) : "memory"); asm volatile ("" : : "r" (r8) : "memory");
chx_sched (CHX_SLEEP); chx_sched (CHX_SLEEP);
/* never comes here. */ /* never comes here. */
@@ -1165,8 +1158,11 @@ chx_release_irq_thread (struct chx_thread *tp)
chx_spin_lock (&intr_lock); chx_spin_lock (&intr_lock);
intr_prev = intr_top; intr_prev = intr_top;
for (intr = intr_top; intr; intr = intr->next) for (intr = intr_top; intr; intr = intr->next)
if (intr->tp == tp) {
break; if (intr->tp == tp)
break;
intr_prev = intr;
}
if (intr) if (intr)
{ {