changeset 1062:f994f5032299 draft

add TaskManagerImpl::get_task_name()
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Thu, 16 Dec 2010 22:35:25 +0900
parents ca73615ab585
children dbd083c00be4
files TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/schedule/Scheduler.cc TaskManager/kernel/schedule/Scheduler.h
diffstat 4 files changed, 62 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Wed Dec 15 18:18:36 2010 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Thu Dec 16 22:35:25 2010 +0900
@@ -118,6 +118,57 @@
     return ta;
 }
 
+/* call get_task_name from ppu only */
+const char *
+TaskManagerImpl::get_task_name(int cmd) {
+	if (0 <= cmd && cmd < MAX_TASK_OBJECT)
+		return task_list[cmd].name;
+	else
+		return NULL;
+}
+const char *
+TaskManagerImpl::get_task_name(TaskPtr task) {
+	return task != NULL ? get_task_name(task->command) : NULL;
+}
+const char *
+TaskManagerImpl::get_task_name(SimpleTaskPtr simple_task) {
+	return simple_task != NULL ? get_task_name(simple_task->command) : NULL;
+}
+const char *
+TaskManagerImpl::get_task_name(SchedTaskBase *sched_task) {
+	if (sched_task == NULL) return NULL;
+	if (sched_task->task != NULL) {
+		return get_task_name(sched_task->task->command);
+	} else if (sched_task->atask != NULL) {
+		return get_task_name(sched_task->atask->command);
+	}
+	return NULL;
+}
+const char *
+TaskManagerImpl::get_task_name(HTaskPtr htask) {
+	return get_task_name(htask, 0);
+}
+const char *
+TaskManagerImpl::get_task_name(HTaskPtr htask, int index) {
+	if (!htask)	return NULL;
+	switch (htask->command) {
+	case TaskArray1:
+		return get_task_name((TaskPtr)htask->rbuf);
+		break;
+	case TaskArray:
+		HTaskPtr t = htask->next;
+		for (int i = 0; i < index; i++) {
+			if (!t->next) return NULL;
+			t = t->next;
+		}
+		return get_task_name(t->command);
+		break;
+	default:
+		return get_task_name(htask->command);
+	}
+	return NULL;
+}
+
 /**
  * task の依存関係を設定
  * master task が終わってから、slave task を実行するように
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h	Wed Dec 15 18:18:36 2010 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.h	Thu Dec 16 22:35:25 2010 +0900
@@ -54,10 +54,16 @@
     virtual HTaskPtr create_task(int cmd,void *from);
     virtual HTaskPtr create_task(int cmd, memaddr rbuf, long r_size, memaddr wbuf, long w_size,void *from);
     virtual HTaskPtr create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData,void *from);
+	const char *TaskManagerImpl::get_task_name(int cmd);
+	const char *TaskManagerImpl::get_task_name(TaskPtr task);
+	const char *TaskManagerImpl::get_task_name(SimpleTaskPtr simpletask);
+	const char *TaskManagerImpl::get_task_name(SchedTaskBase *schedtask);
+	const char *TaskManagerImpl::get_task_name(HTaskPtr htask);
+	const char *TaskManagerImpl::get_task_name(HTaskPtr htask, int index);
     virtual void set_task_depend(HTaskPtr master, HTaskPtr slave);
     virtual void spawn_task(HTaskPtr);
     virtual void set_task_cpu(HTaskPtr, CPU_TYPE);
-    void set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) ; 
+    void set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList);
 
     void free_htask(HTaskPtr htask) {
 #if !defined(__SPU__)
--- a/TaskManager/kernel/schedule/Scheduler.cc	Wed Dec 15 18:18:36 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Thu Dec 16 22:35:25 2010 +0900
@@ -15,7 +15,6 @@
  */
 
 TaskObject task_list[MAX_TASK_OBJECT];
-const char *task_name_list[MAX_TASK_OBJECT];
 
 Scheduler::~Scheduler()
 {
@@ -302,7 +301,7 @@
     task_list[cmd].run = run;
     task_list[cmd].load = null_loader;
     task_list[cmd].wait = null_waiter;
-	task_name_list[cmd] = str;
+	task_list[cmd].name = str;
 }
 
 extern void 
@@ -318,7 +317,7 @@
     task_list[cmd].entry_offset = entry_offset;
     task_list[cmd].load = load_task;
     task_list[cmd].wait = wait_load;
-	task_name_list[cmd] = str;
+	task_list[cmd].name = str;
 #if 0
 this->printf("cmd        = %d\n",cmd);
 this->printf("locatation = 0x%x\n",start);
--- a/TaskManager/kernel/schedule/Scheduler.h	Wed Dec 15 18:18:36 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.h	Thu Dec 16 22:35:25 2010 +0900
@@ -37,6 +37,7 @@
     memaddr end;            
     uint32 entry_offset;        // offset for create();
     MemorySegment *segment;
+	const char *name;
     void (*load)(Scheduler *,int);
     void (*wait)(Scheduler *,int);
 }  __attribute__ ((aligned (DEFAULT_ALIGNMENT)))
@@ -148,7 +149,7 @@
 extern void register_task(int cmd, TaskObjectRun run, const char *str);
 extern void register_dynamic_task(int cmd, 
     memaddr start, int size, TaskObjectRun run,
-								  int entry_offset,
+	int entry_offset,
 	const char *str);
 
 struct tbl { 
@@ -159,7 +160,6 @@
 }; 
 
 extern TaskObject task_list[MAX_TASK_OBJECT];
-extern const char *task_name_list[MAX_TASK_OBJECT];
 
 inline void
 loadSchedTask(Scheduler *scheduler,int command)