aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuji Mano <yuji.mano@am.sony.com>2009-04-29 11:33:42 -0700
committerYuji Mano <yuji.mano@am.sony.com>2009-04-29 11:33:42 -0700
commit753e0fc72f56577c9f5e80744e2f9661ae993e73 (patch)
treeb98ecb92d24047d00f76f2fa06c439f5ec252995
parent923632c76dafe6d73296ee5bb275b1cb2ad52a6d (diff)
downloadmars-src-753e0fc72f56577c9f5e80744e2f9661ae993e73.tar.gz
base: Kernel cleanup scheduler
This is a minor implementation cleanup to reduce kernel code size by a few bytes. Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>
-rw-r--r--base/src/common/kernel_internal_types.h5
-rw-r--r--base/src/mpu/kernel/kernel.c52
-rw-r--r--samples/grayscale/host.c2
-rw-r--r--samples/grayscale/mpu_task1.c2
4 files changed, 19 insertions, 42 deletions
diff --git a/base/src/common/kernel_internal_types.h b/base/src/common/kernel_internal_types.h
index 3757764..6c8499e 100644
--- a/base/src/common/kernel_internal_types.h
+++ b/base/src/common/kernel_internal_types.h
@@ -47,11 +47,6 @@
#define MARS_KERNEL_ID_NONE 0xffff
-#define MARS_KERNEL_STATUS_EXIT 0x0
-#define MARS_KERNEL_STATUS_IDLE 0x1
-#define MARS_KERNEL_STATUS_BUSY 0x2
-#define MARS_KERNEL_STATUS_RETRY 0x3
-
#define MARS_KERNEL_TICKS_FLAG_SYNC_BEGIN 0x1
#define MARS_KERNEL_TICKS_FLAG_SYNC_END 0x2
diff --git a/base/src/mpu/kernel/kernel.c b/base/src/mpu/kernel/kernel.c
index 4188fc2..6cd4948 100644
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -48,6 +48,11 @@
#include "kernel_internal_types.h"
#include "workload_internal_types.h"
+#define MARS_KERNEL_STATUS_EXIT 0x1
+#define MARS_KERNEL_STATUS_IDLE 0x2
+#define MARS_KERNEL_STATUS_BUSY 0x4
+#define MARS_KERNEL_STATUS_RETRY 0x8
+
/* kernel */
union mars_kernel_buffer kernel_buffer;
static struct mars_kernel_params kernel_params;
@@ -953,26 +958,7 @@ static void workload_module_load(void)
spu_sync();
}
-static int scheduler(void)
-{
- int status = workload_reserve();
-
- /* workload reserved */
- if (status == MARS_KERNEL_STATUS_BUSY) {
- /* load the workload module */
- workload_module_load();
-
- /* run workload */
- workload_run();
-
- /* release reservation of current workload */
- workload_release();
- }
-
- return status;
-}
-
-static void scheduler_idle_wait(void)
+static void idle_wait(void)
{
int mask;
struct mars_workload_queue_header *cur_queue_header =
@@ -1059,27 +1045,23 @@ int main(uint64_t mpu_context_id, uint64_t params_ea)
{
(void)mpu_context_id;
- int exit_flag = 0;
-
kernel_params_ea = params_ea;
get_params();
- while (!exit_flag) {
- int status = scheduler();
-
- switch (status) {
- case MARS_KERNEL_STATUS_EXIT:
- exit_flag = 1;
- break;
- case MARS_KERNEL_STATUS_IDLE:
- scheduler_idle_wait();
- break;
- case MARS_KERNEL_STATUS_BUSY:
- case MARS_KERNEL_STATUS_RETRY:
+ do {
+ int status = workload_reserve();
+
+ if (status & MARS_KERNEL_STATUS_BUSY) {
+ workload_module_load();
+ workload_run();
+ workload_release();
+ } else if (status & MARS_KERNEL_STATUS_IDLE) {
+ idle_wait();
+ } else if (status & MARS_KERNEL_STATUS_EXIT) {
break;
}
- }
+ } while (1);
host_signal_send(MARS_HOST_SIGNAL_EXIT);
diff --git a/samples/grayscale/host.c b/samples/grayscale/host.c
index 269309f..12645db 100644
--- a/samples/grayscale/host.c
+++ b/samples/grayscale/host.c
@@ -52,7 +52,7 @@ event signaling completion, the main task completes execution. \n\
#define OUT_FILENAME "out.ppm"
#define PPM_MAGIC "P6"
-#define NUM_TASKS 4
+#define NUM_TASKS 16
#define QUEUE_DEPTH 4
typedef struct _image_t {
diff --git a/samples/grayscale/mpu_task1.c b/samples/grayscale/mpu_task1.c
index c8b95b9..d28ca88 100644
--- a/samples/grayscale/mpu_task1.c
+++ b/samples/grayscale/mpu_task1.c
@@ -27,7 +27,7 @@
#include <spu_mfcio.h>
#include <mars/task.h>
-#define NUM_TASKS 4
+#define NUM_TASKS 16
#define ALIGN4_UP(x) (((x) + 0x3) & ~0x3)