some lisibility improvements

This commit is contained in:
Adrien Bourmault 2021-06-23 11:06:36 +02:00
parent 7c4c43b996
commit 18077df85b
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 8 additions and 8 deletions

View File

@ -38,7 +38,7 @@ static inline int acquireArrowLock(ArrowArray_t *arrowArray)
return pthread_spin_lock(&arrowArray->lock); return pthread_spin_lock(&arrowArray->lock);
} }
static inline int acquireNonBlockinArrowgLock(ArrowArray_t *arrowArray) static inline int acquireNonBlockingArrowLock(ArrowArray_t *arrowArray)
{ {
return pthread_spin_trylock(&arrowArray->lock); return pthread_spin_trylock(&arrowArray->lock);
} }

View File

@ -45,7 +45,7 @@ void SchedInit(Scheduler_t *scheduler)
// Scheduler area finder function // // Scheduler area finder function //
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow, static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow,
int ruleRadius, size_t spaceSize, int xmax, int ymax, int zmax) int ruleRadius, int xmax, int ymax, int zmax)
{ {
register Center_t *currentCenter, *newCenter; register Center_t *currentCenter, *newCenter;
@ -124,14 +124,15 @@ static void *schedulerMain(void *scheduler)
workArea = NULL; workArea = NULL;
// Acquiring lock to consistently read the arrowArray // Acquiring lock to consistently read the arrowArray
if (acquireNonBlockinArrowgLock(args->arrowArray)) { if (acquireNonBlockingArrowLock(args->arrowArray)) {
// Random choice of an arrow // Random choice of an arrow
electedArrow = electedArrow =
&args->arrowArray->array[rand() % args->arrowArray->size]; &args->arrowArray->array[rand() % args->arrowArray->size];
// Find a local area // Find a local area
workArea = findWorkArea(centersList, electedArrow, args->ruleRadius, workArea = findWorkArea(centersList,
args->globalDrawingSpace->size, electedArrow,
args->ruleRadius,
args->globalDrawingSpace->xmax, args->globalDrawingSpace->xmax,
args->globalDrawingSpace->ymax, args->globalDrawingSpace->ymax,
args->globalDrawingSpace->zmax args->globalDrawingSpace->zmax
@ -141,13 +142,12 @@ static void *schedulerMain(void *scheduler)
// If a free area exists, // If a free area exists,
if (workArea) { if (workArea) {
//printLog("A free workArea exists at %p\n", workArea);
// preempt it, // preempt it,
CenterAdd(centersList, workArea); CenterAdd(centersList, workArea);
// find a worker socket, // find a worker socket,
for (int i = 0; i < ncpu; i++) { for (int i = 0; i < ncpu; i++) {
if (!workerArray[i].id) { // if a location is empty
//printLog("Adding worker at rank %d\n", i); if (workerArray[i].id == 0) {
// prepare the worker for the area, // prepare the worker for the area,
workerArray[i].localWorkAreaCenter = workArea; workerArray[i].localWorkAreaCenter = workArea;
workerArray[i].globalDrawingSpace = workerArray[i].globalDrawingSpace =