From 8a82892e52127f50efaafaeda3ae841e8bbefe2d Mon Sep 17 00:00:00 2001 From: Brandon Low Date: Sat, 11 Nov 2006 05:33:24 +0000 Subject: Thread API enhancements. 1) block_thread -> block_thread + block_thread_w_tmo -- this call was always used in distinct ways so having one call with a conditional was ugly. 2) enhance Slasheri's scheduler controlled boost concept. now any thread may trigger a boost which will last until that thread next sleeps. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11509 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/thread.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'firmware/export/thread.h') diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 8bb9ae2608..0c1567de97 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -78,14 +78,22 @@ struct regs #endif /* !SIMULATOR */ -#define STATE_RUNNING 0 -#define STATE_BLOCKED 1 -#define STATE_SLEEPING 2 -#define STATE_BLOCKED_W_TMO 3 +#define STATE_RUNNING 0x00000000 +#define STATE_BLOCKED 0x20000000 +#define STATE_SLEEPING 0x40000000 +#define STATE_BLOCKED_W_TMO 0x60000000 -#define GET_STATE_ARG(state) (state & 0x3FFFFFFF) -#define GET_STATE(state) ((state >> 30) & 3) -#define SET_STATE(state,arg) ((state << 30) | (arg)) +#define THREAD_STATE_MASK 0x60000000 +#define STATE_ARG_MASK 0x1FFFFFFF + +#define GET_STATE_ARG(state) (state & STATE_ARG_MASK) +#define GET_STATE(state) (state & THREAD_STATE_MASK) +#define SET_STATE(var,state,arg) (var = (state | ((arg) & STATE_ARG_MASK))) +#define CLEAR_STATE_ARG(var) (var &= ~STATE_ARG_MASK) + +#define STATE_BOOSTED 0x80000000 +#define STATE_IS_BOOSTED(var) (var & STATE_BOOSTED) +#define SET_BOOST_STATE(var) (var |= STATE_BOOSTED) struct thread_entry { #ifndef SIMULATOR @@ -133,7 +141,8 @@ void trigger_cpu_boost(void); void remove_thread(struct thread_entry *thread); void switch_thread(bool save_context, struct thread_entry **blocked_list); void sleep_thread(int ticks); -void block_thread(struct thread_entry **thread, int timeout); +void block_thread(struct thread_entry **thread); +void block_thread_w_tmo(struct thread_entry **thread, int timeout); void wakeup_thread(struct thread_entry **thread); #ifdef HAVE_PRIORITY_SCHEDULING int thread_set_priority(struct thread_entry *thread, int priority); -- cgit v1.2.3