@@ -24,17 +24,39 @@ const SYSCALL_TRACE: usize = 410;
2424mod fs;
2525mod process;
2626
27+ use core:: sync:: atomic:: { AtomicIsize , Ordering } ;
28+
2729use fs:: * ;
2830use process:: * ;
2931
32+ static SYSCALL_WRITE_COUNT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
33+ static SYSCALL_EXIT_COUNT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
34+ static SYSCALL_YIELD_COUNT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
35+ static SYSCALL_GET_TIME_COUNT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
36+ static SYSCALL_TRACE_COUNT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
3037/// handle syscall exception with `syscall_id` and other arguments
3138pub fn syscall ( syscall_id : usize , args : [ usize ; 3 ] ) -> isize {
3239 match syscall_id {
33- SYSCALL_WRITE => sys_write ( args[ 0 ] , args[ 1 ] as * const u8 , args[ 2 ] ) ,
34- SYSCALL_EXIT => sys_exit ( args[ 0 ] as i32 ) ,
35- SYSCALL_YIELD => sys_yield ( ) ,
36- SYSCALL_GET_TIME => sys_get_time ( args[ 0 ] as * mut TimeVal , args[ 1 ] ) ,
37- SYSCALL_TRACE => sys_trace ( args[ 0 ] , args[ 1 ] , args[ 2 ] ) ,
40+ SYSCALL_WRITE => {
41+ SYSCALL_WRITE_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
42+ sys_write ( args[ 0 ] , args[ 1 ] as * const u8 , args[ 2 ] )
43+ }
44+ SYSCALL_EXIT => {
45+ SYSCALL_EXIT_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
46+ sys_exit ( args[ 0 ] as i32 )
47+ }
48+ SYSCALL_YIELD => {
49+ SYSCALL_YIELD_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
50+ sys_yield ( )
51+ }
52+ SYSCALL_GET_TIME => {
53+ SYSCALL_GET_TIME_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
54+ sys_get_time ( args[ 0 ] as * mut TimeVal , args[ 1 ] )
55+ }
56+ SYSCALL_TRACE => {
57+ SYSCALL_TRACE_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
58+ sys_trace ( args[ 0 ] , args[ 1 ] , args[ 2 ] )
59+ }
3860 _ => panic ! ( "Unsupported syscall_id: {}" , syscall_id) ,
3961 }
4062}
0 commit comments