diff options
| author | Bertrik Sikken <bertrik@sikken.nl> | 2010-04-18 15:24:39 +0000 |
|---|---|---|
| committer | Bertrik Sikken <bertrik@sikken.nl> | 2010-04-18 15:24:39 +0000 |
| commit | c493a1e39d4ce5c725bad9cb3686ee3e8477f734 (patch) | |
| tree | 9cd4ffb2df2fedafa365a7a8d930a67cf98adefe | |
| parent | 44454c3203c84930c3e46d593c44e1edd6d56cc8 (diff) | |
| download | rockbox-c493a1e39d4ce5c725bad9cb3686ee3e8477f734.zip rockbox-c493a1e39d4ce5c725bad9cb3686ee3e8477f734.tar.gz rockbox-c493a1e39d4ce5c725bad9cb3686ee3e8477f734.tar.bz2 rockbox-c493a1e39d4ce5c725bad9cb3686ee3e8477f734.tar.xz | |
Use boolean instead of int for keeping track of mutex signalled state and wakeup signalled state
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25671 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/export/kernel.h | 4 | ||||
| -rw-r--r-- | firmware/kernel.c | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index c4d661f..a476130 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -150,7 +150,7 @@ struct mutex struct thread_entry *thread; #endif IF_COP( struct corelock cl; ) /* multiprocessor sync */ - unsigned char locked; /* locked semaphore */ + bool locked; /* locked semaphore */ }; #ifdef HAVE_SEMAPHORE_OBJECTS @@ -167,7 +167,7 @@ struct semaphore struct wakeup { struct thread_entry *queue; /* waiter list */ - unsigned char signalled; /* signalled status */ + bool signalled; /* signalled status */ IF_COP( struct corelock cl; ) /* multiprocessor sync */ }; #endif diff --git a/firmware/kernel.c b/firmware/kernel.c index d7076c9..64c8142 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -892,7 +892,7 @@ void mutex_init(struct mutex *m) corelock_init(&m->cl); m->queue = NULL; m->count = 0; - m->locked = 0; + m->locked = false; mutex_set_thread(m, NULL); #ifdef HAVE_PRIORITY_SCHEDULING m->blocker.priority = PRIORITY_IDLE; @@ -916,11 +916,11 @@ void mutex_lock(struct mutex *m) /* lock out other cores */ corelock_lock(&m->cl); - if(LIKELY(m->locked == 0)) + if(LIKELY(!m->locked)) { /* lock is open */ mutex_set_thread(m, current); - m->locked = 1; + m->locked = true; corelock_unlock(&m->cl); return; } @@ -963,7 +963,7 @@ void mutex_unlock(struct mutex *m) { /* no threads waiting - open the lock */ mutex_set_thread(m, NULL); - m->locked = 0; + m->locked = false; corelock_unlock(&m->cl); return; } @@ -1062,7 +1062,7 @@ void semaphore_release(struct semaphore *s) void wakeup_init(struct wakeup *w) { w->queue = NULL; - w->signalled = 0; + w->signalled = false; IF_COP( corelock_init(&w->cl); ) } @@ -1074,7 +1074,7 @@ int wakeup_wait(struct wakeup *w, int timeout) corelock_lock(&w->cl); - if(LIKELY(w->signalled == 0 && timeout != TIMEOUT_NOBLOCK)) + if(LIKELY(!w->signalled && timeout != TIMEOUT_NOBLOCK)) { struct thread_entry * current = thread_id_entry(THREAD_ID_CURRENT); @@ -1093,14 +1093,14 @@ int wakeup_wait(struct wakeup *w, int timeout) corelock_lock(&w->cl); } - if(UNLIKELY(w->signalled == 0)) + if(UNLIKELY(!w->signalled)) { /* Timed-out or failed */ ret = (timeout != TIMEOUT_BLOCK) ? OBJ_WAIT_TIMEDOUT : OBJ_WAIT_FAILED; } - w->signalled = 0; /* Reset */ + w->signalled = false; /* Reset */ corelock_unlock(&w->cl); restore_irq(oldlevel); @@ -1120,7 +1120,7 @@ int wakeup_signal(struct wakeup *w) corelock_lock(&w->cl); - w->signalled = 1; + w->signalled = true; ret = wakeup_thread(&w->queue); corelock_unlock(&w->cl); |