Rewrite resource subsystem
This commit is contained in:
24
init/init.c
24
init/init.c
@@ -6,16 +6,20 @@
|
||||
#include <stdint.h>
|
||||
#include <string/string.h>
|
||||
|
||||
char c = 'a';
|
||||
#define EXAMPLE 1
|
||||
|
||||
#if EXAMPLE == 1
|
||||
int mutex_rid;
|
||||
|
||||
void mythread (void) {
|
||||
for (;;) {
|
||||
proc_mutex_lock (mutex_rid);
|
||||
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);
|
||||
proc_mutex_unlock (mutex_rid, RV_PRIVATE);
|
||||
}
|
||||
|
||||
proc_quit ();
|
||||
}
|
||||
|
||||
int make_thread (void (*fn) (void)) {
|
||||
@@ -29,14 +33,18 @@ int make_thread (void (*fn) (void)) {
|
||||
}
|
||||
|
||||
void app_main (void) {
|
||||
mutex_rid = proc_create_resource_mutex (200, RV_PRIVATE);
|
||||
mutex_rid = proc_create_resource (200, PR_MUTEX, RV_PRIVATE, NULL);
|
||||
|
||||
make_thread (&mythread);
|
||||
|
||||
for (;;) {
|
||||
proc_mutex_lock (mutex_rid);
|
||||
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);
|
||||
proc_mutex_unlock (mutex_rid, RV_PRIVATE);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user