diff options
author | Frans Kaashoek <[email protected]> | 2020-08-10 13:05:17 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-10 13:05:17 -0400 |
commit | c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9 (patch) | |
tree | a6c903e1c61c08f4cb87700c320752a737081dcb /user/alarmtest.c | |
parent | 90eb90b5e203299427c3fde8c996a48835fc93cf (diff) | |
parent | d8fe1773b26758c7c7b8f36724cd822555b33612 (diff) | |
download | xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.gz xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.bz2 xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.zip |
Merge branch 'riscv' into riscv
Diffstat (limited to 'user/alarmtest.c')
-rw-r--r-- | user/alarmtest.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/user/alarmtest.c b/user/alarmtest.c deleted file mode 100644 index ca3db23..0000000 --- a/user/alarmtest.c +++ /dev/null @@ -1,88 +0,0 @@ -// -// test program for the alarm lab. -// you can modify this file for testing, -// but please make sure your kernel -// modifications pass the original -// versions of these tests. -// - -#include "kernel/param.h" -#include "kernel/types.h" -#include "kernel/stat.h" -#include "kernel/riscv.h" -#include "user/user.h" - -void test0(); -void test1(); -void periodic(); - -int -main(int argc, char *argv[]) -{ - test0(); - test1(); - exit(); -} - -volatile static int count; - -void -periodic() -{ - count = count + 1; - printf("alarm!\n"); - sigreturn(); -} - -// tests whether the kernel calls -// the alarm handler even a single time. -void -test0() -{ - int i; - printf("test0 start\n"); - count = 0; - sigalarm(2, periodic); - for(i = 0; i < 1000*500000; i++){ - if((i % 250000) == 0) - write(2, ".", 1); - if(count > 0) - break; - } - sigalarm(0, 0); - if(count > 0){ - printf("test0 passed\n"); - } else { - printf("test0 failed\n"); - } -} - -void __attribute__ ((noinline)) foo(int i, int *j) { - if((i % 2500000) == 0) { - write(2, ".", 1); - } - *j += 1; -} - -void -test1() -{ - int i; - int j; - - printf("test1 start\n"); - count = 0; - j = 0; - sigalarm(2, periodic); - for(i = 0; i < 500000000; i++){ - if(count >= 10) - break; - foo(i, &j); - } - if(i != j || count < 10){ - // i should equal j - printf("test1 failed\n"); - } else { - printf("test1 passed\n"); - } -} |