From 6af6eb521c0f1b79a90c6f60409dab3e89d52d03 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 26 Aug 2022 14:28:56 +0000 Subject: [PATCH] Add threadspawn Benchmarks parallel thread creation & destruction within one process or within the system in general (when ran as _processes variant). --- Makefile | 1 + tests/threadspawn1.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/threadspawn1.c diff --git a/Makefile b/Makefile index 8dd0717..ce4e1a6 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ processes: $(processes) threads: $(threads) posix_semaphore1_processes_FLAGS+=-lpthread +threadspawn1_processes_FLAGS+=-lpthread $(processes): %_processes: tests/%.o main.c $(CC) $(CFLAGS) main.c $< $($@_FLAGS) $(LDFLAGS) -o $@ diff --git a/tests/threadspawn1.c b/tests/threadspawn1.c new file mode 100644 index 0000000..a7f6e8c --- /dev/null +++ b/tests/threadspawn1.c @@ -0,0 +1,23 @@ +#include +#include + +char *testcase_description = "Thread creation and teardown"; + +static void *worker(void *arg) +{ + return (NULL); +} + +void testcase(unsigned long long *iterations, unsigned long nr) +{ + pthread_t thread; + int error; + + while (1) { + error = pthread_create(&thread, NULL, worker, NULL); + assert(error == 0); + error = pthread_join(thread, NULL); + assert(error == 0); + (*iterations)++; + } +}