Programs with a single thread do not need mutexes. The default implementations would probably be safe, since the mutex should be unlocked, unless a program recursively locked the same mutex. In that case, they are in trouble anyways (deadlock, usually).
Signed-off-by: Barret Rhoden <[email protected]> --- user/parlib/thread0_sched.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/user/parlib/thread0_sched.c b/user/parlib/thread0_sched.c index 64a78429b4ae..e0b7f9fe51c0 100644 --- a/user/parlib/thread0_sched.c +++ b/user/parlib/thread0_sched.c @@ -22,6 +22,10 @@ static void thread0_thread_refl_fault(struct uthread *uthread, unsigned long aux); static void thread0_thread_runnable(struct uthread *uth); static void thread0_thread_has_blocked(struct uthread *uth, int flags); +static uth_mutex_t thread0_mtx_alloc(void); +static void thread0_mtx_free(uth_mutex_t m); +static void thread0_mtx_lock(uth_mutex_t m); +static void thread0_mtx_unlock(uth_mutex_t m); /* externed into uthread.c */ struct schedule_ops thread0_2ls_ops = { @@ -31,6 +35,10 @@ struct schedule_ops thread0_2ls_ops = { .thread_runnable = thread0_thread_runnable, .thread_paused = thread0_thread_runnable, .thread_has_blocked = thread0_thread_has_blocked, + .mutex_alloc = thread0_mtx_alloc, + .mutex_free = thread0_mtx_free, + .mutex_lock = thread0_mtx_lock, + .mutex_unlock = thread0_mtx_unlock, }; /* externed into uthread.c */ @@ -108,3 +116,22 @@ static void thread0_thread_has_blocked(struct uthread *uth, int flags) { thread0_info.is_blocked = TRUE; } + +/* We only have one thread, so we don't need mutexes */ +static uth_mutex_t thread0_mtx_alloc(void) +{ + /* Returning something non-zero, in case someone compares it to 0 */ + return (uth_mutex_t)0x1234; +} + +static void thread0_mtx_free(uth_mutex_t m) +{ +} + +static void thread0_mtx_lock(uth_mutex_t m) +{ +} + +static void thread0_mtx_unlock(uth_mutex_t m) +{ +} -- 2.6.0.rc2.230.g3dd15c0 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
