diff TaskManager/Cell/CellTaskManagerImpl.cc @ 481:f9ffcffb6d09 draft

Double linked list modification done (tested on Mac OS X)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 05 Oct 2009 16:46:46 +0900
parents bf2d2625485e
children d6245cb38028
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Mon Oct 05 12:24:07 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Mon Oct 05 16:46:46 2009 +0900
@@ -33,6 +33,8 @@
     taskListImpl = new CellTaskListInfo;
     taskListImpl->init(machineNum*2);
 
+    activeTaskQueue = new TaskQueueInfo();
+
     htaskImpl = new CellHTaskInfo;
     htaskImpl->init(TASK_MAX_SIZE*2);
 
@@ -60,13 +62,11 @@
 void
 CellTaskManagerImpl::append_activeTask(HTaskPtr task)
 {
-    TaskQueuePtr q;
-
-    q = taskQueueImpl->create(task);
     if (task->cpu_type == CPU_PPE) {
         ppeManager->append_activeTask(task);
     } else {
-        activeTaskQueue = TaskQueue::append(activeTaskQueue, q);
+	TaskQueuePtr q = taskQueueImpl->create(task);
+        activeTaskQueue->addLast(q);
     }
 }
 
@@ -87,21 +87,18 @@
 {
     // ここ...直すかな
     TaskListPtr list;
-    TaskQueuePtr queue;
+    
     TaskQueuePtr d;
     HTaskPtr htask;
     TaskPtr task;
     int speid;
 
-    queue = activeTaskQueue;
-    if (queue == NULL) {
+    if (activeTaskQueue->empty()) {
 	return ;
     }
  
-    while (queue) {
+    while (TaskQueuePtr queue = activeTaskQueue->poll()) {
 	htask = (HTaskPtr)queue->task;
-	d = queue;
-	queue = queue->next;
 
 	if (htask->cpu_type == SPE_ANY) {
 	    speid = cur_anySpeid++;
@@ -139,10 +136,10 @@
 	task->outData  = htask->outData;
 	task->self     = (unsigned int)htask;
 #else
-	memcpy(task, htask, sizeof(Task));
+	memcpy(task, (Task*)htask, sizeof(Task));
 #endif
 
-	taskQueueImpl->free(d);
+	activeTaskQueue->free(queue);
     }
 
     activeTaskQueue = NULL;
@@ -259,7 +256,7 @@
 	// であり、この場合もし SPE にタスクが残っていても
 	// メインループから抜けてプログラム終了となってしまうので
 	// ここでストップかけてます。
-    } while (!ppeManager->activeTaskQueue && waitTaskQueue);
+    } while (ppeManager->activeTaskQueue->empty() && !waitTaskQueue->empty());
 	
     return ppeManager->get_runTaskList();
 }