Center list
This commit is contained in:
parent
f4711dab25
commit
b73a9a8091
|
@ -62,13 +62,16 @@ struct {
|
||||||
//
|
//
|
||||||
// Local threads
|
// Local threads
|
||||||
//
|
//
|
||||||
struct {
|
struct Center_t {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
|
|
||||||
|
struct Center_t *next;
|
||||||
|
struct Center_t *prev;
|
||||||
} typedef Center_t;
|
} typedef Center_t;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
pthread_t *id;
|
pthread_t *id;
|
||||||
Center_t *localWorkAreaCenter;
|
Center_t *localWorkAreaCenter;
|
||||||
} typedef Thread_t;
|
} typedef Thread_t;
|
||||||
|
|
|
@ -38,6 +38,43 @@ pthread_t *SchedInit(SchedulerParams_t *parameters)
|
||||||
return parameters->id;
|
return parameters->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------- //
|
||||||
|
// Center_t management functions //
|
||||||
|
// -------------------------------------------------------------------------- //
|
||||||
|
static inline void centerAssign(Center_t *center, int x, int y, int z)
|
||||||
|
{
|
||||||
|
center->x = x;
|
||||||
|
center->y = y;
|
||||||
|
center->z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Center_t *centerAdd(Center_t *anyCenter)
|
||||||
|
{
|
||||||
|
Center_t *newCenter = (Center_t*) malloc(sizeof(Center_t));
|
||||||
|
|
||||||
|
Center_t *temp = anyCenter->next;
|
||||||
|
anyCenter->next = newCenter;
|
||||||
|
newCenter->next = temp;
|
||||||
|
newCenter->prev = anyCenter;
|
||||||
|
|
||||||
|
if (temp) {
|
||||||
|
temp->prev = newCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void centerRemove(Center_t *oldCenter)
|
||||||
|
{
|
||||||
|
Center_t *prev = oldCenter->prev;
|
||||||
|
Center_t *next = oldCenter->next;
|
||||||
|
|
||||||
|
prev->next = next->prev;
|
||||||
|
next->prev = prev->next;
|
||||||
|
|
||||||
|
free(oldCenter);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
// Scheduler thread main function //
|
// Scheduler thread main function //
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
|
@ -45,11 +82,15 @@ static void *GreatScheduler(void *params)
|
||||||
{
|
{
|
||||||
// récupération des paramètres et annonce
|
// récupération des paramètres et annonce
|
||||||
SchedulerParams_t *parameters = (SchedulerParams_t*) params;
|
SchedulerParams_t *parameters = (SchedulerParams_t*) params;
|
||||||
printLog("Scheduler id %lu: I'm alive!\n", *(parameters->id));
|
printLog("Scheduler id %lu: Bonjour I'm the boss !\n", *(parameters->id));
|
||||||
|
|
||||||
int ncpu = get_nprocs();
|
int ncpu = get_nprocs();
|
||||||
printLog("%d CPUs available.\n", ncpu);
|
printLog("%d CPUs available.\n", ncpu);
|
||||||
|
|
||||||
|
Thread_t *workerArray = (Thread_t*) malloc(sizeof(Thread_t) * 3 * ncpu);
|
||||||
|
Center_t *centersArray = (Center_t*) malloc(sizeof(Center_t));
|
||||||
|
|
||||||
|
centerAssign(centersArray, -1, -1, -1);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue