From 61ceb3602868c55153ea38042afb0ec238fe0e69 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 11 Jun 2021 13:40:59 +0200 Subject: [PATCH 1/2] Thread -> worker --- include/{localthread.h => localworker.h} | 4 +++- src/{localthread.c => localworker.c} | 0 src/main.c | 4 ++-- src/scheduler.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) rename include/{localthread.h => localworker.h} (96%) rename src/{localthread.c => localworker.c} (100%) diff --git a/include/localthread.h b/include/localworker.h similarity index 96% rename from include/localthread.h rename to include/localworker.h index fa36ae8..3ba3250 100644 --- a/include/localthread.h +++ b/include/localworker.h @@ -1,5 +1,5 @@ //=-------------------------------------------------------------------------=// -// Scheduler definition // +// Local workers definition // // // // Copyright © 2021 The Gem-graph Project // // // @@ -22,3 +22,5 @@ #ifndef BASE_H #include "../include/base.h" #endif + + diff --git a/src/localthread.c b/src/localworker.c similarity index 100% rename from src/localthread.c rename to src/localworker.c diff --git a/src/main.c b/src/main.c index 284f70e..6be34a5 100644 --- a/src/main.c +++ b/src/main.c @@ -31,7 +31,7 @@ void SchedulerCrashTest(void) { - const int maxthread = 2000; + const int maxthread = 16; SchedulerParams_t *parameters = (SchedulerParams_t*) calloc(1, sizeof(SchedulerParams_t)); @@ -97,7 +97,7 @@ int main(int argc, char **argv) free(parameters); - SchedulerCrashTest(); + //SchedulerCrashTest(); return 0; } diff --git a/src/scheduler.c b/src/scheduler.c index c7aa556..e66fb3c 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -20,7 +20,7 @@ //=-------------------------------------------------------------------------=// #include "../include/base.h" -#include "../include/localthread.h" +#include "../include/localworker.h" static void *GreatScheduler(void *parameters); From cbfcdb389f67fb4fa9ad8b41211dfe88280172f9 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 11 Jun 2021 13:56:52 +0200 Subject: [PATCH 2/2] cleanup inlines --- Makefile | 2 +- include/scheduler.h | 17 +++++++++++++++-- src/scheduler.c | 17 ----------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 1ffd83d..bf3d151 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ LDFLAGS= -lc -lpthread BINDIR=bin SRCDIR=src DEBDIR=debian -OBJ=$(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localthread.o $(BINDIR)/main.o +OBJ=$(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o $(BINDIR)/main.o .DEFAULT_GOAL:= all .PHONY: all clean deb diff --git a/include/scheduler.h b/include/scheduler.h index b10a305..a54fa76 100644 --- a/include/scheduler.h +++ b/include/scheduler.h @@ -25,6 +25,19 @@ pthread_t *SchedInit(SchedulerParams_t *parameters); -int SchedWait(pthread_t *schedThread); +// -------------------------------------------------------------------------- // +// Scheduler destructor function // +// -------------------------------------------------------------------------- // +static inline int SchedDestroy(pthread_t *schedThread) +{ + free(schedThread); + return 0; +} -int SchedDestroy(pthread_t *schedThread); +// -------------------------------------------------------------------------- // +// Scheduler wait function // +// -------------------------------------------------------------------------- // +static inline void SchedWait(pthread_t *schedThread) +{ + pthread_join(*schedThread, NULL); +} diff --git a/src/scheduler.c b/src/scheduler.c index e66fb3c..cd91c75 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -36,23 +36,6 @@ pthread_t *SchedInit(SchedulerParams_t *parameters) return parameters->id; } -// -------------------------------------------------------------------------- // -// Scheduler destructor function // -// -------------------------------------------------------------------------- // -int SchedDestroy(pthread_t *schedThread) -{ - free(schedThread); - return 0; -} - -// -------------------------------------------------------------------------- // -// Scheduler wait function // -// -------------------------------------------------------------------------- // -void SchedWait(pthread_t *schedThread) -{ - pthread_join(*schedThread, NULL); -} - // -------------------------------------------------------------------------- // // Scheduler thread main function // // -------------------------------------------------------------------------- //