From cd9285e898c7fed5300bc922c1697f9bde4c8dfc Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 23 Jun 2021 11:37:47 +0200 Subject: [PATCH] some lisibility improvements --- include/base.h | 4 ++-- src/model.c | 10 ++++++++++ src/scheduler.c | 17 +++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/base.h b/include/base.h index ee5acda..678a96d 100644 --- a/include/base.h +++ b/include/base.h @@ -80,7 +80,7 @@ struct { // struct { Space_t *globalDrawingSpace; - IntArray_t *transitionsTree; + IntArray_t *conditionTree; ArrowArray_t *arrowArray; int nmaxThread; int nmaxCycles; @@ -107,7 +107,7 @@ struct { pthread_t *id; Center_t *localWorkAreaCenter; Space_t *globalDrawingSpace; - IntArray_t *transitionsTree; + IntArray_t *conditionTree; ArrowArray_t *arrowArray; bool pleaseStop; bool terminated; diff --git a/src/model.c b/src/model.c index 80153a4..bd1dab0 100644 --- a/src/model.c +++ b/src/model.c @@ -22,6 +22,8 @@ #include "../include/base.h" #include "../include/arrows.h" +#define MAX_MODEL_NUMBER 1 + static Model_t *loadedModels; 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].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)); +} diff --git a/src/scheduler.c b/src/scheduler.c index 2ab48bc..cce8345 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -83,9 +83,10 @@ static void *schedulerMain(void *scheduler) // area for a worker to operate on (as an approximation of a spheric one) Center_t *centersList, *workArea; Arrow_t *electedArrow; - // A cycle is defined as the total renew of all allocated workers. - // 1 cycle = thread * partial cycle. - int nPartialCycles; + // A cycle is defined as the total renew of all allocated workers. This + // measure is used to evaluate the scheduler efficiency. + // 1 cycle = n partial cycle / n max worker. + int createdWorkers; int ncpu, nworker, err; // Getting scheduler argument structure @@ -103,7 +104,7 @@ static void *schedulerMain(void *scheduler) workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t)); nworker = 0; centersList = (Center_t*) calloc(1, sizeof(Center_t)); - nPartialCycles = 0; + createdWorkers = 0; // Initiate the arrowArray lock if (err = createArrowLock(args->arrowArray), err != 0) { // TODO destroy this @@ -113,7 +114,7 @@ static void *schedulerMain(void *scheduler) // // 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); // TODO statistics here @@ -152,8 +153,8 @@ static void *schedulerMain(void *scheduler) workerArray[i].localWorkAreaCenter = workArea; workerArray[i].globalDrawingSpace = args->globalDrawingSpace; - workerArray[i].transitionsTree = - args->transitionsTree; + workerArray[i].conditionTree = + args->conditionTree; workerArray[i].arrowArray = args->arrowArray; // create the worker, @@ -166,7 +167,7 @@ static void *schedulerMain(void *scheduler) nworker ); // Increment partial cycle - nPartialCycles++; + createdWorkers++; break; } }