diff options
author | Christian Cunningham <cc@localhost> | 2022-02-13 01:54:51 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-02-13 01:54:51 -0700 |
commit | 958696be616aaaa4fe18fc2b886216f191bb6f9b (patch) | |
tree | 1bdef3ca97744487cfaad680665adce83dc60d47 /src/tests | |
parent | fcf70bcd6a2b2d3bbf76280041438fb1abf33d52 (diff) |
Mutex Waiting Implemented
Svc 4 and 5
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/test.c b/src/tests/test.c index f6213ae..af906cc 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -4,8 +4,10 @@ #include <lib/kmem.h> #include <sys/core.h> #include <sys/schedule.h> +#include <util/mutex.h> extern void atest(void); +void btest(void); void test_entry(void) { @@ -27,4 +29,47 @@ void test_entry(void) dt += tf - ti; DRAW64(34, 19, dt/64); DRAW64(34+17, 19, dt%64); + btest(); +} + +static struct Mutex testm = {.addr = 0, .pid = 0}; +static int testi = 0; + +void ctest1(void) +{ + uart_string("1 Started\n"); + sys1(4, &testm); + uart_string("1 Finished\n"); +} + +void ctest2(void) +{ + uart_string("2 Started\n"); + sys1(4, &testm); + uart_string("2 Finished\n"); + sys1(5, &testm); +} + +void ctest3(void) +{ + uart_string("3 Started\n"); + sys1(5, &testm); + uart_string("3 Finished\n"); +} + +void btest(void) +{ + if (testi % 3 == 0) { + testi++; + ctest1(); + } + else if (testi % 3 == 1) { + testi++; + ctest2(); + } + else if (testi % 3 == 2) { + testi++; + ctest3(); + } + uart_hexn(&testm); } |