summaryrefslogtreecommitdiff
path: root/firmware/thread.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-03-05 17:48:06 +0000
committerThomas Martitz <kugel@rockbox.org>2011-03-05 17:48:06 +0000
commitcc889e9d608e6b07b78541849b7e63b6fb3f6058 (patch)
treeea01a47602b68561d294f705e8ab7669fb00ae9a /firmware/thread.c
parent0b0f99b18ebe6305c9cab12bf8b36d154fc9c87f (diff)
downloadrockbox-cc889e9d608e6b07b78541849b7e63b6fb3f6058.zip
rockbox-cc889e9d608e6b07b78541849b7e63b6fb3f6058.tar.gz
rockbox-cc889e9d608e6b07b78541849b7e63b6fb3f6058.tar.bz2
rockbox-cc889e9d608e6b07b78541849b7e63b6fb3f6058.tar.xz
Change the thread api a bit.
* Remove THREAD_ID_CURRENT macro in favor of a thread_self() function, this allows thread functions to be simpler. * thread_self_entry() shortcut for kernel.c. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29521 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/thread.c')
-rw-r--r--firmware/thread.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index ea73150..cfedbbe 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -1517,9 +1517,27 @@ static struct thread_entry * find_empty_thread_slot(void)
*/
struct thread_entry * thread_id_entry(unsigned int thread_id)
{
- return (thread_id == THREAD_ID_CURRENT) ?
- cores[CURRENT_CORE].running :
- &threads[thread_id & THREAD_ID_SLOT_MASK];
+ return &threads[thread_id & THREAD_ID_SLOT_MASK];
+}
+
+/*---------------------------------------------------------------------------
+ * Return the thread id of the calling thread
+ * --------------------------------------------------------------------------
+ */
+unsigned int thread_self(void)
+{
+ return cores[CURRENT_CORE].running->id;
+}
+
+/*---------------------------------------------------------------------------
+ * Return the thread entry of the calling thread.
+ *
+ * INTERNAL: Intended for use by kernel and not for programs.
+ *---------------------------------------------------------------------------
+ */
+struct thread_entry* thread_self_entry(void)
+{
+ return cores[CURRENT_CORE].running;
}
/*---------------------------------------------------------------------------
@@ -1675,8 +1693,7 @@ void thread_wait(unsigned int thread_id)
corelock_lock(&thread->waiter_cl);
/* Be sure it hasn't been killed yet */
- if (thread_id == THREAD_ID_CURRENT ||
- (thread->id == thread_id && thread->state != STATE_KILLED))
+ if (thread->id == thread_id && thread->state != STATE_KILLED)
{
IF_COP( current->obj_cl = &thread->waiter_cl; )
current->bqp = &thread->queue;
@@ -1973,8 +1990,7 @@ int thread_set_priority(unsigned int thread_id, int priority)
LOCK_THREAD(thread);
/* Make sure it's not killed */
- if (thread_id == THREAD_ID_CURRENT ||
- (thread->id == thread_id && thread->state != STATE_KILLED))
+ if (thread->id == thread_id && thread->state != STATE_KILLED)
{
int old_priority = thread->priority;
@@ -2099,8 +2115,7 @@ int thread_get_priority(unsigned int thread_id)
/* Simply check without locking slot. It may or may not be valid by the
* time the function returns anyway. If all tests pass, it is the
* correct value for when it was valid. */
- if (thread_id != THREAD_ID_CURRENT &&
- (thread->id != thread_id || thread->state == STATE_KILLED))
+ if (thread->id != thread_id || thread->state == STATE_KILLED)
base_priority = -1;
return base_priority;
@@ -2143,15 +2158,6 @@ void thread_thaw(unsigned int thread_id)
restore_irq(oldlevel);
}
-/*---------------------------------------------------------------------------
- * Return the ID of the currently executing thread.
- *---------------------------------------------------------------------------
- */
-unsigned int thread_get_current(void)
-{
- return cores[CURRENT_CORE].running->id;
-}
-
#if NUM_CORES > 1
/*---------------------------------------------------------------------------
* Switch the processor that the currently executing thread runs on.