Changeset 436 for trunk/kernel/syscalls/sys_thread_cancel.c
- Timestamp:
- Mar 7, 2018, 9:02:03 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_thread_cancel.c
r410 r436 1 1 /* 2 * sys_thread_cancel.c - terminate execution of a targetthread.2 * sys_thread_cancel.c - terminate execution of an user thread. 3 3 * 4 * Authors Alain Greiner (2016,2017 )4 * Authors Alain Greiner (2016,2017, 2018) 5 5 * 6 * Copyright (c) 2011,2012UPMC Sorbonne Universites6 * Copyright (c) UPMC Sorbonne Universites 7 7 * 8 8 * This file is part of ALMOS-MKH. … … 33 33 { 34 34 xptr_t target_xp; // target thread extended pointer 35 thread_t * target_ptr; // target thread local pointer36 cxy_t target_cxy; // target thread cluster37 ltid_t target_ltid; // target thread local index38 35 39 #if CONFIG_SYSCALL_DEBUG 40 uint32_t tm_start; 41 uint32_t tm_end; 42 tm_start = hal_get_cycles(); 43 #endif 44 36 // get killer thread pointers 45 37 thread_t * this = CURRENT_THREAD; 46 38 process_t * process = this->process; 47 48 // check kernel stack overflow49 assert( (this->signature == THREAD_SIGNATURE), __FUNCTION__, "kernel stack overflow\n" );50 51 // get target thread ltid and cxy52 target_ltid = LTID_FROM_TRDID( trdid );53 target_cxy = CXY_FROM_TRDID( trdid );54 55 // check trdid argument56 if( (target_ltid >= CONFIG_THREAD_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) )57 {58 printk("\n[ERROR] in %s : illegal trdid argument\n", __FUNCTION__ );59 this->errno = EINVAL;60 return -1;61 }62 39 63 40 // get extended pointer on target thread 64 41 target_xp = thread_get_xptr( process->pid , trdid ); 65 42 43 // check target_xp 66 44 if( target_xp == XPTR_NULL ) 67 45 { 68 printk("\n[ERROR] in %s : target thread not found\n", __FUNCTION__ ); 46 47 #if CONFIG_DEBUG_SYSCALLS_ERROR 48 printk("\n[ERROR] in %s : target thread %x not found\n", __FUNCTION__, trdid ); 49 #endif 69 50 this->errno = EINVAL; 70 51 return -1; 71 52 } 72 53 73 // get target thread local pointer 74 target_ptr = (thread_t *)GET_PTR( target_xp ); 54 #if CONFIG_DEBUG_SYS_THREAD_CANCEL 55 uint64_t tm_start; 56 uint64_t tm_end; 57 tm_start = hal_get_cycles(); 58 if( CONFIG_DEBUG_SYS_THREAD_CANCEL < tm_start ) 59 printk("\n[DBG] %s : thread %x enter to kill thread %x / cycle %d\n", 60 __FUCTION__, this, GET_PTR( target_xp ), (uint32_t)tm_start ); 61 #endif 75 62 76 63 // cal the relevant kernel function 77 if( target_cxy == local_cxy ) // target thread is local 78 { 79 thread_kill( target_ptr ); 80 } 81 else 82 { 83 rpc_thread_kill_client( target_cxy , target_ptr ); 84 } 64 thread_kill( target_xp, 65 0, // is_exit 66 0 ); // is forced 85 67 86 #if CONFIG_ SYSCALL_DEBUG68 #if CONFIG_DEBUG_SYS_THREAD_CANCEL 87 69 tm_end = hal_get_cycles(); 88 syscall_dmsg("\n[DBG] %s : core[%x,%d] / thread %x in process %x / cycle %d\n" 89 "thread %x killed / cost = %d\n", 90 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid , tm_start , 91 trdid , (uint32_t)(tm_end - tm_start) ); 70 if( CONFIG_DEBUG_SYS_THREAD_CANCEL < tm_end ) 71 printk("\n[DBG] %s : thread %x exit after kill thread %x / cycle %d\n", 72 __FUCTION__, this, GET_PTR( target_xp ), (uint32_t)tm_end ); 92 73 #endif 93 74
Note: See TracChangeset
for help on using the changeset viewer.