Mercurial > hg > Members > kono > Cerium
changeset 821:6e8f8eb1e407
queueInfoTest 90% done
author | game@zeus.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 23 May 2010 16:23:52 +0900 |
parents | e6eea3a208cd |
children | ba45c7b81d2a |
files | TaskManager/kernel/ppe/QueueInfo.h example/task_queue/Makefile.def |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 11:30:39 2010 +0900 +++ b/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 16:23:52 2010 +0900 @@ -2,6 +2,7 @@ #define INCLUDED_QUEUE_INFO #include "base.h" +#include "types.h" #if 0 template <typename T> class Queue : T { @@ -21,9 +22,13 @@ public: /* constructor */ - QueueInfo<T>(); + QueueInfo<T>(){ + queueInfoInit(); + } QueueInfo<T>(QueueInfo<T> *p) { + queueInfoInit(); queuePool = p; + queuePool->queuePool = queuePool; } BASE_NEW_DELETE(QueueInfo); @@ -59,6 +64,7 @@ /* functions */ int extend_pool(int num); void destroy(); + void queueInfoInit(); }; @@ -73,7 +79,7 @@ // you have to define it at where you want to use. // template<typename T>static QueueInfo<T> QueueInfo<T>::queuePool; -template<typename T>QueueInfo<T>::QueueInfo() { +template<typename T>void QueueInfo<T>::queueInfoInit() { // 最初の一つは自分 first = last = this; this->next = this->prev = this; @@ -93,20 +99,23 @@ template<typename T>int QueueInfo<T>::extend_pool(int num) { - T * q = (T *)malloc(sizeof(T)*(num+1)); + T* q = (T*)malloc(sizeof(T)*(num+1)+DEFAULT_ALIGNMENT); // First Queue is previous pool q->waiter = this->waiter; this->waiter = q; + q = (T*)ROUND_UP_ALIGN((long)q, DEFAULT_ALIGNMENT); q++; /* Connect all free queue in the pool */ - T * p = q; - for (; num-- > 0; p++) { - p->waiter = NULL; - queuePool->addLast(p); + T* p = q; + for (; num-- > 0;) { + p->waiter = NULL; + queuePool->addLast(p); + p = (T*)ROUND_UP_ALIGN((long)(p+1),DEFAULT_ALIGNMENT); } return 0; + } /**
--- a/example/task_queue/Makefile.def Sun May 23 11:30:39 2010 +0900 +++ b/example/task_queue/Makefile.def Sun May 23 16:23:52 2010 +0900 @@ -8,7 +8,7 @@ CERIUM = ../../../Cerium CC = g++ -CFLAGS = -g -Wall -O9 +CFLAGS = -g -Wall #-O9 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager