diff --git a/src/localworker.c b/src/localworker.c index effcd53..14fb910 100644 --- a/src/localworker.c +++ b/src/localworker.c @@ -33,7 +33,7 @@ void WorkerInit(Worker_t *worker) worker->id = (pthread_t*) calloc(1, sizeof(pthread_t)); if (pthread_create(worker->id, NULL, workerMain, worker)) { printLog("Worker #%lu can't be initialized!\n", *(worker->id)); - return NULL; + return; } } @@ -48,9 +48,37 @@ static void *workerMain(void *worker) args = (Worker_t*) worker; printLog("Worker #%lu online\n", *args->id); - for (int i = 0; i < 45000; i++) { - for (int j = i; j < 45000; j++) { - a = (a + (long)args->id) * i * j; + int size = args->globalDrawingSpace->size; + /* In each cell: the West (left) site is 0, the East (right) site is 1 */ + for (int orig=0; orig < size; orig++){ + int nxt1 = (orig + 1) % size, + nxt2 = (orig + 2) % size, + prv1 = (orig - 1 + size) % size; + + if( + args->globalDrawingSpace->space[orig].sites[1].nArrow == 1 + && args->globalDrawingSpace->space[nxt2].sites[0].nArrow == 0 + + ) { + args->globalDrawingSpace->space[orig].sites[1].nArrow = 0; + args->globalDrawingSpace->space[nxt1].sites[0].nArrow = 0; + args->globalDrawingSpace->space[nxt1].sites[1].nArrow = 1; + args->globalDrawingSpace->space[nxt2].sites[0].nArrow = 1; + + /* TODO args->arrowArray->array[1].siteId = 0;*/ + } + + else if( + args->globalDrawingSpace->space[orig].sites[1].nArrow == 1 + && args->globalDrawingSpace->space[prv1].sites[0].nArrow == 0 + + ) { + args->globalDrawingSpace->space[orig].sites[1].nArrow = 0; + args->globalDrawingSpace->space[nxt1].sites[0].nArrow = 0; + args->globalDrawingSpace->space[orig].sites[0].nArrow = 1; + args->globalDrawingSpace->space[prv1].sites[1].nArrow = 1; + + /* TODO args->arrowArray->array[1].siteId = 0;*/ } } diff --git a/src/scheduler.c b/src/scheduler.c index 93e1f45..cb6096d 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -90,7 +90,7 @@ static void *schedulerMain(void *scheduler) args = (Scheduler_t*) scheduler; printLog("Scheduler #%lu online\n", *args->id); - if (!args->nmaxThread) { // nmaxthread = 0 => no minimum + if (!args->nMaxThread) { // nmaxthread = 0 => no minimum ncpu = get_nprocs(); // allocating all the cpus available } else { // n thread = min(cpu, nmaxthread) ncpu = MIN(get_nprocs(), args->nMaxThread);