parlib: Don't double-lock a mutex to sleep
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 20 Jan 2017 22:08:46 +0000 (17:08 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 20 Jan 2017 22:08:46 +0000 (17:08 -0500)
commit4a874b08a5771c30179a0f6cc9a30c40eec1c0fc
treed8f902ebaf13391967ea6652a41cba85c6b91e1c
parent5d94c695f4d00a2b0afaab50dca8e8dcc42ed787
parlib: Don't double-lock a mutex to sleep

Yes, double-locking mutexes will normally sleep forever, but it's a little
hacky.  Especially considering how the thread0 scheduler doesn't currently
use mutexes!  Other schedulers / frameworks might treat locking a locked
mutex as a bug too.

Yes!  This means that any app using uthread_sleep_forever() that was using
the thread0 scheduler (e.g. daemonize) would always return immediately.  In
fact, daemonize probably never worked, unless it happened to have pthreads
or something linked in.  That's responsible for two things: /net/ndb wasn't
written before we moved past ipconfig in the ifconfig script, and
occasionally you'd get an "Unable to open cs" complaint from srv.
daemonize was returning early.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/include/parlib/uthread.h
user/parlib/uthread.c