Changeset 619 for trunk/kernel/syscalls
- Timestamp:
- Feb 12, 2019, 1:15:47 PM (6 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_barrier.c
r581 r619 24 24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 #include <hal_uspace.h> 26 27 #include <errno.h> 27 28 #include <thread.h> … … 43 44 44 45 ////////////////////////////////// 45 int sys_barrier( void *vaddr,46 int sys_barrier( intptr_t vaddr, 46 47 uint32_t operation, 47 uint32_t count ) 48 uint32_t count, 49 intptr_t attr ) 48 50 { 49 error_t error; 50 vseg_t * vseg; 51 52 thread_t * this = CURRENT_THREAD; 53 process_t * process = this->process; 51 error_t error; 52 vseg_t * vseg; 53 pthread_barrierattr_t k_attr; 54 55 thread_t * this = CURRENT_THREAD; 56 process_t * process = this->process; 54 57 55 58 #if DEBUG_SYS_BARRIER … … 58 61 tm_start = hal_get_cycles(); 59 62 if( DEBUG_SYS_BARRIER < tm_start ) 60 printk("\n[ DBG] %s : thread %x in process %x enterfor %s / count %d / cycle %d\n",61 __FUNCTION__, this->trdid, process->pid, sys_barrier_op_str(operation), count,63 printk("\n[%s] thread[%x,%x] enters for %s / count %d / cycle %d\n", 64 __FUNCTION__, process->pid, this->trdid, sys_barrier_op_str(operation), count, 62 65 (uint32_t)tm_start ); 63 66 #endif 64 67 65 68 // check vaddr in user vspace 66 error = vmm_get_vseg( process , (intptr_t)vaddr , &vseg ); 67 69 error = vmm_get_vseg( process , vaddr , &vseg ); 68 70 if( error ) 69 71 { … … 71 73 #if DEBUG_SYSCALLS_ERROR 72 74 printk("\n[ERROR] in %s : unmapped barrier %x / thread %x / process %x\n", 73 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );75 __FUNCTION__ , vaddr , this->trdid , process->pid ); 74 76 vmm_display( process , false ); 75 77 #endif … … 84 86 case BARRIER_INIT: 85 87 { 86 error = remote_barrier_create( (intptr_t)vaddr , count ); 87 88 if( attr != 0 ) // QDT barrier required 89 { 90 error = vmm_get_vseg( process , attr , &vseg ); 91 if( error ) 92 { 93 94 #if DEBUG_SYSCALLS_ERROR 95 printk("\n[ERROR] in %s : unmapped barrier attributes %x / thread %x / process %x\n", 96 __FUNCTION__ , attr , this->trdid , process->pid ); 97 vmm_display( process , false ); 98 #endif 99 this->errno = EINVAL; 100 return -1; 101 } 102 103 // copy barrier attributes into kernel space 104 hal_copy_from_uspace( &k_attr , (void*)attr , sizeof(pthread_barrierattr_t) ); 105 106 if ( count != k_attr.x_size * k_attr.y_size *k_attr.nthreads ) 107 { 108 109 #if DEBUG_SYSCALLS_ERROR 110 printk("\n[ERROR] in %s : wrong arguments / count %d / x_size %d / y_size %d / nthreads %x\n", 111 __FUNCTION__, count, k_attr.x_size, k_attr.y_size, k_attr.nthreads ); 112 #endif 113 this->errno = EINVAL; 114 return -1; 115 } 116 117 118 // call relevant system function 119 error = generic_barrier_create( vaddr , count , &k_attr ); 120 } 121 else // simple barrier required 122 { 123 error = generic_barrier_create( vaddr , count , NULL ); 124 } 125 88 126 if( error ) 89 127 { … … 91 129 #if DEBUG_SYSCALLS_ERROR 92 130 printk("\n[ERROR] in %s : cannot create barrier %x / thread %x / process %x\n", 93 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );131 __FUNCTION__ , vaddr , this->trdid , process->pid ); 94 132 #endif 95 this->errno = error;133 this->errno = ENOMEM; 96 134 return -1; 97 135 } … … 101 139 case BARRIER_WAIT: 102 140 { 103 xptr_t barrier_xp = remote_barrier_from_ident( (intptr_t)vaddr );141 xptr_t barrier_xp = generic_barrier_from_ident( vaddr ); 104 142 105 143 if( barrier_xp == XPTR_NULL ) // user error … … 115 153 else // success 116 154 { 117 remote_barrier_wait( barrier_xp );155 generic_barrier_wait( barrier_xp ); 118 156 } 119 157 break; … … 122 160 case BARRIER_DESTROY: 123 161 { 124 xptr_t barrier_xp = remote_barrier_from_ident( (intptr_t)vaddr );162 xptr_t barrier_xp = generic_barrier_from_ident( vaddr ); 125 163 126 164 if( barrier_xp == XPTR_NULL ) // user error … … 136 174 else // success 137 175 { 138 remote_barrier_destroy( barrier_xp );176 generic_barrier_destroy( barrier_xp ); 139 177 } 140 178 break; … … 149 187 tm_end = hal_get_cycles(); 150 188 if( DEBUG_SYS_BARRIER < tm_end ) 151 printk("\n[ DBG] %s : thread %x in process %xexit for %s / cost %d / cycle %d\n",152 __FUNCTION__, this->trdid, process->pid, sys_barrier_op_str(operation),189 printk("\n[%s] thread[%x,%x] exit for %s / cost %d / cycle %d\n", 190 __FUNCTION__, process->pid, this->trdid, sys_barrier_op_str(operation), 153 191 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 154 192 #endif -
trunk/kernel/syscalls/sys_display.c
r614 r619 77 77 tm_start = hal_get_cycles(); 78 78 if( DEBUG_SYS_DISPLAY < tm_start ) 79 printk("\n[ DBG] %s :thread[%x,%x] enter / type %s / cycle = %d\n",79 printk("\n[%s] thread[%x,%x] enter / type %s / cycle = %d\n", 80 80 __FUNCTION__, process->pid, this->trdid, display_type_str(type), (uint32_t)tm_start ); 81 81 #endif … … 84 84 if( type == DISPLAY_STRING ) 85 85 { 86 char kbuf[ 256];86 char kbuf[512]; 87 87 uint32_t length; 88 88 … … 106 106 length = hal_strlen_from_uspace( string ); 107 107 108 if( length >= 256)108 if( length >= 512 ) 109 109 { 110 110 … … 118 118 119 119 // copy string to kernel space 120 hal_strcpy_from_uspace( kbuf , string , 256);120 hal_strcpy_from_uspace( kbuf , string , 512 ); 121 121 122 122 // print message on TXT0 kernel terminal … … 281 281 } 282 282 283 thread_display_busylocks( thread_xp );283 thread_display_busylocks( thread_xp , __FUNCTION__ ); 284 284 } 285 285 ///////////////////////////////// … … 388 388 #if DEBUG_SYS_DISPLAY 389 389 if( DEBUG_SYS_DISPLAY < tm_end ) 390 printk("\n[ DBG] %s :thread[%x,%x] exit / cycle %d\n",390 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 391 391 __FUNCTION__, process->pid, this->trdid, (uint32_t)tm_end ); 392 392 #endif -
trunk/kernel/syscalls/sys_exit.c
r584 r619 58 58 tm_start = hal_get_cycles(); 59 59 if( DEBUG_SYS_EXIT < tm_start ) 60 printk("\n[ DBG] %s :thread[%x,%x] enter / status %x / cycle %d\n",60 printk("\n[%s] thread[%x,%x] enter / status %x / cycle %d\n", 61 61 __FUNCTION__, process->pid, this->trdid , status , (uint32_t)tm_start ); 62 62 #endif … … 69 69 #if (DEBUG_SYS_EXIT & 1) 70 70 if( DEBUG_SYS_EXIT < tm_start ) 71 printk("\n[ DBG] %s :thread[%x,%x] get owner process in cluster %x\n",71 printk("\n[%s] thread[%x,%x] get owner process in cluster %x\n", 72 72 __FUNCTION__, process->pid, this->trdid, owner_cxy ); 73 73 #endif … … 83 83 #if (DEBUG_SYS_EXIT & 1) 84 84 if( DEBUG_SYS_EXIT < tm_start ) 85 printk("\n[ DBG] %s :thread[%x,%x] get parent process in cluster %x\n",85 printk("\n[%s] thread[%x,%x] get parent process in cluster %x\n", 86 86 __FUNCTION__, process->pid, this->trdid, parent_cxy ); 87 87 #endif … … 96 96 #if( DEBUG_SYS_EXIT & 1) 97 97 if( DEBUG_SYS_EXIT < tm_start ) 98 printk("\n[ DBG] %s :thread[%x,%x] detached process from TXT\n",98 printk("\n[%s] thread[%x,%x] detached process from TXT\n", 99 99 __FUNCTION__, process->pid, this->trdid ); 100 100 #endif … … 106 106 #if( DEBUG_SYS_EXIT & 1) 107 107 if( DEBUG_SYS_EXIT < tm_start ) 108 printk("\n[ DBG] %s :thread[%x,%x] deleted all threads but itself\n",108 printk("\n[%s] thread[%x,%x] deleted all threads but itself\n", 109 109 __FUNCTION__, process->pid, this->trdid ); 110 110 #endif … … 116 116 #if( DEBUG_SYS_EXIT & 1) 117 117 if( tm_start > DEBUG_SYS_EXIT ) 118 printk("\n[ DBG] %s :thread[%x,%x] marked iself for delete\n",118 printk("\n[%u] thread[%x,%x] marked iself for delete\n", 119 119 __FUNCTION__, process->pid, this->trdid ); 120 120 #endif … … 127 127 #if( DEBUG_SYS_EXIT & 1) 128 128 if( tm_start > DEBUG_SYS_EXIT ) 129 printk("\n[ DBG] %s :thread[%x,%x] blocked main thread\n",129 printk("\n[%s] thread[%x,%x] blocked main thread\n", 130 130 __FUNCTION__, process->pid, this->trdid ); 131 131 #endif … … 138 138 #if( DEBUG_SYS_EXIT & 1) 139 139 if( tm_start > DEBUG_SYS_EXIT ) 140 printk("\n[ DBG] %s :thread[%x,%x] set exit status %x in owner process\n",140 printk("\n[%s] thread[%x,%x] set exit status %x in owner process\n", 141 141 __FUNCTION__, process->pid, this->trdid, term_state ); 142 142 #endif … … 147 147 #if( DEBUG_SYS_EXIT & 1) 148 148 if( tm_start > DEBUG_SYS_EXIT ) 149 printk("\n[ DBG] %s :thread[%x,%x] unblocked parent main thread in process %x\n",149 printk("\n[%s] thread[%x,%x] unblocked parent main thread in process %x\n", 150 150 __FUNCTION__ , process->pid, this->trdid, 151 151 hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid) ) ); … … 157 157 tm_end = hal_get_cycles(); 158 158 if( DEBUG_SYS_EXIT < tm_end ) 159 printk("\n[ DBG] %s :thread[%x,%x] exit / status %x / cost = %d / cycle %d\n",159 printk("\n[%s] thread[%x,%x] exit / status %x / cost = %d / cycle %d\n", 160 160 __FUNCTION__, process->pid, this->trdid, status, 161 161 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); -
trunk/kernel/syscalls/sys_thread_create.c
r594 r619 70 70 if( DEBUG_SYS_THREAD_CREATE < tm_start ) 71 71 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", 72 __FUNCTION__, process _pid, parent->trdid, (uint32_t)tm_start );72 __FUNCTION__, process->pid, parent->trdid, (uint32_t)tm_start ); 73 73 #endif 74 74 -
trunk/kernel/syscalls/sys_thread_exit.c
r584 r619 64 64 uint64_t tm_start = hal_get_cycles(); 65 65 if( DEBUG_SYS_THREAD_EXIT < tm_start ) 66 printk("\n[ DBG] %s :thread[%x,%x] / main => delete process / cycle %d\n",66 printk("\n[%s] thread[%x,%x] / main => delete process / cycle %d\n", 67 67 __FUNCTION__ , pid , trdid , (uint32_t)tm_start ); 68 68 #endif … … 76 76 uint64_t tm_start = hal_get_cycles(); 77 77 if( DEBUG_SYS_THREAD_EXIT < tm_start ) 78 printk("\n[ DBG] %s :thread[%x,%x] / not main => delete thread / cycle %d\n",78 printk("\n[%s] thread[%x,%x] / not main => delete thread / cycle %d\n", 79 79 __FUNCTION__ , pid , trdid , (uint32_t)tm_start ); 80 80 #endif -
trunk/kernel/syscalls/syscalls.h
r611 r619 146 146 * The code implementting the operations is defined in the remote_barrier.c file. 147 147 ****************************************************************************************** 148 * @ vaddr : barrier virtualaddress in user space == identifier.148 * @ vaddr : barrier address in user space == identifier. 149 149 * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT. 150 * @ count : number of expected threads (only used by BARRIER_INIT operation). 151 * @ return 0 if success / return -1 if failure. 152 *****************************************************************************************/ 153 int sys_barrier( void * vaddr, 150 * @ count : number of expected threads (only used by BARRIER_INIT). 151 * @ attr : barrier attributes address in user space (only used by BARRIER_INIT). 152 * @ return 0 if success / return -1 if failure. 153 *****************************************************************************************/ 154 int sys_barrier( intptr_t vaddr, 154 155 uint32_t operation, 155 uint32_t count ); 156 uint32_t count, 157 intptr_t attr ); 156 158 157 159 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.