summaryrefslogtreecommitdiff
path: root/firmware/kernel/include/thread.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2014-08-08 06:33:51 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-08-16 05:15:37 -0400
commit6ed00870abd566d7267d2436c2693f5a281cda2f (patch)
tree6011c73e302254fc73f61a1b8b1f295ded1f5d56 /firmware/kernel/include/thread.h
parenteb63d8b4a2a7cbe4e98216b48a75391718fcebd7 (diff)
downloadrockbox-6ed00870abd566d7267d2436c2693f5a281cda2f.tar.gz
rockbox-6ed00870abd566d7267d2436c2693f5a281cda2f.zip
Base scheduler queues off linked lists and do cleanup/consolidation
Abstracts threading from itself a bit, changes the way its queues are handled and does type hiding for that as well. Do alot here due to already required major brain surgery. Threads may now be on a run queue and a wait queue simultaneously so that the expired timer only has to wake the thread but not remove it from the wait queue which simplifies the implicit wake handling. List formats change for wait queues-- doubly-linked, not circular. Timeout queue is now singly-linked. The run queue is still circular as before. Adds a better thread slot allocator that may keep the slot marked as used regardless of the thread state. Assists in dumping special tasks that switch_thread was tasked to perform (blocking tasks). Deletes alot of code yet surprisingly, gets larger than expected. Well, I'm not not minding that for the time being-- omlettes and break a few eggs and all that. Change-Id: I0834d7bb16b2aecb2f63b58886eeda6ae4f29d59
Diffstat (limited to 'firmware/kernel/include/thread.h')
-rw-r--r--firmware/kernel/include/thread.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/firmware/kernel/include/thread.h b/firmware/kernel/include/thread.h
index 5a8bff0107..dfb632785e 100644
--- a/firmware/kernel/include/thread.h
+++ b/firmware/kernel/include/thread.h
@@ -26,6 +26,7 @@
26#include <stdbool.h> 26#include <stdbool.h>
27#include "config.h" 27#include "config.h"
28#include "gcc_extensions.h" 28#include "gcc_extensions.h"
29#include "linked_list.h"
29#include "bitarray.h" 30#include "bitarray.h"
30#include "corelock.h" 31#include "corelock.h"
31 32
@@ -52,7 +53,7 @@
52#define PRIORITY_REALTIME_4 4 53#define PRIORITY_REALTIME_4 4
53#define PRIORITY_REALTIME 4 /* Lowest realtime range */ 54#define PRIORITY_REALTIME 4 /* Lowest realtime range */
54#define PRIORITY_BUFFERING 15 /* Codec buffering thread */ 55#define PRIORITY_BUFFERING 15 /* Codec buffering thread */
55#define PRIORITY_USER_INTERFACE 16 /* The main thread */ 56#define PRIORITY_USER_INTERFACE 16 /* For most UI thrads */
56#define PRIORITY_RECORDING 16 /* Recording thread */ 57#define PRIORITY_RECORDING 16 /* Recording thread */
57#define PRIORITY_PLAYBACK 16 /* Variable between this and MAX */ 58#define PRIORITY_PLAYBACK 16 /* Variable between this and MAX */
58#define PRIORITY_PLAYBACK_MAX 5 /* Maximum allowable playback priority */ 59#define PRIORITY_PLAYBACK_MAX 5 /* Maximum allowable playback priority */
@@ -61,6 +62,7 @@
61#define NUM_PRIORITIES 32 62#define NUM_PRIORITIES 32
62#define PRIORITY_IDLE 32 /* Priority representative of no tasks */ 63#define PRIORITY_IDLE 32 /* Priority representative of no tasks */
63 64
65#define PRIORITY_MAIN_THREAD PRIORITY_USER_INTERFACE
64#define IO_PRIORITY_IMMEDIATE 0 66#define IO_PRIORITY_IMMEDIATE 0
65#define IO_PRIORITY_BACKGROUND 32 67#define IO_PRIORITY_BACKGROUND 32
66 68
@@ -108,6 +110,9 @@ extern unsigned sleep(unsigned ticks);
108#define IFN_PRIO(...) __VA_ARGS__ 110#define IFN_PRIO(...) __VA_ARGS__
109#endif 111#endif
110 112
113#define __wait_queue lld_head
114#define __wait_queue_node lld_node
115
111/* Basic structure describing the owner of an object */ 116/* Basic structure describing the owner of an object */
112struct blocker 117struct blocker
113{ 118{
@@ -168,6 +173,7 @@ int thread_get_priority(unsigned int thread_id);
168void thread_set_io_priority(unsigned int thread_id, int io_priority); 173void thread_set_io_priority(unsigned int thread_id, int io_priority);
169int thread_get_io_priority(unsigned int thread_id); 174int thread_get_io_priority(unsigned int thread_id);
170#endif /* HAVE_IO_PRIORITY */ 175#endif /* HAVE_IO_PRIORITY */
176
171#if NUM_CORES > 1 177#if NUM_CORES > 1
172unsigned int switch_core(unsigned int new_core); 178unsigned int switch_core(unsigned int new_core);
173#endif 179#endif
@@ -186,11 +192,21 @@ int core_get_debug_info(unsigned int core, struct core_debug_info *infop);
186 192
187#endif /* NUM_CORES */ 193#endif /* NUM_CORES */
188 194
195#ifdef HAVE_SDL_THREADS
196#define IF_SDL(x...) x
197#define IFN_SDL(x...)
198#else
199#define IF_SDL(x...)
200#define IFN_SDL(x...) x
201#endif
202
189struct thread_debug_info 203struct thread_debug_info
190{ 204{
191 char statusstr[4]; 205 char statusstr[4];
192 char name[32]; 206 char name[32];
207#ifndef HAVE_SDL_THREADS
193 unsigned int stack_usage; 208 unsigned int stack_usage;
209#endif
194#if NUM_CORES > 1 210#if NUM_CORES > 1
195 unsigned int core; 211 unsigned int core;
196#endif 212#endif