Mercurial > hg > Game > Cerium
view TaskManager/kernel/ppe/HTaskInfo.cc @ 70:178459e03f5c
*** empty log message ***
author | gongo |
---|---|
date | Mon, 18 Feb 2008 01:13:00 +0900 |
parents | 519d24aa7ac8 |
children | 83b57e03d3ef |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "TaskManagerImpl.h" #include "HTaskInfo.h" HTaskInfo::HTaskInfo(void) :htaskPool(NULL), freeHTask(NULL) {} HTaskInfo::~HTaskInfo(void) { destroy(); } int HTaskInfo::init(int num) { if (htaskPool == NULL) { return extend_pool(num); } return 0; } /** * Fix me * extend できる限界を設定するべき? */ int HTaskInfo::extend_pool(int num) { HTaskPtr q = NULL; q = (HTaskPtr)malloc(sizeof(HTask)*(num+1)); if (q == NULL) { return -1; } q->next = htaskPool; htaskPool = q; /* Connect all free queue in the pool */ for (q = htaskPool + 1; --num > 0; q++) { q->next = q + 1; } q->next = freeHTask; freeHTask = htaskPool + 1; return 0; } HTaskPtr HTaskInfo::create(int cmd, int size, DmaBuffer *in_addr, DmaBuffer *out_addr) { HTaskPtr q; if (freeHTask == NULL) { extend_pool(100); } q = freeHTask; freeHTask = freeHTask->next; q->command = cmd; q->in_addr = in_addr; q->out_addr = out_addr; q->in_size = size; q->wait_me = NULL; q->wait_i = NULL; q->post_func = NULL; q->mimpl = NULL; q->cpu_type = CPU_PPE; return q; } void HTaskInfo::free(HTaskPtr q) { q->next = freeHTask; freeHTask = q; } void HTaskInfo::destroy(void) { HTaskPtr q; for (q = htaskPool; q; q = q->next) { free(q); } freeHTask = htaskPool = NULL; } /** * manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ * * ってやるより * * task2->set_depend(task1); * * ってやったほうがわかりやすいよねー的な話し合いで * 下のようなAPIを作りました */ void HTask::spawn(void) { mimpl->spawn_task(this); } void HTask::set_depend(HTaskPtr master) { mimpl->set_task_depend(master, this); } void HTask::set_cpu(CPU_TYPE type) { mimpl->set_task_cpu(this, type); }