From 6ed00870abd566d7267d2436c2693f5a281cda2f Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 8 Aug 2014 06:33:51 -0400 Subject: 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 --- firmware/kernel/include/thread.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'firmware/kernel/include/thread.h') 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 @@ #include #include "config.h" #include "gcc_extensions.h" +#include "linked_list.h" #include "bitarray.h" #include "corelock.h" @@ -52,7 +53,7 @@ #define PRIORITY_REALTIME_4 4 #define PRIORITY_REALTIME 4 /* Lowest realtime range */ #define PRIORITY_BUFFERING 15 /* Codec buffering thread */ -#define PRIORITY_USER_INTERFACE 16 /* The main thread */ +#define PRIORITY_USER_INTERFACE 16 /* For most UI thrads */ #define PRIORITY_RECORDING 16 /* Recording thread */ #define PRIORITY_PLAYBACK 16 /* Variable between this and MAX */ #define PRIORITY_PLAYBACK_MAX 5 /* Maximum allowable playback priority */ @@ -61,6 +62,7 @@ #define NUM_PRIORITIES 32 #define PRIORITY_IDLE 32 /* Priority representative of no tasks */ +#define PRIORITY_MAIN_THREAD PRIORITY_USER_INTERFACE #define IO_PRIORITY_IMMEDIATE 0 #define IO_PRIORITY_BACKGROUND 32 @@ -108,6 +110,9 @@ extern unsigned sleep(unsigned ticks); #define IFN_PRIO(...) __VA_ARGS__ #endif +#define __wait_queue lld_head +#define __wait_queue_node lld_node + /* Basic structure describing the owner of an object */ struct blocker { @@ -168,6 +173,7 @@ int thread_get_priority(unsigned int thread_id); void thread_set_io_priority(unsigned int thread_id, int io_priority); int thread_get_io_priority(unsigned int thread_id); #endif /* HAVE_IO_PRIORITY */ + #if NUM_CORES > 1 unsigned int switch_core(unsigned int new_core); #endif @@ -186,11 +192,21 @@ int core_get_debug_info(unsigned int core, struct core_debug_info *infop); #endif /* NUM_CORES */ +#ifdef HAVE_SDL_THREADS +#define IF_SDL(x...) x +#define IFN_SDL(x...) +#else +#define IF_SDL(x...) +#define IFN_SDL(x...) x +#endif + struct thread_debug_info { char statusstr[4]; char name[32]; +#ifndef HAVE_SDL_THREADS unsigned int stack_usage; +#endif #if NUM_CORES > 1 unsigned int core; #endif -- cgit v1.2.3