Changeset 440 for trunk/kernel/syscalls/sys_thread_create.c
- Timestamp:
- May 3, 2018, 5:51:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_thread_create.c
r438 r440 53 53 trdid_t trdid; // created thread identifier 54 54 process_t * process; // pointer on local process descriptor 55 paddr_t paddr; // unused, required by vmm_v2p_translate()55 vseg_t * vseg; // required for user space checking 56 56 cxy_t target_cxy; // target cluster identifier 57 57 error_t error; … … 67 67 tm_start = hal_get_cycles(); 68 68 if( DEBUG_SYS_THREAD_CREATE < tm_start ) 69 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n" 70 __FUNCTION__ , parent , process->pid, (uint32_t)tm_start ); 71 #endif 72 73 // check user_attr in user space & copy to kernel space 69 printk("\n[DBG] %s : thread %x (cxy %x) enter / process %x / cycle %d\n", 70 __FUNCTION__, parent, local_cxy, process->pid, (uint32_t)tm_start ); 71 #endif 72 73 // check trdid buffer in user space 74 error = vmm_get_vseg( process , (intptr_t)trdid_ptr , &vseg ); 75 76 if ( error ) 77 { 78 79 #if DEBUG_SYSCALLS_ERROR 80 printk("\n[ERROR] in %s : trdid buffer unmapped %x / thread %x / process %x\n", 81 __FUNCTION__ , (intptr_t)trdid_ptr, parent->trdid, process->pid ); 82 vmm_display( process , false ); 83 #endif 84 parent->errno = EINVAL; 85 return -1; 86 } 87 88 // check user_attr buffer in user space & copy to kernel space 74 89 if( user_attr != NULL ) 75 90 { 76 error = vmm_ v2p_translate( false , user_attr , &paddr);91 error = vmm_get_vseg( process , (intptr_t)user_attr , &vseg ); 77 92 78 93 if( error ) … … 80 95 81 96 #if DEBUG_SYSCALLS_ERROR 82 printk("\n[ERROR] in %s : user_attr unmapped\n", __FUNCTION__ ); 97 printk("\n[ERROR] in %s : user_attr buffer unmapped %x / thread %x / process %x\n", 98 __FUNCTION__ , (intptr_t)user_attr , parent->trdid , process->pid ); 99 vmm_display( process , false ); 83 100 #endif 84 101 parent->errno = EINVAL; … … 90 107 91 108 // check start_func in user space 92 error = vmm_v2p_translate( false , start_func , &paddr ); 93 94 if( error ) 95 { 96 97 #if DEBUG_SYSCALLS_ERROR 98 printk("\n[ERROR] in %s : start_func unmapped\n", __FUNCTION__ ); 99 #endif 100 parent->errno = EINVAL; 101 return -1; 102 } 103 104 // check start_arg in user space 105 if( start_arg != NULL ) error = vmm_v2p_translate( false , start_arg , &paddr ); 106 107 if( error ) 108 { 109 110 #if DEBUG_SYSCALLS_ERROR 111 printk("\n[ERROR] in %s : start_arg unmapped\n", __FUNCTION__ ); 112 #endif 113 parent->errno = EINVAL; 114 return -1; 115 } 116 117 // check / define attributes an target_cxy 109 error = vmm_get_vseg( process , (intptr_t)start_func , &vseg ); 110 111 if( error ) 112 { 113 114 #if DEBUG_SYSCALLS_ERROR 115 printk("\n[ERROR] in %s : start_func unmapped %x / thread %x / process %x\n", 116 __FUNCTION__ , (intptr_t)start_func , parent->trdid , process->pid ); 117 vmm_display( process , false ); 118 #endif 119 parent->errno = EINVAL; 120 return -1; 121 } 122 123 // check start_arg buffer in user space 124 if( start_arg != NULL ) 125 { 126 error = vmm_get_vseg( process , (intptr_t)start_arg , &vseg ); 127 128 if( error ) 129 { 130 131 #if DEBUG_SYSCALLS_ERROR 132 printk("\n[ERROR] in %s : start_arg buffer unmapped %x / thread %x / process %x\n", 133 __FUNCTION__ , (intptr_t)start_arg , parent->trdid , process->pid ); 134 vmm_display( process , false ); 135 #endif 136 parent->errno = EINVAL; 137 return -1; 138 } 139 } 140 141 // define attributes and target_cxy 118 142 if( user_attr != NULL ) // user defined attributes 119 143 { … … 125 149 126 150 #if DEBUG_SYSCALLS_ERROR 127 printk("\n[ERROR] in %s : illegal target cluster = %x\n", __FUNCTION__ , kern_attr.cxy ); 151 printk("\n[ERROR] in %s : illegal target cluster = %x / thread %x / process %x\n", 152 __FUNCTION__ , kern_attr.cxy, parent->trdid, process->pid ); 128 153 #endif 129 154 parent->errno = EINVAL; … … 175 200 176 201 #if DEBUG_SYSCALLS_ERROR 177 printk("\n[ERROR] in %s : cannot create thread\n", __FUNCTION__ ); 178 #endif 179 return ENOMEM; 202 printk("\n[ERROR] in %s : cannot create new thread / thread %x / process %x\n", 203 __FUNCTION__ , parent->trdid, process->pid ); 204 #endif 205 parent->errno = ENOMEM; 206 return -1; 180 207 } 181 208 … … 184 211 hal_copy_to_uspace( trdid_ptr , &trdid , sizeof(pthread_t) ); 185 212 186 // register child in parent if required187 if( user_attr != NULL )188 {189 if( (kern_attr.attributes & PT_ATTR_DETACH) == 0 )190 thread_child_parent_link( parent_xp , child_xp );191 }192 193 213 // activate new thread 194 214 thread_unblock( child_xp , THREAD_BLOCKED_GLOBAL ); … … 199 219 tm_end = hal_get_cycles(); 200 220 if( DEBUG_SYS_THREAD_CREATE < tm_end ) 201 printk("\n[DBG] %s : thread %x created thread %x for process %x in cluster %x / cycle %d\n"202 __FUNCTION__, parent, child_ptr, process->pid, target_cxy, (uint32_t)tm_end );221 printk("\n[DBG] %s : thread %x (cxy %x) created thread %x (cxy %x) / process %x / cycle %d\n", 222 __FUNCTION__, parent, local_cxy, child_ptr, target_cxy, process->pid, (uint32_t)tm_end ); 203 223 #endif 204 224
Note: See TracChangeset
for help on using the changeset viewer.