parlib: Tease out uth_sync_t from has_blocked()
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 28 Apr 2017 16:05:29 +0000 (12:05 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 3 May 2017 16:16:41 +0000 (12:16 -0400)
commit9e6927a5a4b7ae55a4162abf61f1f3481f62f993
tree8a72d174f6121d72905144df6d2033e96bdfdb00
parentd31bd5722471eb4e9e507f0f691213c222a8afd1
parlib: Tease out uth_sync_t from has_blocked()

Some callers of uthread_has_blocked() might want to separate the blocking
on the sync from the notification to the 2LS - even though both of those
are 2LS ops.

The specific case is pthread_barriers (in an upcoming patch).  There, we
have an optimization where we don't hold the spinlock across
uthread_yield(), and instead reacquire it and double-check if we should
block.  In that case, we'd rather call the 2LS has_blocked *before*
grabbing the barrier's spinlock (> 25% performance improvement).  Other
sync primitives might want to do the same.

Overall, this is probably a better fit - it removes those has_blocked cases
that take NULL and provides a little more flexibility to the sync primitive
code.  It also gets rid of the slightly ugly __uth_default_sync_enqueue()
and provides a nicer sync object interface.  The downside is that the 2LS
gets its has_blocked info independent of the source of the blocking.
Probably doesn't matter.

Similar to the commit 'Make sync objects static', I considered rebasing
this change, but I didn't want to break git bisect or otherwise introduce
hard-to-debug problems, which I've already had a few of due to the
toolchain changes.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/event.c
user/parlib/include/parlib/uthread.h
user/parlib/mutex.c
user/parlib/thread0_sched.c
user/parlib/uthread.c
user/pthread/futex.c
user/pthread/pthread.c
user/vmm/sched.c