Files
mop3/init/init.c
kamkow1 cf51600c6a
All checks were successful
Build documentation / build-and-deploy (push) Successful in 34s
Cleanup syscalls
2026-01-27 17:34:43 +01:00

50 lines
806 B
C

#include <alloc/liballoc.h>
#include <limits.h>
#include <m/status.h>
#include <m/system.h>
#include <stddef.h>
#include <stdint.h>
#include <string/string.h>
#define MUTEX 2000
void app_thread1 (void);
int spawn (void (*fn) (void)) {
size_t stack_size = 256 * PAGE_SIZE;
void* stack = malloc (stack_size);
if (stack == NULL)
return -ST_OOM_ERROR;
uintptr_t stack_top = (uintptr_t)stack + stack_size;
return clone (stack_top, fn);
}
void app_main (void) {
mutex_create (MUTEX);
spawn (&app_thread1);
for (;;) {
mutex_lock (MUTEX);
for (int i = 0; i < 3; i++)
test ('a');
mutex_unlock (MUTEX);
}
}
void app_thread1 (void) {
for (;;) {
mutex_lock (MUTEX);
for (int i = 0; i < 3; i++)
test ('b');
mutex_unlock (MUTEX);
}
quit ();
}