changeset 1362:6b4a0846afcb draft

Spe Threads Init moved
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Fri, 20 Jan 2012 05:46:00 +0900
parents 652fce805fde
children 38ee695f772c
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/ppe/CpuThreads.h TaskManager/kernel/schedule/Scheduler.cc
diffstat 5 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Jan 17 18:12:09 2012 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Jan 20 05:46:00 2012 +0900
@@ -26,9 +26,6 @@
 	spe_running = 0;
 	spuIdle = spuIdle_;
 
-	//speThreads = new SpeThreads(machineNum);
-	//speThreads->init();
-
 	// 実行される Task 用の パイプライン用のダブルバッファ
 	speTaskList = new QueueInfo<TaskList>*[machineNum]; // spe上の走っている Task の配列
 	taskListInfo = new QueueInfo<TaskList>*[machineNum]; // 次に走る Task の配列
@@ -46,6 +43,8 @@
 	set_scheduler(mscheduler);
 	ppeManager->init(mscheduler, this, useRefDma); // ここで HTaskInfo が共有される。
 
+	speThreads->init();
+
 	// 実行可能な HTask のリスト。 FifoTaskManager と共有される
 	activeTaskQueue = ppeManager->activeTaskQueue;
 	// HTask の factory。 HTaskInfo ならなんでもいい。
@@ -358,7 +357,6 @@
 create_impl(int num, int useRefDma)
 {
 	Threads *cpus = new SpeThreads(num);
-	cpus->init();
 	return new CellTaskManagerImpl(num,cpus);
 }
 #endif // __CERIUM_CELL
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Tue Jan 17 18:12:09 2012 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Fri Jan 20 05:46:00 2012 +0900
@@ -342,7 +342,6 @@
     return new FifoTaskManagerImpl(num);
 	} else {
 		Threads *cpus = new CpuThreads(num,useRefDma);
-		cpus->init();
 		return new CellTaskManagerImpl(num,cpus);
 	}
 }
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Tue Jan 17 18:12:09 2012 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Fri Jan 20 05:46:00 2012 +0900
@@ -11,19 +11,12 @@
 SchedExternTask(StartProfile);
 
 
-CpuThreads::CpuThreads(int num, int useRefDma, int start_id) : cpu_num(num), id_offset(start_id) {
+CpuThreads::CpuThreads(int num, int useRefDma, int start_id) : cpu_num(num), use_refdma(useRefDma), id_offset(start_id) {
 
     threads = new pthread_t[cpu_num];
     args    = new cpu_thread_arg_t[cpu_num];
     wait	= new Sem(0);
 
-    for (int i = 0; i < cpu_num; i++) {
-	args[i].cpuid = i + id_offset;
-	args[i].scheduler = new MainScheduler();
-	args[i].wait = wait;
-	args[i].useRefDma = useRefDma;
-    }
-
 }
 
 CpuThreads::~CpuThreads()
@@ -73,6 +66,13 @@
 //CpuThreads::init()
 CpuThreads::init()
 {
+	for (int i = 0; i < cpu_num; i++) {
+		args[i].cpuid = i + id_offset;
+		args[i].scheduler = new MainScheduler();
+		args[i].wait = wait;
+		args[i].useRefDma = use_refdma;
+	}
+
     for (int i = 0; i < cpu_num; i++) {
 	pthread_create(&threads[i], NULL,
 		      &cpu_thread_run, (void*)&args[i]);
--- a/TaskManager/kernel/ppe/CpuThreads.h	Tue Jan 17 18:12:09 2012 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.h	Fri Jan 20 05:46:00 2012 +0900
@@ -36,6 +36,7 @@
     cpu_thread_arg_t *args;
     SemPtr wait; //スレッド生成時の待ち用
     int cpu_num;
+	int use_refdma;
     int id_offset;
 };
 
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue Jan 17 18:12:09 2012 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Fri Jan 20 05:46:00 2012 +0900
@@ -48,6 +48,12 @@
     task_count = 0;
 #endif
 
+	/* 
+	 * ;TODO
+	 * Multi-Core Verの場合、各スレッドにMain Schedulerが作られるが、
+	 * その際、globalなlistの初期化を繰り返して無駄な処理を行なっている
+	 */
+
     for (int i = 0; i< MAX_TASK_OBJECT; i++) {
 	task_list[i].run = null_run;
 	task_list[i].load = null_loader;