Add a helper to sleep a uthread forever
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 21 Apr 2016 20:50:35 +0000 (13:50 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
Just a double-lock on a mutex.  Thread0 for some apps might want to do
this.

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

index 8e2d6e4..0641aff 100644 (file)
@@ -88,6 +88,7 @@ void uthread_yield(bool save_state, void (*yield_func)(struct uthread*, void*),
                    void *yield_arg);
 void uthread_sleep(unsigned int seconds);
 void uthread_usleep(unsigned int usecs);
+void uthread_sleep_forever(void);
 void uthread_has_blocked(struct uthread *uthread, int flags);
 void uthread_paused(struct uthread *uthread);
 
index 3503115..47ce2d2 100644 (file)
@@ -475,6 +475,14 @@ void uthread_usleep(unsigned int usecs)
        sys_block(usecs);       /* usec sleep */
 }
 
+void uthread_sleep_forever(void)
+{
+       uth_mutex_t mtx = uth_mutex_alloc();
+
+       uth_mutex_lock(mtx);
+       uth_mutex_lock(mtx);
+}
+
 /* Cleans up the uthread (the stuff we did in uthread_init()).  If you want to
  * destroy a currently running uthread, you'll want something like
  * pthread_exit(), which yields, and calls this from its sched_ops yield. */