Redesign syscalls
All checks were successful
Build documentation / build-and-deploy (push) Successful in 40s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 40s
This commit is contained in:
55
init/init.c
55
init/init.c
@@ -1,7 +1,7 @@
|
||||
#include <alloc/liballoc.h>
|
||||
#include <limits.h>
|
||||
#include <m/proc.h>
|
||||
#include <m/status.h>
|
||||
#include <m/system.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string/string.h>
|
||||
@@ -9,52 +9,17 @@
|
||||
#define EXAMPLE 1
|
||||
|
||||
#if EXAMPLE == 1
|
||||
int mutex_rid;
|
||||
|
||||
void mythread (void) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
proc_mutex_lock (mutex_rid, RV_PRIVATE);
|
||||
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
proc_test ('b');
|
||||
|
||||
proc_mutex_unlock (mutex_rid, RV_PRIVATE);
|
||||
|
||||
for (volatile int i = 0; i < 200 * 1000 * 1000; i++)
|
||||
;
|
||||
}
|
||||
|
||||
proc_quit ();
|
||||
}
|
||||
|
||||
int make_thread (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 proc_clone (stack_top, stack_size, (void*)fn);
|
||||
}
|
||||
|
||||
void app_main (void) {
|
||||
mutex_rid = proc_create_resource (200, PR_MUTEX, RV_PRIVATE, NULL);
|
||||
test ('a');
|
||||
test ('a');
|
||||
test ('a');
|
||||
|
||||
make_thread (&mythread);
|
||||
int* xs = malloc (1024 * sizeof (*xs));
|
||||
memset (xs, 123, 1024 * sizeof (*xs));
|
||||
free (xs);
|
||||
|
||||
for (int j = 0; j < 10; j++) {
|
||||
proc_mutex_lock (mutex_rid, RV_PRIVATE);
|
||||
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
proc_test ('a');
|
||||
|
||||
proc_mutex_unlock (mutex_rid, RV_PRIVATE);
|
||||
|
||||
for (volatile int i = 0; i < 400 * 1000 * 1000; i++)
|
||||
;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
;
|
||||
test ('a');
|
||||
test ('a');
|
||||
test ('a');
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user