diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c | 2 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/thread-sdl.c | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c index 283c1a2c73..2df461015e 100644 --- a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c +++ b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c | |||
@@ -197,7 +197,7 @@ static enum | |||
197 | static inline void charging_set_thread_priority(bool charging) | 197 | static inline void charging_set_thread_priority(bool charging) |
198 | { | 198 | { |
199 | #ifdef HAVE_PRIORITY_SCHEDULING | 199 | #ifdef HAVE_PRIORITY_SCHEDULING |
200 | thread_set_priority(THREAD_ID_CURRENT, | 200 | thread_set_priority(thread_self(), |
201 | charging ? PRIORITY_REALTIME : PRIORITY_SYSTEM); | 201 | charging ? PRIORITY_REALTIME : PRIORITY_SYSTEM); |
202 | #endif | 202 | #endif |
203 | (void)charging; | 203 | (void)charging; |
diff --git a/firmware/target/hosted/sdl/thread-sdl.c b/firmware/target/hosted/sdl/thread-sdl.c index 08f20367cc..eaffa86aee 100644 --- a/firmware/target/hosted/sdl/thread-sdl.c +++ b/firmware/target/hosted/sdl/thread-sdl.c | |||
@@ -253,9 +253,7 @@ void * sim_thread_unlock(void) | |||
253 | 253 | ||
254 | struct thread_entry * thread_id_entry(unsigned int thread_id) | 254 | struct thread_entry * thread_id_entry(unsigned int thread_id) |
255 | { | 255 | { |
256 | return (thread_id == THREAD_ID_CURRENT) ? | 256 | return &threads[thread_id & THREAD_ID_SLOT_MASK]; |
257 | cores[CURRENT_CORE].running : | ||
258 | &threads[thread_id & THREAD_ID_SLOT_MASK]; | ||
259 | } | 257 | } |
260 | 258 | ||
261 | static void add_to_list_l(struct thread_entry **list, | 259 | static void add_to_list_l(struct thread_entry **list, |
@@ -299,11 +297,16 @@ static void remove_from_list_l(struct thread_entry **list, | |||
299 | thread->l.next->l.prev = thread->l.prev; | 297 | thread->l.next->l.prev = thread->l.prev; |
300 | } | 298 | } |
301 | 299 | ||
302 | unsigned int thread_get_current(void) | 300 | unsigned int thread_self(void) |
303 | { | 301 | { |
304 | return cores[CURRENT_CORE].running->id; | 302 | return cores[CURRENT_CORE].running->id; |
305 | } | 303 | } |
306 | 304 | ||
305 | struct thread_entry* thread_self_entry(void) | ||
306 | { | ||
307 | return cores[CURRENT_CORE].running; | ||
308 | } | ||
309 | |||
307 | void switch_thread(void) | 310 | void switch_thread(void) |
308 | { | 311 | { |
309 | struct thread_entry *current = cores[CURRENT_CORE].running; | 312 | struct thread_entry *current = cores[CURRENT_CORE].running; |
@@ -562,7 +565,7 @@ void remove_thread(unsigned int thread_id) | |||
562 | SDL_Thread *t; | 565 | SDL_Thread *t; |
563 | SDL_sem *s; | 566 | SDL_sem *s; |
564 | 567 | ||
565 | if (thread_id != THREAD_ID_CURRENT && thread->id != thread_id) | 568 | if (thread->id != thread_id) |
566 | return; | 569 | return; |
567 | 570 | ||
568 | int oldlevel = disable_irq_save(); | 571 | int oldlevel = disable_irq_save(); |
@@ -629,11 +632,11 @@ void remove_thread(unsigned int thread_id) | |||
629 | 632 | ||
630 | void thread_exit(void) | 633 | void thread_exit(void) |
631 | { | 634 | { |
632 | remove_thread(THREAD_ID_CURRENT); | 635 | unsigned int id = thread_self(); |
636 | remove_thread(id); | ||
633 | /* This should never and must never be reached - if it is, the | 637 | /* This should never and must never be reached - if it is, the |
634 | * state is corrupted */ | 638 | * state is corrupted */ |
635 | THREAD_PANICF("thread_exit->K:*R (ID: %d)", | 639 | THREAD_PANICF("thread_exit->K:*R (ID: %d)", id); |
636 | thread_id_entry(THREAD_ID_CURRENT)->id); | ||
637 | while (1); | 640 | while (1); |
638 | } | 641 | } |
639 | 642 | ||
@@ -642,8 +645,7 @@ void thread_wait(unsigned int thread_id) | |||
642 | struct thread_entry *current = cores[CURRENT_CORE].running; | 645 | struct thread_entry *current = cores[CURRENT_CORE].running; |
643 | struct thread_entry *thread = thread_id_entry(thread_id); | 646 | struct thread_entry *thread = thread_id_entry(thread_id); |
644 | 647 | ||
645 | if (thread_id == THREAD_ID_CURRENT || | 648 | if (thread->id == thread_id && thread->state != STATE_KILLED) |
646 | (thread->id == thread_id && thread->state != STATE_KILLED)) | ||
647 | { | 649 | { |
648 | current->bqp = &thread->queue; | 650 | current->bqp = &thread->queue; |
649 | block_thread(current); | 651 | block_thread(current); |