From 6833ea062f264ff35773f23f6f68b293b4cfec34 Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Wed, 29 Oct 2025 00:17:37 +0300 Subject: Implemented some not critical functions. --- src/non_critical/syscall_storm.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/non_critical/syscall_storm.c (limited to 'src/non_critical/syscall_storm.c') diff --git a/src/non_critical/syscall_storm.c b/src/non_critical/syscall_storm.c new file mode 100644 index 0000000..bfe7dde --- /dev/null +++ b/src/non_critical/syscall_storm.c @@ -0,0 +1,44 @@ +#define _GNU_SOURCE +#define MAX_THREADS 5 + +#include +#include +#include +#include +#include + +pthread_t THRS[MAX_THREADS]; + + +static void* syscall_storm_linux(void* iterations) { + while(1) { + for(int i = 0; 1 < iterations; i++) { + syscall(rand() % 400, rand() / rand()); + printf("%d. Called rand(), from thread %d", i); + } +} +} + +int init(int threads, int iterations) { + if (threads > 5) { + printf("ERR: Max treads 5, %d required", threads); + return NULL; + } + + for(int i = 0; i < MAX_THREADS; i++) { + int thread_args[i] = i; + if (pthread_create(&THRS[i], NULL, syscall_storm_linux, thread_args) != 0) { + printf("ERR: Could not create thread %d", i); + return NULL; + } + }; +} + +void stop() { + for(int i = 0; i < MAX_THREADS; i++) { + pthread_cancel(THRS[i]); + } +} + +//TODO: Fix this and create random shit-syscall chooser. Maximaly shitcoded!!! Its system-killer, not a default program +//TODO: Add support for other *NIXes \ No newline at end of file -- cgit v1.2.3