diff options
author | Yuji Mano <yuji.mano@am.sony.com> | 2009-03-13 18:19:06 -0700 |
---|---|---|
committer | Yuji Mano <yuji.mano@am.sony.com> | 2009-03-17 11:11:06 -0700 |
commit | f59348bb11dbd182030e0b934867dee5a601e0d8 (patch) | |
tree | abe2fb2c8e0492fda6d48e9ee41aca0966b20161 | |
parent | b8aa5902e3a75e63816a877abbf295e92b52e857 (diff) | |
download | mars-src-f59348bb11dbd182030e0b934867dee5a601e0d8.tar.gz |
task: Optimize context switch
This patch optimizes the task context switch by only loading the task elf's
text segment only if it's not cached in MPU storage. Also the text segment is no
longer saved during a context switch as it is readonly and does not change.
Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>
Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>
-rw-r--r-- | task/src/mpu/module/task_module.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/task/src/mpu/module/task_module.c b/task/src/mpu/module/task_module.c index ced5b5c..0a4409a 100644 --- a/task/src/mpu/module/task_module.c +++ b/task/src/mpu/module/task_module.c @@ -96,8 +96,8 @@ static void dma(void *ls, uint64_t ea, int size, int put) static void dma_context(uint32_t low_size, uint32_t high_size, int put) { - /* save or restore text and heap (low address) */ - dma((void *)MARS_TASK_BASE_ADDR, task->context_save_area_ea, + /* save or restore data segment and heap (low address) */ + dma((void *)task->data_vaddr, task->context_save_area_ea, low_size, put); /* save or restore stack (high address) */ @@ -229,7 +229,7 @@ static void __attribute__((noinline)) context_save(void *task_heap) /* save context MPU storage state */ task->context_save_area_low_size = ((uintptr_t)task_heap - - MARS_TASK_BASE_ADDR + MARS_TASK_MODULE_DMA_SIZE_MASK) & + task->data_vaddr + MARS_TASK_MODULE_DMA_SIZE_MASK) & ~MARS_TASK_MODULE_DMA_SIZE_MASK; task->context_save_area_high_size = @@ -416,15 +416,10 @@ static struct mars_task_module_syscalls task_module_syscalls = mars_module_dma_wait }; -static void context_start(int task_cached) +static void context_start(void) { __vector unsigned char *bss_ptr, *bss_end; - /* only reload the readonly text segment if different from cached */ - if (!task_cached) - dma((void *)task->text_vaddr, - task->text_ea, task->text_size, 0); - /* load the read-write data segment */ dma((void *)task->data_vaddr, task->data_ea, task->data_size, 0); @@ -461,9 +456,14 @@ void mars_module_main(void) task_cached = mars_module_workload_query(mars_module_get_workload_id(), MARS_QUERY_IS_CACHED); + /* only reload the readonly text segment if different from cached */ + if (!task_cached) + dma((void *)MARS_TASK_BASE_ADDR, + task->text_ea, task->text_size, 0); + /* if stack pointer is uninitialized run fresh, otherwise resume */ if (!task->stack) - context_start(task_cached); + context_start(); else context_resume(task_cached); |