# HG changeset patch # User Yuhi TOMARI # Date 1416859730 -32400 # Node ID 25849868012857ff5a8a93a69c9f440f33a23ebb # Parent c8e35ceae52b770942efe96f07051fba231deb39 indent-region diff -r c8e35ceae52b -r 258498680128 TaskManager/kernel/ppe/QueueInfo.h --- a/TaskManager/kernel/ppe/QueueInfo.h Sun Nov 16 18:00:06 2014 +0900 +++ b/TaskManager/kernel/ppe/QueueInfo.h Tue Nov 25 05:08:50 2014 +0900 @@ -6,7 +6,7 @@ #if 0 template class Queue : T { -public: + public: T(); @@ -23,22 +23,22 @@ template class QueueInfo : public T { -public: + public: /* constructor */ /** - singleton queuePool constructor - Do not use this as a Queue + singleton queuePool constructor + Do not use this as a Queue */ QueueInfo(){ - queueInfoInit(); + queueInfoInit(); } /** - normal constructor requires + normal constructor requires */ QueueInfo(QueueInfo *p) { - queueInfoInit(); - queuePool = p; + queueInfoInit(); + queuePool = p; } BASE_NEW_DELETE(QueueInfo); @@ -65,7 +65,7 @@ T* getNext(T* q) ; int length(); -private: + private: /* variables */ /* we cannot use static in template */ @@ -107,18 +107,18 @@ templatevoid QueueInfo::freePool() { for(T * p = queuePool->waiter; p; ) { - T * next = p->waiter; - p->waiter = NULL; - p->freeOnce(); - free(p); - p = next; + T * next = p->waiter; + p->waiter = NULL; + p->freeOnce(); + free(p); + p = next; } } /** - all pools are shared among QueueInfo (separated by size and type). - it automatically extended by 64. - */ + all pools are shared among QueueInfo (separated by size and type). + it automatically extended by 64. +*/ templateint QueueInfo::extend_pool(int num) { @@ -157,8 +157,8 @@ { T * q = queuePool->poll(); if (! q) { - queuePool->extend_pool(64); - q = queuePool->poll(); + queuePool->extend_pool(64); + q = queuePool->poll(); } q->init(); return q; @@ -176,11 +176,11 @@ /*! QueueInfo は空にならない。最低1個は要素が入っていて 1個目は特別扱いする。getFirst すると first->next を返す - */ +*/ /*! 最初の1個は特別扱いなので、それの後に追加していく - */ +*/ templatevoid QueueInfo::addFirst(T* e) { @@ -195,9 +195,9 @@ { #ifdef CHECK if (find(e)) { - fprintf(stderr,"Add duplicate task %0x\n",(int)e); - return; - // ... + fprintf(stderr,"Add duplicate task %0x\n",(int)e); + return; + // ... } #endif e->next = first; @@ -225,19 +225,19 @@ { #ifdef CHECK if (!find(e)) { - fprintf(stderr,"Remove non existing task %0x\n",(int)e); - return 0; - // ... + fprintf(stderr,"Remove non existing task %0x\n",(int)e); + return 0; + // ... } #endif e->prev->next = e->next; e->next->prev = e->prev; if (first->next == e) { - first->next = e->next; + first->next = e->next; } if (last == e) { - last = e->prev; + last = e->prev; } e->prev = NULL; @@ -248,14 +248,14 @@ /*! リストの先頭を取得および削除する。リストが空の場合は NULL を返す。 - */ +*/ templateT* QueueInfo::poll() { T* e = first->next; if (e == this) { - return NULL; + return NULL; } remove(e); return e; @@ -271,15 +271,15 @@ /*! リスト内の指定された位置にある要素を返す。 要素数を超えた位置を指定した場合 NULL を返す。 - */ +*/ templateT* QueueInfo::get(int index) { T* e = first->next; for (int i = 0; i < index; i++) { - if (e->next == this) return NULL; - e = e->next; + if (e->next == this) return NULL; + e = e->next; } return e; } @@ -289,9 +289,9 @@ { T* e = first->next; for(;;) { - if (e == this) return NULL; - if (e == task) break; - e = e->next; + if (e == this) return NULL; + if (e == task) break; + e = e->next; } return e; } diff -r c8e35ceae52b -r 258498680128 TaskManager/kernel/schedule/SchedTask.cc --- a/TaskManager/kernel/schedule/SchedTask.cc Sun Nov 16 18:00:06 2014 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Tue Nov 25 05:08:50 2014 +0900 @@ -11,7 +11,7 @@ #include #include "gettime.h" -extern TaskObject task_list[MAX_TASK_OBJECT]; +//extern TaskObject task_list[MAX_TASK_OBJECT]; SchedTask::SchedTask() { @@ -44,6 +44,8 @@ manager = sc->manager; connector = sc->connector; + taskPool = new QueueInfo(); + inListData.bound = din; inListData.size = 0; inListData.length = 0; @@ -53,7 +55,7 @@ outListData.length = 0; outListData.element = 0; - cur_index = _task; + cur_index = _task; this->tag = tag; if (list) @@ -101,8 +103,8 @@ void SchedTask::exec() { - task_list[atask->command].wait(scheduler,atask->command); - TaskObjectRun run = task_list[atask->command].run; + taskPool->get(atask->command)->wait(scheduler,atask->command); + TaskObjectRun run = taskPool->get(atask->command)->run; if (atask->outData_count > 0) { setup_outputData(); // we need write buffer before run() } @@ -118,7 +120,7 @@ } (*connector->end_dmawait_profile)(&connector->global_busy_time,&connector->start_time,&connector->stop_time); list->task_end_time = gettime(); - __debug(this->scheduler,"cpuid %ld %s\t0x%p time %lld\n",scheduler->id,(char *)(task_list[atask->command].name),(void*)list, list->task_end_time-list->task_start_time); + __debug(this->scheduler,"cpuid %ld %s\t0x%p time %lld\n",scheduler->id,(char *)(taskPool->get(atask->command)->name),(void*)list, list->task_end_time-list->task_start_time); connector->free_(readbuf); // User 側で作る方法が必要... // 書き込む領域がなければ無視 diff -r c8e35ceae52b -r 258498680128 TaskManager/kernel/schedule/SchedTask.h --- a/TaskManager/kernel/schedule/SchedTask.h Sun Nov 16 18:00:06 2014 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Tue Nov 25 05:08:50 2014 +0900 @@ -7,7 +7,7 @@ #include "ListData.h" #include "HTask.h" #include "MemList.h" - +#include "QueueInfo.h" class SchedTask : public SchedTaskBase { public: @@ -32,6 +32,8 @@ // タスクの処理は、task_list に登録された C の関数によっておこなう public: + QueueInfo *taskPool; + /* functions */ void init(TaskListPtr _list, TaskPtr _task, diff -r c8e35ceae52b -r 258498680128 example/word_count/Makefile.def --- a/example/word_count/Makefile.def Sun Nov 16 18:00:06 2014 +0900 +++ b/example/word_count/Makefile.def Tue Nov 25 05:08:50 2014 +0900 @@ -12,7 +12,7 @@ OPT = -g -O0 CC = clang++ -CFLAGS = -m64 -Wall $(OPT) +CFLAGS = -m64 -Wall $(OPT) INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. -LIBS = -L${CERIUM}/TaskManager +LIBS = -L${CERIUM}/TaskManager -lprofiler -ltcmalloc diff -r c8e35ceae52b -r 258498680128 example/word_count/Makefile.macosx --- a/example/word_count/Makefile.macosx Sun Nov 16 18:00:06 2014 +0900 +++ b/example/word_count/Makefile.macosx Tue Nov 25 05:08:50 2014 +0900 @@ -11,8 +11,8 @@ TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) TASK_OBJS = $(TASK_SRCS:.cc=.o) -LIBS += -lFifoManager `sdl-config --libs` -CC += -m$(ABIBIT) +LIBS += -lFifoManager `sdl-config --libs` -lprofiler +CC += -m$(ABIBIT) -g .SUFFIXES: .cc .o