summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-10-19 11:51:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-10-19 11:51:45 +0000
commitd332601135f75dd4a06c1bc8347f0155dc2867f1 (patch)
tree9a6f609f57de1f0d7daac30b7ffea5fd05938cea /firmware
parent9ec00d7f25f2f6ec0fe43eae0b1749dafde0b32c (diff)
Save a little space and only initialize the minimum for initial threads at startup. The BSS sections should already be zereod and if they're mistakenly not, be sure to crash ASAP. ;)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15204 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/thread.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index 930e149302..db5d6c3d2c 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -2491,6 +2491,7 @@ unsigned int switch_core(unsigned int new_core)
void init_threads(void)
{
const unsigned int core = CURRENT_CORE;
+ struct thread_entry *thread;
int slot;
/* CPU will initialize first and then sleep */
@@ -2503,42 +2504,38 @@ void init_threads(void)
* or threads is in the wrong section. */
THREAD_PANICF("init_threads->no slot", NULL);
}
-
- cores[core].running = NULL;
- cores[core].timeout = NULL;
+
+ /* Initialize initially non-zero members of core */
thread_queue_init(&cores[core].waking);
cores[core].next_tmo_check = current_tick; /* Something not in the past */
-#if NUM_CORES > 1
- cores[core].blk_ops.flags = 0;
-#else
+#if NUM_CORES == 1
cores[core].irq_level = STAY_IRQ_LEVEL;
#endif
- threads[slot].name = main_thread_name;
- UNLOCK_THREAD_SET_STATE(&threads[slot], STATE_RUNNING); /* No sync worries yet */
- threads[slot].context.start = NULL; /* core's main thread already running */
- threads[slot].tmo.prev = NULL;
- threads[slot].queue = NULL;
-#ifdef HAVE_SCHEDULER_BOOSTCTRL
- threads[slot].boosted = 0;
+#ifdef HAVE_PRIORITY_SCHEDULING
+ cores[core].highest_priority = LOWEST_PRIORITY;
#endif
+
+ /* Initialize initially non-zero members of slot */
+ thread = &threads[slot];
+ thread->name = main_thread_name;
+ UNLOCK_THREAD_SET_STATE(thread, STATE_RUNNING); /* No sync worries yet */
#if NUM_CORES > 1
- threads[slot].core = core;
+ thread->core = core;
#endif
#ifdef HAVE_PRIORITY_SCHEDULING
- threads[slot].priority = PRIORITY_USER_INTERFACE;
- threads[slot].priority_x = LOWEST_PRIORITY;
- cores[core].highest_priority = LOWEST_PRIORITY;
+ thread->priority = PRIORITY_USER_INTERFACE;
+ thread->priority_x = LOWEST_PRIORITY;
+#endif
+#if CONFIG_CORELOCK == SW_CORELOCK
+ corelock_init(&thread->cl);
#endif
- add_to_list_l(&cores[core].running, &threads[slot]);
+ add_to_list_l(&cores[core].running, thread);
if (core == CPU)
{
-#ifdef HAVE_SCHEDULER_BOOSTCTRL
- boosted_threads = 0;
-#endif
- threads[slot].stack = stackbegin;
- threads[slot].stack_size = (int)stackend - (int)stackbegin;
+ thread->stack = stackbegin;
+ thread->stack_size = (int)stackend - (int)stackbegin;
#if NUM_CORES > 1 /* This code path will not be run on single core targets */
/* TODO: HAL interface for this */
/* Wake up coprocessor and let it initialize kernel and threads */
@@ -2550,10 +2547,8 @@ void init_threads(void)
else
{
/* Initial stack is the COP idle stack */
- threads[slot].stack = cop_idlestackbegin;
- threads[slot].stack_size = IDLE_STACK_SIZE;
- /* Mark COP initialized */
- cores[COP].blk_ops.flags = 0;
+ thread->stack = cop_idlestackbegin;
+ thread->stack_size = IDLE_STACK_SIZE;
/* Get COP safely primed inside switch_thread where it will remain
* until a thread actually exists on it */
CPU_CTL = PROC_WAKE;