From 18077df85b3baa25fb92ca0204670024ad5856bb Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 23 Jun 2021 11:06:36 +0200 Subject: [PATCH] some lisibility improvements --- include/arrows.h | 2 +- src/scheduler.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/arrows.h b/include/arrows.h index 9689ffe..3be8a38 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -38,7 +38,7 @@ static inline int acquireArrowLock(ArrowArray_t *arrowArray) 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); } diff --git a/src/scheduler.c b/src/scheduler.c index fa102b9..2ab48bc 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -45,7 +45,7 @@ void SchedInit(Scheduler_t *scheduler) // Scheduler area finder function // // -------------------------------------------------------------------------- // 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; @@ -124,14 +124,15 @@ static void *schedulerMain(void *scheduler) workArea = NULL; // Acquiring lock to consistently read the arrowArray - if (acquireNonBlockinArrowgLock(args->arrowArray)) { + if (acquireNonBlockingArrowLock(args->arrowArray)) { // Random choice of an arrow electedArrow = &args->arrowArray->array[rand() % args->arrowArray->size]; // Find a local area - workArea = findWorkArea(centersList, electedArrow, args->ruleRadius, - args->globalDrawingSpace->size, + workArea = findWorkArea(centersList, + electedArrow, + args->ruleRadius, args->globalDrawingSpace->xmax, args->globalDrawingSpace->ymax, args->globalDrawingSpace->zmax @@ -141,13 +142,12 @@ static void *schedulerMain(void *scheduler) // If a free area exists, if (workArea) { - //printLog("A free workArea exists at %p\n", workArea); // preempt it, CenterAdd(centersList, workArea); // find a worker socket, for (int i = 0; i < ncpu; i++) { - if (!workerArray[i].id) { - //printLog("Adding worker at rank %d\n", i); + // if a location is empty + if (workerArray[i].id == 0) { // prepare the worker for the area, workerArray[i].localWorkAreaCenter = workArea; workerArray[i].globalDrawingSpace =