diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-10-29 00:17:37 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-10-29 00:18:11 +0300 |
| commit | 6833ea062f264ff35773f23f6f68b293b4cfec34 (patch) | |
| tree | 94729c4364bc1a304e295b31cae89dca0b845832 /src/non_critical/syscall_storm.c | |
| parent | d7c64d28e1bb3a9e8f563704128593da80b9f0a7 (diff) | |
Implemented some not critical functions.
Diffstat (limited to 'src/non_critical/syscall_storm.c')
| -rw-r--r-- | src/non_critical/syscall_storm.c | 44 |
1 files changed, 44 insertions, 0 deletions
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 <sys/syscall.h> +#include <unistd.h> +#include <stdlib.h> +#include <pthread.h> +#include <stdio.h> + +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 |
