[Cbe-oss-dev] [PATCH 27/28]MARS/task: cache workload context

Yuji Mano yuji.mano at am.sony.com
Fri Feb 6 13:33:20 EST 2009


This patch queries the kernel to check if the task context state is cached in
MPU storage. If it is cached, then no context restore is necessary when resuming
the task.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 task/include/mpu/mars/task.h      |    4 ++--
 task/src/mpu/lib/task.c           |    2 +-
 task/src/mpu/module/task_module.c |   14 +++++++++++---
 task/src/mpu/module/task_module.h |    4 ++--
 4 files changed, 16 insertions(+), 8 deletions(-)

--- a/task/include/mpu/mars/task.h
+++ b/task/include/mpu/mars/task.h
@@ -248,9 +248,9 @@ uint32_t mars_task_get_ticks(void);
  * will range from 0 to (# of MPUs initiialized for MARS context) - 1.
  *
  * \return
- *	uint32_t			- id of MARS kernel
+ *	uint16_t			- id of MARS kernel
  */
-uint32_t mars_task_get_kernel_id(void);
+uint16_t mars_task_get_kernel_id(void);
 
 /**
  * \ingroup group_mars_task
--- a/task/src/mpu/lib/task.c
+++ b/task/src/mpu/lib/task.c
@@ -165,7 +165,7 @@ uint32_t mars_task_get_ticks(void)
 	return mars_task_module_get_ticks();
 }
 
-uint32_t mars_task_get_kernel_id(void)
+uint16_t mars_task_get_kernel_id(void)
 {
 	return mars_task_module_get_kernel_id();
 }
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -53,8 +53,9 @@
 void *__module_stack;
 void *__task_stack;
 
-/* global task structs */
+/* global task variables */
 static struct mars_task_context *task;
+static int task_cached;
 
 /* task entry */
 typedef void (*mars_task_entry)(struct mars_task_args *args,
@@ -65,7 +66,7 @@ static uint32_t get_ticks(void)
 	return mars_module_get_ticks();
 }
 
-static uint32_t get_kernel_id(void)
+static uint16_t get_kernel_id(void)
 {
 	return mars_module_get_kernel_id();
 }
@@ -280,12 +281,15 @@ static void __attribute__((noinline)) co
 	/* save workload stack pointer */
 	task->stack = (uint32_t)__task_stack;
 
+	/* save context MPU storage state */
 	dma_context(1, task_heap);
 }
 
 static void __attribute__((noinline)) context_restore(void)
 {
-	dma_context(0, NULL);
+	/* if task not cashed restore context MPU storage state */
+	if (!task_cached)
+		dma_context(0, NULL);
 
 	/* restore workload stack pointer */
 	__task_stack = (void *)task->stack;
@@ -508,6 +512,10 @@ void mars_module_main(void)
 	/* get task context */
 	task = get_task();
 
+	/* check if task context is cached in mpu storage */
+	task_cached = mars_module_workload_query(mars_module_get_workload_id(),
+						 MARS_QUERY_IS_CACHED);
+
 	/* if stack pointer is uninitialized run fresh, otherwise resume */
 	if (!task->stack)
 		context_start();
--- a/task/src/mpu/module/task_module.h
+++ b/task/src/mpu/module/task_module.h
@@ -52,7 +52,7 @@
 /* mars task module syscalls */
 struct mars_task_module_syscalls {
 	uint32_t			(*get_ticks)(void);
-	uint32_t			(*get_kernel_id)(void);
+	uint16_t			(*get_kernel_id)(void);
 	struct mars_task_context *	(*get_task)(void);
 	struct mars_task_context *	(*get_task_by_id)
 						(struct mars_task_id *task_id);
@@ -95,7 +95,7 @@ static inline uint32_t mars_task_module_
 	return (*mars_task_module_syscalls->get_ticks)();
 }
 
-static inline uint32_t mars_task_module_get_kernel_id(void)
+static inline uint16_t mars_task_module_get_kernel_id(void)
 {
 	return (*mars_task_module_syscalls->get_kernel_id)();
 }







More information about the cbe-oss-dev mailing list