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.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/non_critical/syscall_storm.c b/src/non_critical/syscall_storm.c
index ff7347d..a7a2066 100644
--- a/src/non_critical/syscall_storm.c
+++ b/src/non_critical/syscall_storm.c
@@ -9,29 +9,33 @@
pthread_t THRS[MAX_THREADS];
-
-static void* syscall_storm_linux(void* iterations) {
+static void* syscall_storm_linux(void* arg) {
+ int iterations = *(int*)arg;
while(1) {
- for(int i = 0; 1 < iterations; i++) {
+ for(int i = 0; i < iterations; i++) {
syscall(rand() % 400, rand() / rand());
- printf("%d. Called rand(), from thread %d", i);
+ printf("%d. Called rand(), from thread %d\n", i, (int)(intptr_t)arg);
+ }
}
-}
+ return NULL;
}
int init_syscall_storm(int threads, int iterations) {
- if (threads > 5) {
- printf("ERR: Max treads 5, %d required", threads);
- return NULL;
+ if (threads > MAX_THREADS) {
+ printf("ERR: Max treads 5, %d required\n", threads);
+ return -1;
}
- 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;
+ for(int i = 0; i < threads; i++) {
+ int *thread_arg = malloc(sizeof(int));
+ *thread_arg = iterations;
+ if (pthread_create(&THRS[i], NULL, syscall_storm_linux, thread_arg) != 0) {
+ printf("ERR: Could not create thread %d\n", i);
+ free(thread_arg);
+ return -1;
}
- };
+ }
+ return 0;
}
void stop_syscall_storm() {
@@ -39,6 +43,10 @@ void stop_syscall_storm() {
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
+//TODO: Add support for other *NIXes
+
+
+// cc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -m64 -I src/non_critical -I src/critical/classic -std=c11 -o /home/namilskyy/suicidekit/target/debug/build/suicidekit-d9b57cca9def6d72/out/170d28c25dafbf6f-random_sounds.o -c src/non_critical/random_sounds.c
+
+