diff options
author | Christian Cunningham <cc@localhost> | 2022-03-19 10:30:56 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-03-19 10:30:56 -0700 |
commit | 8e475d7e3d540a6d4ea244e38fcfb74179349326 (patch) | |
tree | d81a633b9d25a265ed2e18d25cc341ce31f20d72 /src/tests | |
parent | c1bd3aa131d89abc128e2e9ddc24fd80c86c203e (diff) |
Added Deadlock Test
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/tests/test.c b/src/tests/test.c index 1776483..2cd830e 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -231,6 +231,44 @@ void stest2(void) draw_cletter(x++, y+2, 'F', 0xFF00); } +static struct Mutex* dead1 = 0; +static struct Mutex* dead2 = 0; + +void dtest2(void) +{ + draw_cletter(x++, y+1, 'S', 0xFF00); + draw_cletter(x++, y+1, 'l', 0xFF00); + lock_mutex(dead1); + draw_cletter(x++, y+1, 'L', 0xFF00); + lock_mutex(dead2); + draw_cletter(x++, y+1, 'u', 0xFF00); + unlock_mutex(dead2); + draw_cletter(x++, y+1, 'U', 0xFF00); + unlock_mutex(dead1); + draw_cletter(x++, y+1, 'F', 0xFF00); +} + +void dtest1(void) +{ + draw_cletter(x++, y+2, ' ', 0xFF0000); + draw_cletter(x++, y+2, 'S', 0xFF0000); + dead1 = create_mutex(0xDEADBEEF); + dead2 = create_mutex(0x12345678); + draw_cletter(x++, y+2, 'L', 0xFF0000); + lock_mutex(dead2); + draw_cletter(x++, y+2, 'A', 0xFF0000); + add_thread(dtest2, 0, 6); + draw_cletter(x++, y+2, 'l', 0xFF0000); + lock_mutex(dead1); + draw_cletter(x++, y+2, 'u', 0xFF0000); + unlock_mutex(dead2); + draw_cletter(x++, y+2, 'U', 0xFF0000); + unlock_mutex(dead1); + delete_mutex(dead1); + delete_mutex(dead2); + draw_cletter(x++, y+2, 'F', 0xFF0000); +} + void btest(void) { draw_string(0, y+0, " "); @@ -239,6 +277,7 @@ void btest(void) draw_string(0, y+3, " "); x = 0; add_thread(ctest1, 0, 3); - add_thread(stest1, 0, 6); - add_thread(stest2, 0, 7); + //add_thread(stest1, 0, 6); + //add_thread(stest2, 0, 7); + add_thread(dtest1, 0, 7); } |