findWorkArea
This commit is contained in:
commit
dd45f7794a
|
@ -24,6 +24,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BASE_H
|
||||
|
||||
|
@ -37,6 +38,9 @@ struct {
|
|||
int *space;
|
||||
} typedef IntArray_t;
|
||||
|
||||
#define LOGMSG "[%s]"
|
||||
#define printLog(FORMAT, ...) printf(LOGMSG " " FORMAT, __func__, ##__VA_ARGS__)
|
||||
|
||||
//
|
||||
// Scheduler
|
||||
//
|
||||
|
@ -58,10 +62,13 @@ struct {
|
|||
//
|
||||
// Local threads
|
||||
//
|
||||
struct {
|
||||
struct Center_t {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
struct Center_t *next;
|
||||
struct Center_t *prev;
|
||||
} typedef Center_t;
|
||||
|
||||
struct {
|
||||
|
|
|
@ -53,6 +53,8 @@ void SchedulerCrashTest(void)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printLog("Starting gem-graph-server...\n");
|
||||
|
||||
//
|
||||
// Creating parameters structure for the Scheduler
|
||||
//
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "../include/base.h"
|
||||
#include "../include/localworker.h"
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
static void *GreatScheduler(void *parameters);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -36,14 +38,59 @@ pthread_t *SchedInit(SchedulerParams_t *parameters)
|
|||
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 //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static void *GreatScheduler(void *params)
|
||||
{
|
||||
// récupération des paramètres et annonce
|
||||
SchedulerParams_t *parameters = (SchedulerParams_t*) params;
|
||||
printLog("Scheduler id %lu: Bonjour I'm the boss !\n", *(parameters->id));
|
||||
|
||||
printf("Scheduler id %p: I'm alive!\n", parameters->id);
|
||||
int ncpu = get_nprocs();
|
||||
printLog("%d CPUs available.\n", ncpu);
|
||||
|
||||
Thread_t *workerArray = (Thread_t*) malloc(sizeof(Thread_t) * 3 * ncpu);
|
||||
Center_t *centersList = (Center_t*) malloc(sizeof(Center_t));
|
||||
|
||||
centerAssign(centersList, -1, -1, -1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue