Changeset 566 for trunk/kernel/syscalls/sys_getpid.c
- Timestamp:
- Oct 4, 2018, 11:50:21 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_getpid.c
r506 r566 1 1 /* 2 * kern/sys_getpid.c - get process id2 * kern/sys_getpid.c - Kernel function implementing the "get_pid" system call. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017, 2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 23 23 24 24 #include <thread.h> 25 25 #include <process.h> 26 26 #include <syscalls.h> 27 27 28 //////////////// 28 ////////////////////// 29 29 int sys_getpid( void ) 30 30 { 31 return CURRENT_THREAD->process->pid; 32 } 31 thread_t * this = CURRENT_THREAD; 32 process_t * process = this->process; 33 34 #if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS) 35 uint64_t tm_start = hal_get_cycles(); 36 #endif 37 38 #if DEBUG_SYS_GETPID 39 tm_start = hal_get_cycles(); 40 if( DEBUG_SYS_FG < tm_start ) 41 printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n", 42 __FUNCTION__ , this->trdid , process->pid, (uint32_t)tm_start ); 43 #endif 44 45 // get pid value from local process descriptor 46 pid_t pid = process->pid; 47 48 #if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS) 49 uint64_t tm_end = hal_get_cycles(); 50 #endif 51 52 #if DEBUG_SYS_GETPID 53 tm_end = hal_get_cycles(); 54 if( DEBUG_SYS_GETPID < tm_end ) 55 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n", 56 __FUNCTION__, this->trdid, process->pid, (uint32_t)tm_end ); 57 #endif 58 59 #if CONFIG_INSTRUMENTATION_SYSCALLS 60 hal_atomic_add( &syscalls_cumul_cost[SYS_GETPID] , tm_end - tm_start ); 61 hal_atomic_add( &syscalls_occurences[SYS_GETPID] , 1 ); 62 #endif 63 64 return pid; 65 66 } // end sys_getpid()
Note: See TracChangeset
for help on using the changeset viewer.