some lisibility improvements
This commit is contained in:
parent
18077df85b
commit
cd9285e898
|
@ -80,7 +80,7 @@ struct {
|
||||||
//
|
//
|
||||||
struct {
|
struct {
|
||||||
Space_t *globalDrawingSpace;
|
Space_t *globalDrawingSpace;
|
||||||
IntArray_t *transitionsTree;
|
IntArray_t *conditionTree;
|
||||||
ArrowArray_t *arrowArray;
|
ArrowArray_t *arrowArray;
|
||||||
int nmaxThread;
|
int nmaxThread;
|
||||||
int nmaxCycles;
|
int nmaxCycles;
|
||||||
|
@ -107,7 +107,7 @@ struct {
|
||||||
pthread_t *id;
|
pthread_t *id;
|
||||||
Center_t *localWorkAreaCenter;
|
Center_t *localWorkAreaCenter;
|
||||||
Space_t *globalDrawingSpace;
|
Space_t *globalDrawingSpace;
|
||||||
IntArray_t *transitionsTree;
|
IntArray_t *conditionTree;
|
||||||
ArrowArray_t *arrowArray;
|
ArrowArray_t *arrowArray;
|
||||||
bool pleaseStop;
|
bool pleaseStop;
|
||||||
bool terminated;
|
bool terminated;
|
||||||
|
|
10
src/model.c
10
src/model.c
|
@ -22,6 +22,8 @@
|
||||||
#include "../include/base.h"
|
#include "../include/base.h"
|
||||||
#include "../include/arrows.h"
|
#include "../include/arrows.h"
|
||||||
|
|
||||||
|
#define MAX_MODEL_NUMBER 1
|
||||||
|
|
||||||
static Model_t *loadedModels;
|
static Model_t *loadedModels;
|
||||||
|
|
||||||
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model)
|
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model)
|
||||||
|
@ -55,3 +57,11 @@ void ModelPrepareArrows(Space_t *globalDrawingSpace, ArrowArray_t *arrowArray,
|
||||||
arrowArray->array[1].siteId = 0;
|
arrowArray->array[1].siteId = 0;
|
||||||
arrowArray->array[1].x = 4;
|
arrowArray->array[1].x = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelInit(void) {
|
||||||
|
loadedModels = (Model_t*) calloc(MAX_MODEL_NUMBER, sizeof(Model_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelDestroy(void) {
|
||||||
|
loadedModels = (Model_t*) calloc(MAX_MODEL_NUMBER, sizeof(Model_t));
|
||||||
|
}
|
||||||
|
|
|
@ -83,9 +83,10 @@ static void *schedulerMain(void *scheduler)
|
||||||
// area for a worker to operate on (as an approximation of a spheric one)
|
// area for a worker to operate on (as an approximation of a spheric one)
|
||||||
Center_t *centersList, *workArea;
|
Center_t *centersList, *workArea;
|
||||||
Arrow_t *electedArrow;
|
Arrow_t *electedArrow;
|
||||||
// A cycle is defined as the total renew of all allocated workers.
|
// A cycle is defined as the total renew of all allocated workers. This
|
||||||
// 1 cycle = thread * partial cycle.
|
// measure is used to evaluate the scheduler efficiency.
|
||||||
int nPartialCycles;
|
// 1 cycle = n partial cycle / n max worker.
|
||||||
|
int createdWorkers;
|
||||||
int ncpu, nworker, err;
|
int ncpu, nworker, err;
|
||||||
|
|
||||||
// Getting scheduler argument structure
|
// Getting scheduler argument structure
|
||||||
|
@ -103,7 +104,7 @@ static void *schedulerMain(void *scheduler)
|
||||||
workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t));
|
workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t));
|
||||||
nworker = 0;
|
nworker = 0;
|
||||||
centersList = (Center_t*) calloc(1, sizeof(Center_t));
|
centersList = (Center_t*) calloc(1, sizeof(Center_t));
|
||||||
nPartialCycles = 0;
|
createdWorkers = 0;
|
||||||
|
|
||||||
// Initiate the arrowArray lock
|
// Initiate the arrowArray lock
|
||||||
if (err = createArrowLock(args->arrowArray), err != 0) { // TODO destroy this
|
if (err = createArrowLock(args->arrowArray), err != 0) { // TODO destroy this
|
||||||
|
@ -113,7 +114,7 @@ static void *schedulerMain(void *scheduler)
|
||||||
//
|
//
|
||||||
// MAIN LOOP
|
// MAIN LOOP
|
||||||
//
|
//
|
||||||
while (!args->pleaseStop && (nPartialCycles / ncpu) <= args->nmaxCycles) {
|
while (!args->pleaseStop && (createdWorkers / ncpu) <= args->nmaxCycles) {
|
||||||
//printLog("Scheduler #%lu online: cycle %d\n", *args->id, ncycles);
|
//printLog("Scheduler #%lu online: cycle %d\n", *args->id, ncycles);
|
||||||
|
|
||||||
// TODO statistics here
|
// TODO statistics here
|
||||||
|
@ -152,8 +153,8 @@ static void *schedulerMain(void *scheduler)
|
||||||
workerArray[i].localWorkAreaCenter = workArea;
|
workerArray[i].localWorkAreaCenter = workArea;
|
||||||
workerArray[i].globalDrawingSpace =
|
workerArray[i].globalDrawingSpace =
|
||||||
args->globalDrawingSpace;
|
args->globalDrawingSpace;
|
||||||
workerArray[i].transitionsTree =
|
workerArray[i].conditionTree =
|
||||||
args->transitionsTree;
|
args->conditionTree;
|
||||||
workerArray[i].arrowArray =
|
workerArray[i].arrowArray =
|
||||||
args->arrowArray;
|
args->arrowArray;
|
||||||
// create the worker,
|
// create the worker,
|
||||||
|
@ -166,7 +167,7 @@ static void *schedulerMain(void *scheduler)
|
||||||
nworker
|
nworker
|
||||||
);
|
);
|
||||||
// Increment partial cycle
|
// Increment partial cycle
|
||||||
nPartialCycles++;
|
createdWorkers++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue