Changeset 435 for trunk/kernel/kern
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.c
r433 r435 39 39 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 40 40 41 #if CONFIG_READ_DEBUG 42 extern uint32_t enter_chdev_cmd; 43 extern uint32_t exit_chdev_cmd; 44 extern uint32_t enter_chdev_server; 45 extern uint32_t exit_chdev_server; 41 #if (CONFIG_DEBUG_SYS_READ & 1) 42 extern uint32_t enter_chdev_cmd_read; 43 extern uint32_t exit_chdev_cmd_read; 44 extern uint32_t enter_chdev_server_read; 45 extern uint32_t exit_chdev_server_read; 46 #endif 47 48 #if (CONFIG_DEBUG_SYS_WRITE & 1) 49 extern uint32_t enter_chdev_cmd_write; 50 extern uint32_t exit_chdev_cmd_write; 51 extern uint32_t enter_chdev_server_write; 52 extern uint32_t exit_chdev_server_write; 46 53 #endif 47 54 … … 123 130 uint32_t save_sr; // for critical section 124 131 125 #if CONFIG_READ_DEBUG 126 enter_chdev_cmd = hal_time_stamp(); 132 #if (CONFIG_DEBUG_SYS_READ & 1) 133 enter_chdev_cmd_read = (uint32_t)hal_get_cycles(); 134 #endif 135 136 #if (CONFIG_DEBUG_SYS_WRITE & 1) 137 enter_chdev_cmd_write = (uint32_t)hal_get_cycles(); 127 138 #endif 128 139 … … 178 189 if( different ) dev_pic_send_ipi( chdev_cxy , lid ); 179 190 191 // deschedule 192 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" ); 193 sched_yield("blocked on I/O"); 194 195 // exit critical section 196 hal_restore_irq( save_sr ); 197 180 198 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 181 199 cycle = (uint32_t)hal_get_cycles(); … … 185 203 #endif 186 204 187 // deschedule 188 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" ); 189 sched_yield("blocked on I/O"); 190 191 // exit critical section 192 hal_restore_irq( save_sr ); 193 194 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 195 cycle = (uint32_t)hal_get_cycles(); 196 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle ) 197 printk("\n[DBG] %s : client_thread %x (%s) resumes / cycle %d\n", 198 __FUNCTION__, this, thread_type_str(this->type) , cycle ); 199 #endif 200 201 #if CONFIG_READ_DEBUG 202 exit_chdev_cmd = hal_time_stamp(); 205 #if (CONFIG_DEBUG_SYS_READ & 1) 206 exit_chdev_cmd_read = (uint32_t)hal_get_cycles(); 207 #endif 208 209 #if (CONFIG_DEBUG_SYS_WRITE & 1) 210 exit_chdev_cmd_write = (uint32_t)hal_get_cycles(); 203 211 #endif 204 212 … … 240 248 remote_spinlock_unlock( lock_xp ); 241 249 242 chdev_dmsg("\n[DBG] %s : thread %x deschedule /cycle %d\n",243 __FUNCTION__ , server , hal_time_stamp() );244 245 250 // deschedule 246 251 sched_yield("I/O queue empty"); 247 248 chdev_dmsg("\n[DBG] %s : thread %x resume /cycle %d\n",249 __FUNCTION__ , server , hal_time_stamp() );250 251 252 } 252 253 else // waiting queue not empty 253 254 { 254 255 255 #if CONFIG_READ_DEBUG 256 enter_chdev_server = hal_time_stamp(); 257 #endif 256 #if (CONFIG_DEBUG_SYS_READ & 1) 257 enter_chdev_server_read = (uint32_t)hal_get_cycles(); 258 #endif 259 260 #if (CONFIG_DEBUG_SYS_WRITE & 1) 261 enter_chdev_server_write = (uint32_t)hal_get_cycles(); 262 #endif 263 258 264 // release lock 259 265 remote_spinlock_unlock( lock_xp ); … … 284 290 #endif 285 291 286 #if CONFIG_READ_DEBUG 287 exit_chdev_server = hal_time_stamp(); 292 #if (CONFIG_DEBUG_SYS_READ & 1) 293 exit_chdev_server_read = (uint32_t)hal_get_cycles(); 294 #endif 295 296 #if (CONFIG_DEBUG_SYS_WRITE & 1) 297 exit_chdev_server_write = (uint32_t)hal_get_cycles(); 288 298 #endif 289 299 -
trunk/kernel/kern/kernel_init.c
r428 r435 123 123 124 124 125 // TODO remove these debug variables used dans sys_read()125 // these debug variables are used to analyse the sys_read() syscall timing 126 126 127 127 #if CONFIG_READ_DEBUG … … 129 129 uint32_t exit_sys_read; 130 130 131 uint32_t enter_devfs_ move;132 uint32_t exit_devfs_ move;131 uint32_t enter_devfs_read; 132 uint32_t exit_devfs_read; 133 133 134 134 uint32_t enter_txt_read; 135 135 uint32_t exit_txt_read; 136 136 137 uint32_t enter_chdev_cmd; 138 uint32_t exit_chdev_cmd; 139 140 uint32_t enter_chdev_server; 141 uint32_t exit_chdev_server; 142 143 uint32_t enter_tty_cmd; 144 uint32_t exit_tty_cmd; 145 146 uint32_t enter_tty_isr; 147 uint32_t exit_tty_isr; 137 uint32_t enter_chdev_cmd_read; 138 uint32_t exit_chdev_cmd_read; 139 140 uint32_t enter_chdev_server_read; 141 uint32_t exit_chdev_server_read; 142 143 uint32_t enter_tty_cmd_read; 144 uint32_t exit_tty_cmd_read; 145 146 uint32_t enter_tty_isr_read; 147 uint32_t exit_tty_isr_read; 148 #endif 149 150 // these debug variables are used to analyse the sys_write() syscall timing 151 152 #if CONFIG_WRITE_DEBUG 153 uint32_t enter_sys_write; 154 uint32_t exit_sys_write; 155 156 uint32_t enter_devfs_write; 157 uint32_t exit_devfs_write; 158 159 uint32_t enter_txt_write; 160 uint32_t exit_txt_write; 161 162 uint32_t enter_chdev_cmd_write; 163 uint32_t exit_chdev_cmd_write; 164 165 uint32_t enter_chdev_server_write; 166 uint32_t exit_chdev_server_write; 167 168 uint32_t enter_tty_cmd_write; 169 uint32_t exit_tty_cmd_write; 170 171 uint32_t enter_tty_isr_write; 172 uint32_t exit_tty_isr_write; 148 173 #endif 149 174 -
trunk/kernel/kern/process.c
r433 r435 51 51 #include <elf.h> 52 52 #include <syscalls.h> 53 #include <s ignal.h>53 #include <shared_syscalls.h> 54 54 55 55 ////////////////////////////////////////////////////////////////////////////////////////// … … 114 114 // get model process cluster and local pointer 115 115 model_cxy = GET_CXY( model_xp ); 116 model_ptr = (process_t *)GET_PTR( model_xp );116 model_ptr = GET_PTR( model_xp ); 117 117 118 118 // get parent process cluster and local pointer 119 119 parent_cxy = GET_CXY( parent_xp ); 120 parent_ptr = (process_t *)GET_PTR( parent_xp );120 parent_ptr = GET_PTR( parent_xp ); 121 121 122 122 // get model_pid and parent_pid … … 209 209 // get cluster and local pointer on chdev 210 210 chdev_cxy = GET_CXY( chdev_xp ); 211 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );211 chdev_ptr = GET_PTR( chdev_xp ); 212 212 213 213 // get TXT terminal index … … 289 289 // get reference process cluster and local pointer 290 290 cxy_t ref_cxy = GET_CXY( reference_process_xp ); 291 process_t * ref_ptr = (process_t *)GET_PTR( reference_process_xp );291 process_t * ref_ptr = GET_PTR( reference_process_xp ); 292 292 293 293 // initialize PID, REF_XP, PARENT_XP, and STATE … … 364 364 process_t * parent_ptr; 365 365 cxy_t parent_cxy; 366 xptr_t parent_thread_xp;367 366 xptr_t children_lock_xp; 368 367 xptr_t copies_lock_xp; … … 450 449 } 451 450 452 //////////////////////////////////////// ////453 void process_sigaction( p rocess_t * process,451 //////////////////////////////////////// 452 void process_sigaction( pid_t pid, 454 453 uint32_t action_type ) 455 454 { … … 467 466 rpc_desc_t rpc; // rpc descriptor allocated in stack 468 467 468 thread_t * client = CURRENT_THREAD; 469 469 470 #if CONFIG_DEBUG_PROCESS_SIGACTION 470 471 uint32_t cycle = (uint32_t)hal_get_cycles(); 471 472 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 472 printk("\n[DBG] %s : thread %x enter to %s process %x in cluster %x / cycle %d\n", 473 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) , 474 process->pid , local_cxy , cycle ); 475 #endif 476 477 thread_t * client = CURRENT_THREAD; 473 printk("\n[DBG] %s : thread %x enter to %s process %x / cycle %d\n", 474 __FUNCTION__ , client, process_action_str( action_type ) , pid , cycle ); 475 #endif 478 476 479 477 // get local pointer on local cluster manager … … 481 479 482 480 // get owner cluster identifier and process lpid 483 owner_cxy = CXY_FROM_PID( p rocess->pid );484 lpid = LPID_FROM_PID( p rocess->pid );485 486 // checkowner cluster487 assert( (owner_cxy == local_cxy) , __FUNCTION__ , "must be executed in owner cluster\n" );488 489 // get number of remote copies490 responses = cluster->pmgr.copies_nr[lpid] - 1; 481 owner_cxy = CXY_FROM_PID( pid ); 482 lpid = LPID_FROM_PID( pid ); 483 484 // get root of list of copies, lock, and number of copies from owner cluster 485 responses = hal_remote_lw ( XPTR( owner_cxy , &cluster->pmgr.copies_nr[lpid] ) ); 486 root_xp = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ) ); 487 lock_xp = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ) ); 488 491 489 rsp_count = 0; 492 490 … … 502 500 rpc.thread = client; 503 501 504 // get extended pointers on copies root and lock505 root_xp = XPTR( local_cxy , &cluster->pmgr.copies_root[lpid] );506 lock_xp = XPTR( local_cxy , &cluster->pmgr.copies_lock[lpid] );507 508 502 // take the lock protecting the copies 509 503 remote_spinlock_lock( lock_xp ); … … 514 508 process_xp = XLIST_ELEMENT( iter_xp , process_t , copies_list ); 515 509 process_cxy = GET_CXY( process_xp ); 516 process_ptr = (process_t *)GET_PTR( process_xp ); 517 518 // send RPC to remote clusters 519 if( process_cxy != local_cxy ) 520 { 510 process_ptr = GET_PTR( process_xp ); 521 511 522 512 #if CONFIG_DEBUG_PROCESS_SIGACTION 523 513 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 524 printk("\n[DBG] %s : send RPC to remote cluster %x\n", __FUNCTION__ , process_cxy ); 525 #endif 526 527 rpc.args[0] = (uint64_t)action_type; 528 rpc.args[1] = (uint64_t)(intptr_t)process_ptr; 529 rpc_process_sigaction_client( process_cxy , &rpc ); 530 rsp_count++; 531 } 514 printk("\n[DBG] %s : send RPC to cluster %x\n", __FUNCTION__ , process_cxy ); 515 #endif 516 517 // check PID 518 assert( (hal_remote_lw( XPTR( process_cxy , &process_ptr->pid) ) == pid), 519 __FUNCTION__ , "unconsistent PID value\n" ); 520 521 rpc.args[0] = (uint64_t)action_type; 522 rpc.args[1] = (uint64_t)pid; 523 rpc_process_sigaction_client( process_cxy , &rpc ); 524 rsp_count++; 532 525 } 533 526 … … 540 533 rsp_count , responses ); 541 534 542 // block and deschedule to wait RPC responses if required 543 if( responses ) 544 { 545 thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC ); 546 sched_yield("BLOCKED on RPC_PROCESS_SIGACTION"); 547 } 548 549 #if CONFIG_DEBUG_PROCESS_SIGACTION 550 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 551 printk("\n[DBG] %s : make action in owner cluster %x\n", __FUNCTION__ , local_cxy ); 552 #endif 553 554 // call directly the relevant function in local owner cluster 555 if (action_type == DELETE_ALL_THREADS ) process_delete_threads ( process ); 556 else if (action_type == BLOCK_ALL_THREADS ) process_block_threads ( process ); 557 else if (action_type == UNBLOCK_ALL_THREADS ) process_unblock_threads( process ); 535 // block and deschedule to wait RPC responses 536 thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC ); 537 sched_yield("BLOCKED on RPC_PROCESS_SIGACTION"); 558 538 559 539 #if CONFIG_DEBUG_PROCESS_SIGACTION … … 561 541 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 562 542 printk("\n[DBG] %s : thread %x exit after %s process %x in cluster %x / cycle %d\n", 563 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,543 __FUNCTION__ , client, process_action_str( action_type ) , 564 544 process->pid , local_cxy , cycle ); 565 545 #endif … … 778 758 { 779 759 process_xp = XLIST_ELEMENT( iter , process_t , local_list ); 780 process_ptr = (process_t *)GET_PTR( process_xp );760 process_ptr = GET_PTR( process_xp ); 781 761 if( process_ptr->pid == pid ) 782 762 { … … 838 818 839 819 // get reference process cluster and local pointer 840 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );820 process_t * ref_ptr = GET_PTR( ref_xp ); 841 821 cxy_t ref_cxy = GET_CXY( ref_xp ); 842 822 … … 858 838 // get reference process cluster and local pointer 859 839 xptr_t ref_xp = process->ref_xp; 860 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );840 process_t * ref_ptr = GET_PTR( ref_xp ); 861 841 cxy_t ref_cxy = GET_CXY( ref_xp ); 862 842 … … 900 880 xptr_t ref_xp = process->ref_xp; 901 881 cxy_t ref_cxy = GET_CXY( ref_xp ); 902 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );882 process_t * ref_ptr = GET_PTR( ref_xp ); 903 883 904 884 // access reference process descriptor … … 925 905 // get cluster and local pointer for src fd_array 926 906 cxy_t src_cxy = GET_CXY( src_xp ); 927 fd_array_t * src_ptr = (fd_array_t *)GET_PTR( src_xp );907 fd_array_t * src_ptr = GET_PTR( src_xp ); 928 908 929 909 // get cluster and local pointer for dst fd_array 930 910 cxy_t dst_cxy = GET_CXY( dst_xp ); 931 fd_array_t * dst_ptr = (fd_array_t *)GET_PTR( dst_xp );911 fd_array_t * dst_ptr = GET_PTR( dst_xp ); 932 912 933 913 // get the remote lock protecting the src fd_array … … 1044 1024 // get cluster and local pointer for parent process 1045 1025 cxy_t parent_process_cxy = GET_CXY( parent_process_xp ); 1046 process_t * parent_process_ptr = (process_t *)GET_PTR( parent_process_xp );1026 process_t * parent_process_ptr = GET_PTR( parent_process_xp ); 1047 1027 1048 1028 // get parent process PID and extended pointer on .elf file … … 1349 1329 } // end process_make_exec() 1350 1330 1351 ////////////////////////////////////////////1352 void process_make_kill( process_t * process,1353 bool_t is_exit,1354 uint32_t exit_status )1355 {1356 thread_t * this = CURRENT_THREAD;1357 1358 assert( (CXY_FROM_PID( process->pid ) == local_cxy) , __FUNCTION__ ,1359 "must be executed in process owner cluster\n" );1360 1361 assert( ( this->type == THREAD_RPC ) , __FUNCTION__ ,1362 "must be executed by an RPC thread\n" );1363 1364 #if CONFIG_DEBUG_PROCESS_MAKE_KILL1365 uint32_t cycle = (uint32_t)hal_get_cycles();1366 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )1367 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",1368 __FUNCTION__, this , process->pid , cycle );1369 #endif1370 1371 // register exit_status in owner process descriptor1372 if( is_exit ) process->term_state = exit_status;1373 1374 // atomically update owner process descriptor flags1375 if( is_exit ) hal_atomic_or( &process->term_state , PROCESS_FLAG_EXIT );1376 else hal_atomic_or( &process->term_state , PROCESS_FLAG_KILL );1377 1378 // remove TXT ownership from owner process descriptor1379 process_txt_reset_ownership( XPTR( local_cxy , process ) );1380 1381 // block all process threads in all clusters1382 process_sigaction( process , BLOCK_ALL_THREADS );1383 1384 // mark all process threads in all clusters for delete1385 process_sigaction( process , DELETE_ALL_THREADS );1386 1387 /* unused if sys_wait deschedules without blocking [AG]1388 1389 // get cluster and pointers on reference parent process1390 xptr_t parent_xp = process->parent_xp;1391 process_t * parent_ptr = GET_PTR( parent_xp );1392 cxy_t parent_cxy = GET_CXY( parent_xp );1393 1394 // get loal pointer on parent main thread1395 thread_t * main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );1396 1397 // reset THREAD_BLOCKED_WAIT bit in parent process main thread1398 thread_unblock( XPTR( parent_cxy , main_ptr ) , THREAD_BLOCKED_WAIT );1399 */1400 1401 #if CONFIG_DEBUG_PROCESS_MAKE_KILL1402 cycle = (uint32_t)hal_get_cycles();1403 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )1404 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",1405 __FUNCTION__, this, process->pid , cycle );1406 #endif1407 1408 } // end process_make_kill()1409 1410 1331 /////////////////////////////////////////////// 1411 1332 void process_zero_create( process_t * process ) … … 1679 1600 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1680 1601 printk("\n[DBG] %s : thread %x enter for process %x / txt_id = %d / cycle %d\n", 1681 __FUNCTION__, CURRENT_THREAD, process ->pid, txt_id, cycle );1602 __FUNCTION__, CURRENT_THREAD, process, txt_id, cycle ); 1682 1603 #endif 1683 1604 … … 1708 1629 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1709 1630 printk("\n[DBG] %s : thread %x exit for process %x / txt_id = %d / cycle %d\n", 1710 __FUNCTION__, CURRENT_THREAD, process ->pid, txt_id , cycle );1631 __FUNCTION__, CURRENT_THREAD, process, txt_id , cycle ); 1711 1632 #endif 1712 1633 … … 1721 1642 xptr_t lock_xp; // extended pointer on list lock in chdev 1722 1643 1723 #if CONFIG_DEBUG_PROCESS_TXT_ DETACH1644 #if CONFIG_DEBUG_PROCESS_TXT_ATTACH 1724 1645 uint32_t cycle = (uint32_t)hal_get_cycles(); 1725 if( CONFIG_DEBUG_PROCESS_TXT_ DETACH < cycle )1646 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1726 1647 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n", 1727 __FUNCTION__, CURRENT_THREAD, process ->pid, cycle );1648 __FUNCTION__, CURRENT_THREAD, process, cycle ); 1728 1649 #endif 1729 1650 … … 1745 1666 remote_spinlock_unlock( lock_xp ); 1746 1667 1747 #if CONFIG_DEBUG_PROCESS_TXT_ DETACH1748 cycle = (uint32_t)hal_get_cycles(); 1749 if( CONFIG_DEBUG_PROCESS_TXT_ DETACH < cycle )1668 #if CONFIG_DEBUG_PROCESS_TXT_ATTACH 1669 cycle = (uint32_t)hal_get_cycles(); 1670 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1750 1671 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n", 1751 __FUNCTION__, CURRENT_THREAD, process ->pid, cycle );1672 __FUNCTION__, CURRENT_THREAD, process, cycle ); 1752 1673 #endif 1753 1674 … … 1766 1687 // get cluster and local pointer on process 1767 1688 process_cxy = GET_CXY( process_xp ); 1768 process_ptr = (process_t *)GET_PTR( process_xp );1689 process_ptr = GET_PTR( process_xp ); 1769 1690 1770 1691 // get extended pointer on stdin pseudo file … … 1774 1695 txt_xp = chdev_from_file( file_xp ); 1775 1696 txt_cxy = GET_CXY( txt_xp ); 1776 txt_ptr = (chdev_t *)GET_PTR( txt_xp );1697 txt_ptr = GET_PTR( txt_xp ); 1777 1698 1778 1699 // set owner field in TXT chdev … … 1804 1725 // get cluster and local pointer on process 1805 1726 process_cxy = GET_CXY( process_xp ); 1806 process_ptr = (process_t *)GET_PTR( process_xp );1727 process_ptr = GET_PTR( process_xp ); 1807 1728 1808 1729 // get extended pointer on stdin pseudo file … … 1831 1752 current_ptr = GET_PTR( current_xp ); 1832 1753 parent_xp = hal_remote_lwd( XPTR( current_cxy , ¤t_ptr->parent_xp ) ); 1833 1834 1754 parent_cxy = GET_CXY( parent_xp ); 1835 1755 parent_ptr = GET_PTR( parent_xp ); 1836 1756 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 1757 1758 printk("\n@@@ %s : pid = %x / process = %x\n", __FUNCTION__ , current_ptr->pid, current_ptr ); 1837 1759 1838 1760 if( ppid == 1 ) // current is KSH … … 1849 1771 1850 1772 1851 1773 ////////////////////////////////////////////////////// 1774 inline pid_t process_get_txt_owner( uint32_t channel ) 1775 { 1776 xptr_t txt_rx_xp = chdev_dir.txt_rx[channel]; 1777 cxy_t txt_rx_cxy = GET_CXY( txt_rx_xp ); 1778 chdev_t * txt_rx_ptr = GET_PTR( txt_rx_xp ); 1779 1780 xptr_t process_xp = (xptr_t)hal_remote_lwd( XPTR( txt_rx_cxy, 1781 &txt_rx_ptr->ext.txt.owner_xp ) ); 1782 1783 cxy_t process_cxy = GET_CXY( process_xp ); 1784 process_t * process_ptr = GET_PTR( process_xp ); 1785 1786 return (pid_t)hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1787 } 1788 1789 /////////////////////////////////////////// 1790 void process_txt_display( uint32_t txt_id ) 1791 { 1792 xptr_t chdev_xp; 1793 cxy_t chdev_cxy; 1794 chdev_t * chdev_ptr; 1795 xptr_t root_xp; 1796 xptr_t lock_xp; 1797 xptr_t current_xp; 1798 xptr_t iter_xp; 1799 1800 // check terminal index 1801 assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) , 1802 __FUNCTION__ , "illegal TXT terminal index" ); 1803 1804 // get pointers on TXT_RX[txt_id] chdev 1805 chdev_xp = chdev_dir.txt_rx[txt_id]; 1806 chdev_cxy = GET_CXY( chdev_xp ); 1807 chdev_ptr = GET_PTR( chdev_xp ); 1808 1809 // get extended pointer on root & lock of attached process list 1810 root_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.root ); 1811 lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock ); 1812 1813 // display header 1814 printk("\n***** processes attached to TXT_%d\n", txt_id ); 1815 1816 // get lock 1817 remote_spinlock_lock( lock_xp ); 1818 1819 // scan attached process list to find KSH process 1820 XLIST_FOREACH( root_xp , iter_xp ) 1821 { 1822 current_xp = XLIST_ELEMENT( iter_xp , process_t , txt_list ); 1823 process_display( current_xp ); 1824 } 1825 1826 // release lock 1827 remote_spinlock_unlock( lock_xp ); 1828 1829 } // end process_txt_display -
trunk/kernel/kern/process.h
r433 r435 36 36 #include <hal_atomic.h> 37 37 #include <vmm.h> 38 #include <signal.h>39 38 #include <cluster.h> 40 39 #include <vfs.h> … … 63 62 DELETE_ALL_THREADS = 33, 64 63 }; 65 66 /*********************************************************************************************67 * The termination state is a 32 bits word:68 * - the 8 LSB bits contain the user defined exit status69 * - the 24 other bits contain the flags defined below70 ********************************************************************************************/71 72 #define PROCESS_FLAG_BLOCK 0x100 /*! process received as SIGSTOP signal */73 #define PROCESS_FLAG_KILL 0x200 /*! process terminated by a sys_kill() */74 #define PROCESS_FLAG_EXIT 0x400 /*! process terminated by a sys_exit() */75 #define PROCESS_FLAG_WAIT 0x800 /*! parent process executed successfully a sys_wait() */76 64 77 65 /********************************************************************************************* … … 291 279 292 280 /********************************************************************************************* 293 * This function allows a client thread running in the owner cluster of a process identified294 * by the <process> argument to block, unblock or delete all threads of the target process,295 * depending on the<action_type> argument. The scenario is the following:281 * This function allows a client thread running in any cluster to block, unblock or delete 282 * all threads of a process identified by the <pid> argument, depending on the 283 * <action_type> argument. The scenario is the following: 296 284 * - It uses the multicast, non blocking rpc_process_sigaction_client() function to send 297 285 * parallel requests to all remote clusters containing a process copy. Then it blocks … … 305 293 * It is used by the sys_kill() & sys_exit() functions to handle the "kill" & "exit" syscalls. 306 294 * It is also used by the process_make_exec() function to handle the "exec" syscall. 307 * WARNING : the DELETE and the BLOCK actions are NOT executed on the client thread. 308 ********************************************************************************************* 309 * @ process : pointer on the process descriptor in owner cluster. 295 * It is also called by the TXT device to execute the ctrl C & ctrl Z commands. 296 * WARNING : the DELETE action is NOT executed on the main thread (thread 0 in owner cluster). 297 ********************************************************************************************* 298 * @ pid : target process identifier. 310 299 * @ action_type : BLOCK_ALL_THREADS / UNBLOCK_ALL_THREADS / DELETE_ALL_THREADS 311 300 ********************************************************************************************/ 312 void process_sigaction( p rocess_t * process,301 void process_sigaction( pid_t pid, 313 302 uint32_t action_type ); 314 303 … … 403 392 struct thread_s ** child_thread_ptr ); 404 393 405 /*********************************************************************************************406 * This function is called by both the sys_kill() and sys_exit() system calls.407 * It must be executed by an RPC thread running in the target process owner cluster.408 * It uses twice the process_sigaction() function:409 * - first, to block all target process threads, in all clusters.410 * - second, to delete all target process threads in all clusters.411 * Finally, it synchronizes with the parent process sys_wait() function that MUST be called412 * by the parent process main thread.413 *********************************************************************************************414 * @ process : pointer on process descriptor in owner cluster.415 * @ is_exit : true when called by sys_exit() / false when called by sys_kill().416 * @ exit_status : exit status, when called by sys_exit().417 ********************************************************************************************/418 void process_make_kill( process_t * process,419 bool_t is_exit,420 uint32_t exit_status );421 422 394 423 395 /******************** File Management Operations ****************************************/ … … 573 545 void process_txt_reset_ownership( xptr_t process_xp ); 574 546 547 /********************************************************************************************* 548 * This function returns the terminal owner process (foreground process) 549 * for a given TXT terminal identified by its <channel> index. 550 ********************************************************************************************* 551 * @ channel : TXT terminal channel. 552 * @ return owner process identifier. 553 ********************************************************************************************/ 554 pid_t process_get_txt_owner( uint32_t channel ); 555 556 /********************************************************************************************* 557 * This debug function diplays on the kernel terminal the list of processes attached 558 * to a given terminal identified by the <txt_id> argument. 559 ********************************************************************************************* 560 * @ txt_id : TXT terminal channel. 561 ********************************************************************************************/ 562 void process_txt_display( uint32_t txt_id ); 563 564 575 565 #endif /* _PROCESS_H_ */ -
trunk/kernel/kern/rpc.c
r433 r435 39 39 #include <vfs.h> 40 40 #include <fatfs.h> 41 #include <signal.h>42 41 #include <rpc.h> 43 42 … … 80 79 &rpc_process_make_fork_server, // 3 81 80 &rpc_undefined, // 4 unused slot 82 &rpc_ process_make_kill_server, // 581 &rpc_undefined, // 5 unused slot 83 82 &rpc_thread_user_create_server, // 6 84 83 &rpc_thread_kernel_create_server, // 7 … … 610 609 611 610 ///////////////////////////////////////////////////////////////////////////////////////// 612 // [5] Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking) 613 ///////////////////////////////////////////////////////////////////////////////////////// 614 615 /////////////////////////////////////////////////// 616 void rpc_process_make_kill_client( cxy_t cxy, 617 process_t * process, 618 bool_t is_exit, 619 uint32_t status ) 620 { 621 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 622 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 623 CURRENT_THREAD->core->lid , hal_time_stamp() ); 624 625 // initialise RPC descriptor header 626 rpc_desc_t rpc; 627 rpc.index = RPC_PROCESS_MAKE_KILL; 628 rpc.response = 1; 629 rpc.blocking = true; 630 631 // set input arguments in RPC descriptor 632 rpc.args[0] = (uint64_t)(intptr_t)process; 633 rpc.args[1] = (uint64_t)is_exit; 634 rpc.args[2] = (uint64_t)status; 635 636 // register RPC request in remote RPC fifo (blocking function) 637 rpc_send( cxy , &rpc ); 638 639 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 640 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 641 CURRENT_THREAD->core->lid , hal_time_stamp() ); 642 } 643 644 ////////////////////////////////////////////// 645 void rpc_process_make_kill_server( xptr_t xp ) 646 { 647 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 648 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 649 CURRENT_THREAD->core->lid , hal_time_stamp() ); 650 651 process_t * process; 652 bool_t is_exit; 653 uint32_t status; 654 655 // get client cluster identifier and pointer on RPC descriptor 656 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 657 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 658 659 // get arguments from RPC descriptor 660 process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 661 is_exit = (bool_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 662 status = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 663 664 // call local kernel function 665 process_make_kill( process , is_exit , status ); 666 667 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 668 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 669 CURRENT_THREAD->core->lid , hal_time_stamp() ); 670 } 611 // [5] undefined slot 612 ///////////////////////////////////////////////////////////////////////////////////////// 671 613 672 614 ///////////////////////////////////////////////////////////////////////////////////////// … … 906 848 rpc_desc_t * rpc_ptr ) 907 849 { 908 sigaction_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",850 rpc_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n", 909 851 __FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) , 910 852 ((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() ); … … 913 855 rpc_send( cxy , rpc_ptr ); 914 856 915 sigaction_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",857 rpc_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n", 916 858 __FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) , 917 859 ((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() ); … … 921 863 void rpc_process_sigaction_server( xptr_t xp ) 922 864 { 865 pid_t pid; // target process identifier 923 866 process_t * process; // pointer on local process descriptor 924 867 uint32_t action; // sigaction index … … 934 877 935 878 // get arguments from RPC descriptor 936 action = (uint32_t) 937 p rocess = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) );879 action = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &rpc->args[0] ) ); 880 pid = (pid_t) hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) ); 938 881 client_ptr = (thread_t *)hal_remote_lpt( XPTR( client_cxy , &rpc->thread ) ); 882 883 rpc_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n", 884 __FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() ); 885 886 // get local process descriptor 887 process = process_get_local_copy( pid ); 939 888 940 889 // build extended pointer on client thread 941 890 client_xp = XPTR( client_cxy , client_ptr ); 942 943 sigaction_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n",944 __FUNCTION__ , process_action_str( action ) , process->pid , (uint32_t)hal_get_cycles() );945 891 946 892 // call relevant kernel function … … 958 904 } 959 905 960 sigaction_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n",961 __FUNCTION__ , process_action_str( action ) , p rocess->pid , (uint32_t)hal_get_cycles() );906 rpc_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n", 907 __FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() ); 962 908 } 963 909 -
trunk/kernel/kern/rpc.h
r433 r435 32 32 #include <vseg.h> 33 33 #include <remote_fifo.h> 34 #include <signal.h>35 34 36 35 /**** Forward declarations ****/ … … 65 64 RPC_PROCESS_MAKE_FORK = 3, 66 65 RPC_UNDEFINED_4 = 4, 67 RPC_ PROCESS_MAKE_KILL= 5,66 RPC_UNDEFINED_5 = 5, 68 67 RPC_THREAD_USER_CREATE = 6, 69 68 RPC_THREAD_KERNEL_CREATE = 7, … … 242 241 243 242 /*********************************************************************************** 244 * [5] The RPC_PROCESS_MAKE_KILL can be called by any thread to request the owner 245 * cluster to execute the process_make_kill() function for a target process. 246 *********************************************************************************** 247 * @ cxy : owner cluster identifier. 248 * @ process : pointer on process in owner cluster. 249 * @ is_exit : true if called by sys_exit() / false if called by sys_kill() 250 * @ status : exit status (only when called by sys_exit() 251 **********************************************************************************/ 252 void rpc_process_make_kill_client( cxy_t cxy, 253 struct process_s * process, 254 bool_t is_exit, 255 uint32_t status ); 256 257 void rpc_process_make_kill_server( xptr_t xp ); 243 * [5] undefined slot 244 **********************************************************************************/ 258 245 259 246 /*********************************************************************************** … … 314 301 /*********************************************************************************** 315 302 * [9] The RPC_PROCESS_SIGACTION allows the owner cluster to request any other 316 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all threads317 * of a given process.303 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all 304 * threads of a given process. 318 305 * 319 306 * WARNING : It is implemented as a NON BLOCKING multicast RPC, that can be sent -
trunk/kernel/kern/scheduler.c
r433 r435 280 280 } 281 281 282 // enter critical section / save SR in current thread context283 hal_disable_irq( & current->save_sr );282 // enter critical section / save SR in current thread descriptor 283 hal_disable_irq( &CURRENT_THREAD->save_sr ); 284 284 285 285 // loop on threads to select next thread … … 321 321 } 322 322 323 // switch CPU from c allingthread context to new thread context323 // switch CPU from current thread context to new thread context 324 324 hal_do_cpu_switch( current->cpu_context, next->cpu_context ); 325 325 } … … 330 330 uint32_t cycle = (uint32_t)hal_get_cycles(); 331 331 if( CONFIG_DEBUG_SCHED_YIELD < cycle ) 332 printk("\n[DBG] %s : core[%x,%d] / cause = %s / thread %x (%s) (%x,%x) continue / cycle %d\n", 332 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 333 " thread %x (%s) (%x,%x) continue / cycle %d\n", 333 334 __FUNCTION__, local_cxy, core->lid, cause, 334 335 current, thread_type_str(current->type), current->process->pid, current->trdid, cycle ); … … 340 341 sched_handle_signals( core ); 341 342 342 // exit critical section / restore SR from next thread context343 hal_restore_irq( next->save_sr );343 // exit critical section / restore SR from current thread descriptor 344 hal_restore_irq( CURRENT_THREAD->save_sr ); 344 345 345 346 } // end sched_yield() -
trunk/kernel/kern/signal.h
r409 r435 28 28 29 29 #include <hal_types.h> 30 31 #define SIG_DEFAULT (void*)0L32 #define SIG_IGNORE (void*)1L33 #define SIG_ERROR -1L34 35 #define SIGHUP 1 /*! hangup */36 #define SIGINT 2 /*! interrupt */37 #define SIGQUIT 3 /*! quit */38 #define SIGILL 4 /*! illegal instruction (not reset when caught) */39 #define SIGTRAP 5 /*! trace trap (not reset when caught) */40 #define SIGIOT 6 /*! IOT instruction */41 #define SIGABRT 6 /*! used by abort, replace SIGIOT in the future */42 #define SIGEMT 7 /*! EMT instruction */43 #define SIGFPE 8 /*! floating point exception */44 #define SIGKILL 9 /*! kill (cannot be caught or ignored) */45 #define SIGBUS 10 /*! bus error */46 #define SIGSEGV 11 /*! segmentation violation */47 #define SIGSYS 12 /*! bad argument to system call */48 #define SIGPIPE 13 /*! write on a pipe with no one to read it */49 #define SIGALRM 14 /*! alarm clock */50 #define SIGTERM 15 /*! software termination signal from kill */51 #define SIGURG 16 /*! urgent condition on IO channel */52 #define SIGSTOP 17 /*! sendable stop signal not from tty */53 #define SIGTSTP 18 /*! stop signal from tty */54 #define SIGCONT 19 /*! continue a stopped process */55 #define SIGCHLD 20 /*! to parent on child stop or exit */56 #define SIGCLD 20 /*! System V name for SIGCHLD */57 #define SIGTTIN 21 /*! to readers pgrp upon background tty read */58 #define SIGTTOU 22 /*! like TTIN for output if (tp->t_local<OSTOP) */59 #define SIGIO 23 /*! input/output possible signal */60 #define SIGPOLL SIGIO /*! System V name for SIGIO */61 #define SIGXCPU 24 /*! exceeded CPU time limit */62 #define SIGXFSZ 25 /*! exceeded file size limit */63 #define SIGVTALRM 26 /*! virtual time alarm */64 #define SIGPROF 27 /*! profiling time alarm */65 #define SIGWINCH 28 /*! window changed */66 #define SIGLOST 29 /*! resource lost (eg, record-lock lost) */67 #define SIGUSR1 30 /*! user defined signal 1 */68 #define SIGUSR2 31 /*! user defined signal 2 */69 #define SIG_NR 32 /*! signal 0 implied */70 71 #define SIG_DEFAULT_MASK 0xFFEEFFFF72 30 73 31
Note: See TracChangeset
for help on using the changeset viewer.