Add mutex syscalls
This commit is contained in:
26
init/init.c
26
init/init.c
@@ -9,17 +9,21 @@
|
||||
#define EXAMPLE 1
|
||||
|
||||
#if EXAMPLE == 1
|
||||
void app_main (void) {
|
||||
test ('a');
|
||||
test ('a');
|
||||
test ('a');
|
||||
|
||||
int* xs = malloc (1024 * sizeof (*xs));
|
||||
memset (xs, 123, 1024 * sizeof (*xs));
|
||||
free (xs);
|
||||
|
||||
test ('a');
|
||||
test ('a');
|
||||
test ('a');
|
||||
void app_thread1 (void) {
|
||||
test ('b');
|
||||
quit ();
|
||||
}
|
||||
|
||||
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, stack_size, fn);
|
||||
}
|
||||
|
||||
void app_main (void) { spawn (&app_thread1); }
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user