diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-04-16 22:01:59 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-04-16 22:01:59 +0000 |
commit | d9af87c40b3a613a7a2a312d4529e566d0565a2c (patch) | |
tree | 5122aa3ee6af0984684644f872b1af850b78cc2e /firmware | |
parent | da018391e0b7756eba9655384e9cf3683d133361 (diff) | |
download | rockbox-d9af87c40b3a613a7a2a312d4529e566d0565a2c.tar.gz rockbox-d9af87c40b3a613a7a2a312d4529e566d0565a2c.zip |
Use API call instead of accessing a global variable for receiving the current thread.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25657 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/kernel.c | 23 | ||||
-rw-r--r-- | firmware/thread.c | 2 |
2 files changed, 11 insertions, 14 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index 29907f3082..27f3b0d08b 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -57,8 +57,6 @@ volatile long current_tick SHAREDDATA_ATTR = 0; | |||
57 | /* List of tick tasks - final element always NULL for termination */ | 57 | /* List of tick tasks - final element always NULL for termination */ |
58 | void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void); | 58 | void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void); |
59 | 59 | ||
60 | extern struct core_entry cores[NUM_CORES]; | ||
61 | |||
62 | /* This array holds all queues that are initiated. It is used for broadcast. */ | 60 | /* This array holds all queues that are initiated. It is used for broadcast. */ |
63 | static struct | 61 | static struct |
64 | { | 62 | { |
@@ -535,7 +533,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) | |||
535 | 533 | ||
536 | #ifdef HAVE_PRIORITY_SCHEDULING | 534 | #ifdef HAVE_PRIORITY_SCHEDULING |
537 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || | 535 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || |
538 | QUEUE_GET_THREAD(q) == cores[CURRENT_CORE].running, | 536 | QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), |
539 | "queue_wait->wrong thread\n"); | 537 | "queue_wait->wrong thread\n"); |
540 | #endif | 538 | #endif |
541 | 539 | ||
@@ -547,7 +545,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) | |||
547 | 545 | ||
548 | if (q->read == q->write) | 546 | if (q->read == q->write) |
549 | { | 547 | { |
550 | struct thread_entry *current = cores[CURRENT_CORE].running; | 548 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); |
551 | 549 | ||
552 | do | 550 | do |
553 | { | 551 | { |
@@ -582,7 +580,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) | |||
582 | 580 | ||
583 | #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME | 581 | #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME |
584 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || | 582 | KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || |
585 | QUEUE_GET_THREAD(q) == cores[CURRENT_CORE].running, | 583 | QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), |
586 | "queue_wait_w_tmo->wrong thread\n"); | 584 | "queue_wait_w_tmo->wrong thread\n"); |
587 | #endif | 585 | #endif |
588 | 586 | ||
@@ -594,7 +592,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) | |||
594 | 592 | ||
595 | if (q->read == q->write && ticks > 0) | 593 | if (q->read == q->write && ticks > 0) |
596 | { | 594 | { |
597 | struct thread_entry *current = cores[CURRENT_CORE].running; | 595 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); |
598 | 596 | ||
599 | IF_COP( current->obj_cl = &q->cl; ) | 597 | IF_COP( current->obj_cl = &q->cl; ) |
600 | current->bqp = &q->queue; | 598 | current->bqp = &q->queue; |
@@ -669,7 +667,7 @@ intptr_t queue_send(struct event_queue *q, long id, intptr_t data) | |||
669 | { | 667 | { |
670 | struct queue_sender_list *send = q->send; | 668 | struct queue_sender_list *send = q->send; |
671 | struct thread_entry **spp = &send->senders[wr]; | 669 | struct thread_entry **spp = &send->senders[wr]; |
672 | struct thread_entry *current = cores[CURRENT_CORE].running; | 670 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); |
673 | 671 | ||
674 | if(UNLIKELY(*spp)) | 672 | if(UNLIKELY(*spp)) |
675 | { | 673 | { |
@@ -878,8 +876,7 @@ void mutex_init(struct mutex *m) | |||
878 | /* Gain ownership of a mutex object or block until it becomes free */ | 876 | /* Gain ownership of a mutex object or block until it becomes free */ |
879 | void mutex_lock(struct mutex *m) | 877 | void mutex_lock(struct mutex *m) |
880 | { | 878 | { |
881 | const unsigned int core = CURRENT_CORE; | 879 | struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); |
882 | struct thread_entry *current = cores[core].running; | ||
883 | 880 | ||
884 | if(current == MUTEX_GET_THREAD(m)) | 881 | if(current == MUTEX_GET_THREAD(m)) |
885 | { | 882 | { |
@@ -918,10 +915,10 @@ void mutex_lock(struct mutex *m) | |||
918 | void mutex_unlock(struct mutex *m) | 915 | void mutex_unlock(struct mutex *m) |
919 | { | 916 | { |
920 | /* unlocker not being the owner is an unlocking violation */ | 917 | /* unlocker not being the owner is an unlocking violation */ |
921 | KERNEL_ASSERT(MUTEX_GET_THREAD(m) == cores[CURRENT_CORE].running, | 918 | KERNEL_ASSERT(MUTEX_GET_THREAD(m) == thread_id_entry(THREAD_ID_CURRENT), |
922 | "mutex_unlock->wrong thread (%s != %s)\n", | 919 | "mutex_unlock->wrong thread (%s != %s)\n", |
923 | MUTEX_GET_THREAD(m)->name, | 920 | MUTEX_GET_THREAD(m)->name, |
924 | cores[CURRENT_CORE].running->name); | 921 | thread_id_entry(THREAD_ID_CURRENT)->name); |
925 | 922 | ||
926 | if(m->count > 0) | 923 | if(m->count > 0) |
927 | { | 924 | { |
@@ -989,7 +986,7 @@ void semaphore_wait(struct semaphore *s) | |||
989 | } | 986 | } |
990 | 987 | ||
991 | /* too many waits - block until dequeued... */ | 988 | /* too many waits - block until dequeued... */ |
992 | current = cores[CURRENT_CORE].running; | 989 | current = thread_id_entry(THREAD_ID_CURRENT); |
993 | 990 | ||
994 | IF_COP( current->obj_cl = &s->cl; ) | 991 | IF_COP( current->obj_cl = &s->cl; ) |
995 | current->bqp = &s->queue; | 992 | current->bqp = &s->queue; |
@@ -1051,7 +1048,7 @@ int wakeup_wait(struct wakeup *w, int timeout) | |||
1051 | 1048 | ||
1052 | if(LIKELY(w->signalled == 0 && timeout != TIMEOUT_NOBLOCK)) | 1049 | if(LIKELY(w->signalled == 0 && timeout != TIMEOUT_NOBLOCK)) |
1053 | { | 1050 | { |
1054 | struct thread_entry * current = cores[CURRENT_CORE].running; | 1051 | struct thread_entry * current = thread_id_entry(THREAD_ID_CURRENT); |
1055 | 1052 | ||
1056 | IF_COP( current->obj_cl = &w->cl; ) | 1053 | IF_COP( current->obj_cl = &w->cl; ) |
1057 | current->bqp = &w->queue; | 1054 | current->bqp = &w->queue; |
diff --git a/firmware/thread.c b/firmware/thread.c index 81ef42a6b0..7c2cfb23e9 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -119,7 +119,7 @@ | |||
119 | /* Cast to the the machine pointer size, whose size could be < 4 or > 32 | 119 | /* Cast to the the machine pointer size, whose size could be < 4 or > 32 |
120 | * (someday :). */ | 120 | * (someday :). */ |
121 | #define DEADBEEF ((uintptr_t)0xdeadbeefdeadbeefull) | 121 | #define DEADBEEF ((uintptr_t)0xdeadbeefdeadbeefull) |
122 | struct core_entry cores[NUM_CORES] IBSS_ATTR; | 122 | static struct core_entry cores[NUM_CORES] IBSS_ATTR; |
123 | struct thread_entry threads[MAXTHREADS] IBSS_ATTR; | 123 | struct thread_entry threads[MAXTHREADS] IBSS_ATTR; |
124 | 124 | ||
125 | static const char main_thread_name[] = "main"; | 125 | static const char main_thread_name[] = "main"; |