Mercurial > hg > Members > kono > Cerium
view example/task_queue/spe/Hello.cc @ 639:70c5c2d2eb24
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Nov 2009 18:45:24 +0900 |
parents | ab866bc8a624 |
children |
line wrap: on
line source
#include <stdio.h> #include "Hello.h" #include "Func.h" #include "main.h" /* これは必須 */ SchedDefineTask(Hello); static int run(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = (long)smanager->get_param(0); smanager->printf("[%d] Hello, World!!\n", task_id); #if 0 we don't have TaskQueue in spu QueuePtr q = (QueuePtr )smanager->global_get(0); for(int i=0;i<100;i++) { TaskQueueInfo *i0 = q->q[i%MAX_QUEUE]; TaskQueueInfo *i1 = q->q[(i+1)%MAX_QUEUE]; TaskQueue *q0; TaskQueue *q1; // switch(smanager->get_random() % 4) { switch(q->j++ % 4 ) { case 0: q0 = i0->create(0); q1 = i1->create(0); i1->addLast(q0); i0->addLast(q1); break; case 1: if (TaskQueue *p = i0->poll()) { i1->addLast(p); } break; case 2: if (TaskQueue *p = i1->poll()) { i0->addLast(p); } break; case 3: if (TaskQueue *p = i0->poll()) { i0->free_(p); } if (TaskQueue *p = i1->poll()) { i1->free_(p); } break; } } #endif return 0; }