some lisibility improvements
This commit is contained in:
parent
18077df85b
commit
cd9285e898
|
@ -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;
|
||||
|
|
10
src/model.c
10
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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue