summaryrefslogtreecommitdiff
path: root/src/non_critical/syscall_storm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/non_critical/syscall_storm.c')
-rw-r--r--src/non_critical/syscall_storm.c44
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