From 9f3d21ac20a3259906064308ec7be79fff6a87d8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 11 Jun 2021 14:30:26 +0200 Subject: [PATCH] Worker has parameters --- include/base.h | 4 ++++ src/localworker.c | 3 +-- src/scheduler.c | 5 +---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/base.h b/include/base.h index f570ca0..2163269 100644 --- a/include/base.h +++ b/include/base.h @@ -51,6 +51,10 @@ struct { pthread_t *id; } typedef SchedulerParams_t; +struct { + pthread_t *id; +} typedef WorkerParams_t; + // // Local threads // diff --git a/src/localworker.c b/src/localworker.c index c57f463..8525b94 100644 --- a/src/localworker.c +++ b/src/localworker.c @@ -40,10 +40,9 @@ pthread_t *WorkerInit(SchedulerParams_t *parameters) // -------------------------------------------------------------------------- // static void *LittleWorker(void *params) { - SchedulerParams_t *parameters = (SchedulerParams_t*) params; + WorkerParams_t *parameters = (WorkerParams_t*) params; int a = 4; - for (int i = 0; i < 45000; i++) { for (int j = i; j < 45000; j++) { a = (a + (long)parameters->id) * i * j; diff --git a/src/scheduler.c b/src/scheduler.c index 43c8d57..1b943df 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -42,11 +42,8 @@ pthread_t *SchedInit(SchedulerParams_t *parameters) static void *GreatScheduler(void *params) { SchedulerParams_t *parameters = (SchedulerParams_t*) params; - int a = 4; + printf("Scheduler id %p: I'm alive!\n", parameters->id); - - - printf("thread %d\n", a); return NULL; }