diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-04 12:47:39 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-04 12:47:39 +0000 |
commit | 80f8b22357d4997c2025bee4660f726f3049fe74 (patch) | |
tree | 4246890690b8fe36ad26cced79190c3b45db07ec | |
parent | 150c5a7ceff528cbd5bdd153d3e29f0f6d4f794a (diff) |
Clarified the mutex code, renamed the NUM_TICK_TASKS macro
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@885 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/kernel.c | 18 | ||||
-rw-r--r-- | firmware/kernel.h | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index 12b6eea781..be30d8e56b 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -25,7 +25,7 @@ long current_tick = 0; -void (*tick_funcs[NUM_TICK_TASKS])(void); +void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); static void tick_start(unsigned int interval_in_ms); @@ -37,7 +37,7 @@ void kernel_init(void) int i; /* Clear the tick task array */ - for(i = 0;i < NUM_TICK_TASKS;i++) + for(i = 0;i < MAX_NUM_TICK_TASKS;i++) { tick_funcs[i] = NULL; } @@ -151,7 +151,7 @@ void IMIA0(void) int i; /* Run through the list of tick tasks */ - for(i = 0;i < NUM_TICK_TASKS;i++) + for(i = 0;i < MAX_NUM_TICK_TASKS;i++) { if(tick_funcs[i]) { @@ -170,7 +170,7 @@ int tick_add_task(void (*f)(void)) int oldlevel = set_irq_level(15); /* Add a task if there is room */ - for(i = 0;i < NUM_TICK_TASKS;i++) + for(i = 0;i < MAX_NUM_TICK_TASKS;i++) { if(tick_funcs[i] == NULL) { @@ -189,7 +189,7 @@ int tick_remove_task(void (*f)(void)) int oldlevel = set_irq_level(15); /* Remove a task if it is there */ - for(i = 0;i < NUM_TICK_TASKS;i++) + for(i = 0;i < MAX_NUM_TICK_TASKS;i++) { if(tick_funcs[i] == f) { @@ -208,20 +208,20 @@ int tick_remove_task(void (*f)(void)) ****************************************************************************/ void mutex_init(struct mutex *m) { - m->count = 0; + m->locked = false; } void mutex_lock(struct mutex *m) { /* Wait until the lock is open... */ - while(m->count) + while(m->locked) yield(); /* ...and lock it */ - m->count++; + m->locked = true; } void mutex_unlock(struct mutex *m) { - m->count--; + m->locked = false; } diff --git a/firmware/kernel.h b/firmware/kernel.h index f79bc42b80..ee9ded7ab0 100644 --- a/firmware/kernel.h +++ b/firmware/kernel.h @@ -27,7 +27,7 @@ #define HZ 100 /* number of ticks per second */ -#define NUM_TICK_TASKS 4 +#define MAX_NUM_TICK_TASKS 4 #define QUEUE_LENGTH 16 /* MUST be a power of 2 */ #define QUEUE_LENGTH_MASK (QUEUE_LENGTH - 1) @@ -47,7 +47,7 @@ struct event_queue struct mutex { - int count; + bool locked; }; /* global tick variable */ |