diff TaskManager/kernel/schedule/SchedTask.cc @ 483:0b933bef0328

renew task worked. but not test_nogl...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 05 Oct 2009 20:29:28 +0900
parents bd5b93d39597
children 9d225ba0c34f
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTask.cc	Mon Oct 05 16:52:45 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Mon Oct 05 20:29:28 2009 +0900
@@ -39,17 +39,17 @@
 
 SchedTask::SchedTask()
 {
-    __list        = NULL;
-    __task        = NULL;
-    __inListData  = NULL;
-    __outListData = NULL;
-    __readbuf     = NULL;
-    __writebuf    = NULL;
-    __scheduler   = NULL;
-    __taskGroup   = NULL;
-    __renew_flag  = 0;
-    __cur_index   = 0;
-    __flag_renewTask = SCHED_TASK_NORMAL;
+    list        = NULL;
+    task        = NULL;
+    inListData  = NULL;
+    outListData = NULL;
+    readbuf     = NULL;
+    writebuf    = NULL;
+    scheduler   = NULL;
+    taskGroup   = NULL;
+    renew_flag  = 0;
+    cur_index   = 0;
+    flag_renewTask = SCHED_TASK_NORMAL;
     this->stdout_ = stdout;
     this->stderr_ = stderr;
     this->stdin_ = stdin;
@@ -65,25 +65,25 @@
 /**
  * dma_store の wait を行う
  * このタスクが RenewTask だった場合、
- * __inListData や __outListData は
+ * inListData や outListData は
  * Scheduler の持つ、使い回しの buffer ではなく
  * 新たに allocate されたものなので、ここで free する
  */
 SchedTask::~SchedTask()
 {
-    if (__flag_renewTask == SCHED_TASK_RENEW) {
-        free(__inListData);
-        free(__outListData);
+    if (flag_renewTask == SCHED_TASK_RENEW) {
+        free(inListData);
+        free(outListData);
 
         /**
-         * __list != NULL の場合、
-         * この Task が __list の最後の Task になるので (SchedTask::next 参照)
-         * このタイミングで __list を解放する
+         * list != NULL の場合、
+         * この Task が list の最後の Task になるので (SchedTask::next 参照)
+         * このタイミングで list を解放する
          *   (free に渡されるアドレスが正しいものとなる)。
          * それ以外の Task では当然解放しない。
-         *  __list == NULL なので、free に渡しても無問題
+         *  list == NULL なので、free に渡しても無問題
          */
-        free(__list);
+        free(list);
     }
 
 
@@ -93,9 +93,9 @@
  * このタスクを Renew Task とし、それに応じた関数をセットする
  */
 void
-SchedTask::__setRenew()
+SchedTask::setRenew()
 {
-    __flag_renewTask = SCHED_TASK_RENEW;
+    flag_renewTask = SCHED_TASK_RENEW;
 
     ex_init   = &SchedTask::ex_init_renew;
     ex_read   = &SchedTask::ex_read_renew;
@@ -105,17 +105,17 @@
 }
 
 void
-SchedTask::__init__(TaskListPtr _list, TaskPtr _task, int index,
+SchedTask::init(TaskListPtr _list, TaskPtr _task, int index,
                     ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc)
 {
-    __list        = _list;
-    __task        = _task;
-    __inListData  = rbuf;
-    __outListData = wbuf;
-    __scheduler   = sc;
-    __cur_index   = index;
+    list        = _list;
+    task        = _task;
+    inListData  = rbuf;
+    outListData = wbuf;
+    scheduler   = sc;
+    cur_index   = index;
 
-    __scheduler->mainMem_wait();
+    scheduler->mainMem_wait();
 
     (this->*ex_init)();
 }
@@ -126,17 +126,17 @@
 void
 SchedTask::ex_init_normal()
 {
-    __scheduler->dma_load(__inListData, (uint32)__task->inData,
+    scheduler->dma_load(inListData, (uint32)task->inData,
                           sizeof(ListData), DMA_READ_IN_LIST);
-    __scheduler->dma_load(__outListData, (uint32)__task->outData,
+    scheduler->dma_load(outListData, (uint32)task->outData,
                           sizeof(ListData), DMA_READ_OUT_LIST);
 #if defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ_IN_LIST);
-    __scheduler->dma_wait(DMA_READ_OUT_LIST);
+    scheduler->dma_wait(DMA_READ_IN_LIST);
+    scheduler->dma_wait(DMA_READ_OUT_LIST);
 #endif
 
-    __taskGroup = new TaskGroup;
-    __taskGroup->command = __task->self;
+    taskGroup = new TaskGroup;
+    taskGroup->command = task->self;
 }
 
 /**
@@ -147,9 +147,9 @@
 void
 SchedTask::ex_init_renew()
 {
-    __inListData = __task->inData;
-    __outListData = __task->outData;
-    __taskGroup = (TaskGroupPtr)__task->self;
+    inListData = task->inData;
+    outListData = task->outData;
+    taskGroup = (TaskGroupPtr)task->self;
 }
 
 /**
@@ -167,21 +167,21 @@
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
 #if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ_IN_LIST);
-    __scheduler->dma_wait(DMA_READ_OUT_LIST);
+    scheduler->dma_wait(DMA_READ_IN_LIST);
+    scheduler->dma_wait(DMA_READ_OUT_LIST);
 #endif
 
-    __writebuf = __scheduler->allocate(__outListData->size);
+    writebuf = scheduler->allocate(outListData->size);
 
     // 読むデータが一つもなければ無視
-    if (__inListData->length == 0) return;
+    if (inListData->length == 0) return;
 
     // load Input Data
-    __readbuf = __scheduler->allocate(__inListData->size);
-    __scheduler->dma_loadList(__inListData, __readbuf, DMA_READ);
+    readbuf = scheduler->allocate(inListData->size);
+    scheduler->dma_loadList(inListData, readbuf, DMA_READ);
 
 #if defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ);
+    scheduler->dma_wait(DMA_READ);
 #endif
 
     (this->*ex_read)();
@@ -193,28 +193,28 @@
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
 #if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_READ);
-    task_list[__task->command].wait(__scheduler,__task->command);
+    scheduler->dma_wait(DMA_READ);
+    task_list[task->command].wait(scheduler,task->command);
 #endif
 
-    task_list[__task->command].run(this, __readbuf, __writebuf);
+    task_list[task->command].run(this, readbuf, writebuf);
 
-    free(__readbuf);
+    free(readbuf);
 
-    if (__taskGroup->status() != 0) {
-        __task->self = __taskGroup->command;
-        delete __taskGroup;
-        __taskGroup = NULL;
+    if (taskGroup->status() != 0) {
+        task->self = taskGroup->command;
+        delete taskGroup;
+        taskGroup = NULL;
     }
 
 
     // 書き込む領域がなければ無視
-    if (__outListData->length > 0) {
-        __scheduler->dma_storeList(__outListData, __writebuf, DMA_WRITE);
+    if (outListData->length > 0) {
+        scheduler->dma_storeList(outListData, writebuf, DMA_WRITE);
 
 #if defined(NO_PIPELINE)
-        __scheduler->dma_wait(DMA_WRITE);
-        free(__writebuf);
+        scheduler->dma_wait(DMA_WRITE);
+        free(writebuf);
 #endif
     }
 
@@ -227,11 +227,11 @@
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
 #if !defined(NO_PIPELINE)
-    __scheduler->dma_wait(DMA_WRITE);
-    free(__writebuf);
+    scheduler->dma_wait(DMA_WRITE);
+    free(writebuf);
 #endif
 
-    if (__task->self == MY_SPE_NOP) return;
+    if (task->self == MY_SPE_NOP) return;
 
     (this->*ex_write)();
 }
@@ -284,8 +284,8 @@
      * このタスク内で新たにタスクが生成されなかった
      * or 生成されたが、そのタスクの終了を待つ必要は無い
      */
-    if (__renew_flag == 0) {
-        __scheduler->mail_write(__task->self);
+    if (renew_flag == 0) {
+        scheduler->mail_write(task->self);
     }
 }
 
@@ -306,13 +306,13 @@
 {
     uint32 cmd;
 
-    __taskGroup->remove(__task);
-    cmd = __taskGroup->status();
+    taskGroup->remove(task);
+    cmd = taskGroup->status();
 
     // タスク内で作られた全てのタスクが終了した
     if (cmd != 0) {
-        delete __taskGroup;
-        __scheduler->mail_write(cmd);
+        delete taskGroup;
+        scheduler->mail_write(cmd);
     }
 }
 
@@ -329,36 +329,36 @@
 SchedTaskBase*
 SchedTask::ex_next_normal()
 {
-    if (__cur_index < __list->length) {
+    if (cur_index < list->length) {
         SchedTaskBase *nextSched;
 
-        nextSched = __scheduler->get_nextRenewTaskList();
+        nextSched = scheduler->get_nextRenewTaskList();
 
         // RenewTask がある
         if (nextSched) {
-            __scheduler->set_backupTaskList(__list);
-            __scheduler->set_backupTaskListIndex(__cur_index);
+            scheduler->set_backupTaskList(list);
+            scheduler->set_backupTaskListIndex(cur_index);
             return nextSched;
         } else {
-            TaskPtr nextTask = &__list->tasks[__cur_index++];
-	    if (__cur_index < __list->length) {
+            TaskPtr nextTask = &list->tasks[cur_index++];
+	    if (cur_index < list->length) {
 		// load next task
-		loadSchedTask(__scheduler, &__list->tasks[__cur_index]);
+		loadSchedTask(scheduler, &list->tasks[cur_index]);
 	    }
-            nextSched = createSchedTask(__scheduler, nextTask);
-            ((SchedTask*)nextSched)->__init__(__list, nextTask, __cur_index,
-                                              __scheduler->get_curReadBuf(),
-                                              __scheduler->get_curWriteBuf(),
-                                              __scheduler);
+            nextSched = createSchedTask(scheduler, nextTask);
+            ((SchedTask*)nextSched)->init(list, nextTask, cur_index,
+                                              scheduler->get_curReadBuf(),
+                                              scheduler->get_curWriteBuf(),
+                                              scheduler);
             return nextSched;
         }
     } else {
-        uint32 nextList = (uint32)__list->next;
+        uint32 nextList = (uint32)list->next;
 
         if (nextList == 0) {
-            return new SchedNop2Ready(__scheduler);
+            return new SchedNop2Ready(scheduler);
         } else {
-            return createSchedTaskList(nextList, __scheduler,
+            return createSchedTaskList(nextList, scheduler,
                                        SCHED_TASKLIST_NORMAL);
         }
     }
@@ -373,54 +373,54 @@
     TaskPtr nextTask;
     SchedTask *nextSched;
 
-    if (__cur_index < __list->length) {
-        nextTask = &__list->tasks[__cur_index++];
-	if (__cur_index < __list->length) {
+    if (cur_index < list->length) {
+        nextTask = &list->tasks[cur_index++];
+	if (cur_index < list->length) {
 	    // load next task
-	    loadSchedTask(__scheduler, &__list->tasks[__cur_index]);
+	    loadSchedTask(scheduler, &list->tasks[cur_index]);
 	}
-        nextSched = createSchedTask(__scheduler, nextTask);
+        nextSched = createSchedTask(scheduler, nextTask);
 
         // RenewTaskList を実行中なので
-        nextSched->__setRenew();
-        nextSched->__init__(__list, nextTask, __cur_index,
-                            __scheduler->get_curReadBuf(),
-                            __scheduler->get_curWriteBuf(),
-                            __scheduler);
+        nextSched->setRenew();
+        nextSched->init(list, nextTask, cur_index,
+                            scheduler->get_curReadBuf(),
+                            scheduler->get_curWriteBuf(),
+                            scheduler);
 
         /**
          * この理由は SchedTask:~SchedTask() で
          */
-        __list = NULL;
+        list = NULL;
         return nextSched;
     } else {
         SchedTaskBase *nextList;
 
-        nextList = __scheduler->get_nextRenewTaskList();
+        nextList = scheduler->get_nextRenewTaskList();
 
         if (nextList) {
             return nextList;
         } else {
-            TaskListPtr nextList = __scheduler->get_backupTaskList();
+            TaskListPtr nextList = scheduler->get_backupTaskList();
 
             // 中断した TaskList がある
             if (nextList) {
-                __cur_index = __scheduler->get_backupTaskListIndex();
+                cur_index = scheduler->get_backupTaskListIndex();
 
-                nextTask = &nextList->tasks[__cur_index++];
-		if (__cur_index < __list->length) {
+                nextTask = &nextList->tasks[cur_index++];
+		if (cur_index < list->length) {
 		    // load next task
-		    loadSchedTask(__scheduler, &__list->tasks[__cur_index]);
+		    loadSchedTask(scheduler, &list->tasks[cur_index]);
 		}
-                nextSched = createSchedTask(__scheduler, nextTask);
+                nextSched = createSchedTask(scheduler, nextTask);
 
-                nextSched->__init__(nextList, nextTask, __cur_index,
-                                    __scheduler->get_curReadBuf(),
-                                    __scheduler->get_curWriteBuf(),
-                                    __scheduler);
+                nextSched->init(nextList, nextTask, cur_index,
+                                    scheduler->get_curReadBuf(),
+                                    scheduler->get_curWriteBuf(),
+                                    scheduler);
                 return nextSched;
             } else {
-                return new SchedNop2Ready(__scheduler);
+                return new SchedNop2Ready(scheduler);
             }
         }
     }
@@ -429,7 +429,7 @@
 int
 SchedTask::get_cpuid()
 {
-    return __scheduler->id;
+    return scheduler->id;
 }
 
 /**
@@ -440,7 +440,7 @@
 SchedTask::get_input(void *buff, int index)
 {
     if (buff != NULL) {
-        return (void*)((int)buff + __inListData->bound[index]);
+        return (void*)((int)buff + inListData->bound[index]);
     } else {
         return NULL;
     }
@@ -452,7 +452,7 @@
 uint32
 SchedTask::get_inputAddr(int index)
 {
-    return __inListData->element[index].addr;
+    return inListData->element[index].addr;
 }
 
 /**
@@ -461,7 +461,7 @@
 int
 SchedTask::get_inputSize(int index)
 {
-    return __inListData->element[index].size;
+    return inListData->element[index].size;
 }
 
 /**
@@ -471,7 +471,7 @@
 SchedTask::get_output(void *buff, int index)
 {
     if (buff != NULL) {
-        return (void*)((int)buff + __outListData->bound[index]);
+        return (void*)((int)buff + outListData->bound[index]);
     } else {
         return NULL;
     }
@@ -483,7 +483,7 @@
 uint32
 SchedTask::get_outputAddr(int index)
 {
-    return __outListData->element[index].addr;
+    return outListData->element[index].addr;
 }
 
 /**
@@ -492,24 +492,24 @@
 int
 SchedTask::get_outputSize(int index)
 {
-    return __outListData->element[index].size;
+    return outListData->element[index].size;
 }
 
 int
 SchedTask::get_param(int index)
 {
-    return __task->param[index];
+    return task->param[index];
 }
 
 TaskPtr
 SchedTask::create_task(int cmd)
 {
-    TaskListPtr taskList = __scheduler->get_renewListBuf();
+    TaskListPtr taskList = scheduler->get_renewListBuf();
     TaskPtr p = &taskList->tasks[taskList->length++];
     p->command = cmd;
 
-    p->inData = (ListData*)__scheduler->allocate(sizeof(ListData));
-    p->outData = (ListData*)__scheduler->allocate(sizeof(ListData));
+    p->inData = (ListData*)scheduler->allocate(sizeof(ListData));
+    p->outData = (ListData*)scheduler->allocate(sizeof(ListData));
 
     p->inData->clear();
     p->outData->clear();
@@ -521,97 +521,95 @@
 }
 
 /**
- * 生成したタスクが終了してから、メインスケジューラ(PPE) に
- * タスクが終了した旨を知らせる。
  *
- * @param[in] waitTask タスク内で生成したタスク
+ * @param[in] waitTask タスク内で生成したタスクの登録(spawn()に相当)
  */
 void
 SchedTask::wait_task(TaskPtr waitTask)
 {
-    waitTask->self = (uint32)__taskGroup;
+    waitTask->self = (uint32)taskGroup;
 
-    __scheduler->add_groupTask(__taskGroup, waitTask);
+    scheduler->add_groupTask(taskGroup, waitTask);
 
-    __renew_flag++;
+    renew_flag++;
 }
 
 void*
 SchedTask::global_alloc(int id, int size) {
-    return __scheduler->global_alloc(id, size);
+    return scheduler->global_alloc(id, size);
 }
 
 void*
 SchedTask::global_get(int id) {
-    return __scheduler->global_get(id);
+    return scheduler->global_get(id);
 }
 
 void
 SchedTask::global_set(int id, void *addr) {
-    __scheduler->global_set(id, addr);
+    scheduler->global_set(id, addr);
 }
 
 void
 SchedTask::global_free(int id) {
-    __scheduler->global_free(id);
+    scheduler->global_free(id);
 }
 
 MemList*
 SchedTask::createMemList(int size, int count) {
-    return __scheduler->createMemList(size, count);
+    return scheduler->createMemList(size, count);
 }
 
 void
 SchedTask::mainMem_alloc(int id, int size) {
-    __scheduler->mainMem_alloc(id, size);
+    scheduler->mainMem_alloc(id, size);
 }
 
 void
 SchedTask::mainMem_wait() {
-    __scheduler->mainMem_wait();
+    scheduler->mainMem_wait();
 }
 
 void*
 SchedTask::mainMem_get(int id) {
-    return __scheduler->mainMem_get(id);
+    return scheduler->mainMem_get(id);
 }
 
 void*
 SchedTask::allocate(int size) {
-    return __scheduler->allocate(size);
+    return scheduler->allocate(size);
 }
 
 
 void
 SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {
-    __scheduler->dma_load(buf, addr, size, mask);
+    scheduler->dma_load(buf, addr, size, mask);
 }
 
 void
 SchedTask::dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {
-    __scheduler->dma_store(buf, addr, size, mask);
+    scheduler->dma_store(buf, addr, size, mask);
 }
 
 void
 SchedTask::dma_wait(uint32 mask) {
-    __scheduler->dma_wait(mask);
+    scheduler->dma_wait(mask);
 }
 
 void
 SchedTask::show_dma_wait() {
-    __scheduler->show_dma_wait();
+    scheduler->show_dma_wait();
 }
 
 MemorySegment * SchedTask::get_segment(memaddr addr, MemList *m) {
-    return __scheduler->get_segment(addr,m);
+    return scheduler->get_segment(addr,m);
 }
 
 void SchedTask::put_segment(MemorySegment *s) {
-    __scheduler->put_segment(s);
+    scheduler->put_segment(s);
 }
 
 void SchedTask::wait_segment(MemorySegment *s) {
-    __scheduler->wait_segment(s);
+    scheduler->wait_segment(s);
 }
 
 /* system call */