changeset 961:02f1a707ee82

fix QueueInfo
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 04 Aug 2010 23:05:59 +0900
parents 6945fb810ce3
children 9f9b2bbc9a10
files TaskManager/kernel/ppe/QueueInfo.h example/task_queue/main.cc example/task_queue/main.h example/task_queue/ppe/Hello.cc example/task_queue/testQueueInfo.cc
diffstat 5 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/QueueInfo.h	Wed Aug 04 19:08:33 2010 +0900
+++ b/TaskManager/kernel/ppe/QueueInfo.h	Wed Aug 04 23:05:59 2010 +0900
@@ -32,6 +32,7 @@
     */
     QueueInfo<T>(){
 	queueInfoInit();
+	queuePool = this;
     }
     /** 
 	normal constructor requires
@@ -39,7 +40,6 @@
     QueueInfo<T>(QueueInfo<T> *p) {
 	queueInfoInit();
 	queuePool = p;
-	queuePool->queuePool = queuePool;
     }
 
     BASE_NEW_DELETE(QueueInfo);
--- a/example/task_queue/main.cc	Wed Aug 04 19:08:33 2010 +0900
+++ b/example/task_queue/main.cc	Wed Aug 04 23:05:59 2010 +0900
@@ -7,12 +7,13 @@
 
 extern void task_init(void);
 
-static int count = 1;
+static int count = 10;
 
 extern TaskManager *manager;
 
 extern void queueInfoTest(int count);
 
+static	QueueInfo<TaskQueue> *mainPool = new QueueInfo<TaskQueue>() ;
 
 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
   -cpu    Number of SPE (default 1) \n\
@@ -62,7 +63,8 @@
     queues.m = manager;
     queues.i = 0;
     for (int i = 0; i < MAX_QUEUE; i++) {
-	TaskQueueInfo *q = new TaskQueueInfo() ;
+	QueueInfo<TaskQueue> *q = new QueueInfo<TaskQueue>(mainPool) ;
+	// QueueInfo<TaskQueue> *q = new QueueInfo<TaskQueue>() ;
 	queues.q[i] = q;
     }
 
@@ -106,6 +108,7 @@
     if (init(argc, argv) < 0) {
 	return -1;
     }
+    if (count<2) count = 2;
 
     // Task Register
     //   ppe/task_init.cc
--- a/example/task_queue/main.h	Wed Aug 04 19:08:33 2010 +0900
+++ b/example/task_queue/main.h	Wed Aug 04 23:05:59 2010 +0900
@@ -1,4 +1,5 @@
-#include "TaskQueueInfo.h"
+#include "TaskQueue.h"
+#include "QueueInfo.h"
 #include "TaskManager.h"
 
 #define MAX_QUEUE 4
@@ -7,5 +8,5 @@
     int i;
     int j;
     TaskManager *m;
-    TaskQueueInfo *q[MAX_QUEUE];
+    QueueInfo<TaskQueue> *q[MAX_QUEUE];
 } Queues, *QueuePtr;
--- a/example/task_queue/ppe/Hello.cc	Wed Aug 04 19:08:33 2010 +0900
+++ b/example/task_queue/ppe/Hello.cc	Wed Aug 04 23:05:59 2010 +0900
@@ -18,15 +18,15 @@
     smanager->printf("[%d] Hello, World!!\n", task_id);
 
     for(int i=0;i<100;i++) {
-	TaskQueueInfo *i0 = q->q[i%MAX_QUEUE];
-	TaskQueueInfo *i1 = q->q[(i+1)%MAX_QUEUE];
+	QueueInfo<TaskQueue> *i0 = q->q[i%MAX_QUEUE];
+	QueueInfo<TaskQueue> *i1 = q->q[(i+1)%MAX_QUEUE];
 	TaskQueue *q0;
 	TaskQueue *q1;
 
 	switch(q->m->get_random() % 4) {
 	case 0:
-	    q0 = i0->create(0);
-	    q1 = i1->create(0);
+	    q0 = i0->create(); i0->init(0);
+	    q1 = i1->create(); i1->init(0);
 	    i1->addLast(q0);
 	    i0->addLast(q1);
 	    break;
--- a/example/task_queue/testQueueInfo.cc	Wed Aug 04 19:08:33 2010 +0900
+++ b/example/task_queue/testQueueInfo.cc	Wed Aug 04 23:05:59 2010 +0900
@@ -27,14 +27,14 @@
 
     i = 0;
     for(TaskListPtr t=  q->getFirst(); t ;t = q->getNext(t) ) {
-	printf(" No. %d %ld\n", i++, t->length);
+	printf(" No. %d %d\n", i++, t->length);
     }
 
-    printf("First %ld\n", q->getFirst()->length);
-    printf("Last %ld\n", q->getLast()->length);
+    printf("First %d\n", q->getFirst()->length);
+    printf("Last %d\n", q->getLast()->length);
 
     TaskListPtr t = q->poll();
-    printf("Polled %ld\n", t->length);
+    printf("Polled %d\n", t->length);
     q->free_(t);
 
     printf("Length %d = %d - 1\n", q->length(), count);
@@ -43,7 +43,7 @@
 
     i = 0;
     for(TaskListPtr t=  q->getFirst(); t ;t = q->getNext(t) ) {
-	printf(" No. %d %ld\n", i++, t->length);
+	printf(" No. %d %d\n", i++, t->length);
     }
 
     while(!q->empty()){
@@ -52,7 +52,7 @@
 
     i = 0;
     for(TaskListPtr t=  r->getFirst(); t ;t = r->getNext(t) ) {
-	printf(" No. %d %ld\n", i++, t->length);
+	printf(" No. %d %d\n", i++, t->length);
     }