pthread: Account for pth stopping in has_blocked
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 20 Oct 2015 18:16:19 +0000 (14:16 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Oct 2015 16:05:13 +0000 (12:05 -0400)
commit383de31570adf3c916be7e55254b6495f9cf67ba
tree84d020620d75755b7d88af226c7c7d266ef66e8d
parentb50178ab79ffb1fbe6d10d5fab6a9094cc14d625
pthread: Account for pth stopping in has_blocked

This popped up as

uthread.c:621: run_uthread: Assertion `uthread->state == 2' failed.

and

pthread.c:246: pth_sched_entry: Assertion `new_thread->state == 2'
failed.

for an epoll/eventfd app.

The ready and active queues were corrupted, due to adding a pthread to
the ready queue in pth_thread_runnable() that was still on the active
queue.

Anytime a pthread stops and will eventually have pth_thread_runnable()
called, as is the case with blocking a uthread on an event queue (which
epoll does), then the pthread code needs to yank it off the active
queue.  Modifications of pthread->state are a good sign that list
management needs to be done.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/pthread/pthread.c