view TaskManager/Cell/CellHTaskInfo.cc @ 109:5c194c71eca8

Cerium cvs version
author gongo@gendarme.local
date Wed, 12 Nov 2008 17:39:33 +0900
parents
children 8602bb323369
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include "CellHTaskInfo.h"

int
CellHTaskInfo::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;
	posix_memalign((void**)&q->inData, DEFAULT_ALIGNMENT, sizeof(ListData));
	posix_memalign((void**)&q->outData, DEFAULT_ALIGNMENT, sizeof(ListData));
    }
    q->next = freeHTask;
    posix_memalign((void**)&q->inData, DEFAULT_ALIGNMENT, sizeof(ListData));
    posix_memalign((void**)&q->outData, DEFAULT_ALIGNMENT, sizeof(ListData));

    freeHTask = htaskPool + 1;

    return 0;
}