Changeset 580 for trunk/kernel/kern/process.c
- Timestamp:
- Oct 8, 2018, 11:31:42 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/process.c
r564 r580 112 112 cxy_t chdev_cxy; 113 113 pid_t parent_pid; 114 lpid_t process_lpid; 115 lpid_t parent_lpid; 114 116 115 117 // get parent process cluster and local pointer … … 119 121 // get parent_pid 120 122 parent_pid = hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid ) ); 123 124 // get process and parent lpid 125 process_lpid = LPID_FROM_PID( pid ); 126 parent_lpid = LPID_FROM_PID( parent_pid ); 121 127 122 128 #if DEBUG_PROCESS_REFERENCE_INIT … … 150 156 151 157 // define the stdin/stdout/stderr pseudo files <=> select a TXT terminal. 152 if( (pid == 1) || (parent_pid == 1)) // INIT or KSH process 158 if( (process_lpid == 1) || // INIT process 159 (parent_lpid == 1) ) // KSH process 153 160 { 154 161 // allocate a TXT channel 155 if( p id == 1 ) txt_id = 0; // INIT156 else txt_id = process_txt_alloc(); // KSH162 if( process_lpid == 1 ) txt_id = 0; // INIT 163 else txt_id = process_txt_alloc(); // KSH 157 164 158 165 // attach process to TXT … … 1487 1494 void process_zero_create( process_t * process ) 1488 1495 { 1496 error_t error; 1497 pid_t pid; 1489 1498 1490 1499 #if DEBUG_PROCESS_ZERO_CREATE … … 1495 1504 #endif 1496 1505 1506 // get PID from local cluster manager for this kernel process 1507 error = cluster_pid_alloc( process , &pid ); 1508 1509 if( error || (LPID_FROM_PID( pid ) != 0) ) 1510 { 1511 printk("\n[PANIC] in %s : cannot get valid PID in cluster %x / PID = %x\n", 1512 __FUNCTION__ , local_cxy, pid ); 1513 hal_core_sleep(); 1514 } 1515 1497 1516 // initialize PID, REF_XP, PARENT_XP, and STATE 1498 process->pid = 0; 1517 // the kernel process_zero is its own parent_process, 1518 // reference_process, and owner_process, and cannot be killed... 1519 process->pid = pid; 1499 1520 process->ref_xp = XPTR( local_cxy , process ); 1500 1521 process->owner_xp = XPTR( local_cxy , process ); 1501 process->parent_xp = XPTR _NULL;1522 process->parent_xp = XPTR( local_cxy , process ); 1502 1523 process->term_state = 0; 1503 1524 … … 1518 1539 LOCK_PROCESS_CHILDREN ); 1519 1540 1541 // register kernel process in cluster manager local_list 1542 cluster_process_local_link( process ); 1543 1520 1544 hal_fence(); 1521 1545 … … 1686 1710 pid_t pid; 1687 1711 pid_t ppid; 1712 lpid_t lpid; 1688 1713 uint32_t state; 1689 1714 uint32_t th_nr; … … 1707 1732 process_cxy = GET_CXY( process_xp ); 1708 1733 1709 // get PIDand state1734 // get process PID, LPID, and state 1710 1735 pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) ); 1736 lpid = LPID_FROM_PID( pid ); 1711 1737 state = hal_remote_l32( XPTR( process_cxy , &process_ptr->term_state ) ); 1712 1738 1713 // get PPID1739 // get process PPID 1714 1740 parent_xp = hal_remote_l64( XPTR( process_cxy , &process_ptr->parent_xp ) ); 1715 1741 parent_cxy = GET_CXY( parent_xp ); … … 1725 1751 owner_ptr = GET_PTR( owner_xp ); 1726 1752 1727 // get extended pointer on TXT_RX file descriptor attached to process 1728 txt_file_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->fd_array.array[0] ) ); 1729 1730 assert( (txt_file_xp != XPTR_NULL) , 1731 "process must be attached to one TXT terminal\n" ); 1732 1733 // get TXT_RX chdev pointers 1734 txt_chdev_xp = chdev_from_file( txt_file_xp ); 1735 txt_chdev_cxy = GET_CXY( txt_chdev_xp ); 1736 txt_chdev_ptr = GET_PTR( txt_chdev_xp ); 1737 1738 // get TXT_RX name and ownership 1739 hal_remote_strcpy( XPTR( local_cxy , txt_name ) , 1740 XPTR( txt_chdev_cxy , txt_chdev_ptr->name ) ); 1753 // get process TXT name and .elf name 1754 if( lpid ) // user process 1755 { 1756 1757 // get extended pointer on file descriptor associated to TXT_RX 1758 txt_file_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->fd_array.array[0] ) ); 1759 1760 assert( (txt_file_xp != XPTR_NULL) , 1761 "process must be attached to one TXT terminal\n" ); 1762 1763 // get TXT_RX chdev pointers 1764 txt_chdev_xp = chdev_from_file( txt_file_xp ); 1765 txt_chdev_cxy = GET_CXY( txt_chdev_xp ); 1766 txt_chdev_ptr = GET_PTR( txt_chdev_xp ); 1767 1768 // get TXT_RX name and ownership 1769 hal_remote_strcpy( XPTR( local_cxy , txt_name ) , 1770 XPTR( txt_chdev_cxy , txt_chdev_ptr->name ) ); 1741 1771 1742 txt_owner_xp = (xptr_t)hal_remote_l64( XPTR( txt_chdev_cxy, 1743 &txt_chdev_ptr->ext.txt.owner_xp ) ); 1744 1745 // get process .elf name 1746 elf_file_xp = hal_remote_l64( XPTR( process_cxy , &process_ptr->vfs_bin_xp ) ); 1747 elf_file_cxy = GET_CXY( elf_file_xp ); 1748 elf_file_ptr = (vfs_file_t *)GET_PTR( elf_file_xp ); 1749 elf_inode_ptr = (vfs_inode_t *)hal_remote_lpt( XPTR( elf_file_cxy , &elf_file_ptr->inode ) ); 1750 vfs_inode_get_name( XPTR( elf_file_cxy , elf_inode_ptr ) , elf_name ); 1772 txt_owner_xp = (xptr_t)hal_remote_l64( XPTR( txt_chdev_cxy, 1773 &txt_chdev_ptr->ext.txt.owner_xp ) ); 1774 1775 // get process .elf name 1776 elf_file_xp = hal_remote_l64( XPTR( process_cxy , &process_ptr->vfs_bin_xp ) ); 1777 elf_file_cxy = GET_CXY( elf_file_xp ); 1778 elf_file_ptr = GET_PTR( elf_file_xp ); 1779 elf_inode_ptr = hal_remote_lpt( XPTR( elf_file_cxy , &elf_file_ptr->inode ) ); 1780 vfs_inode_get_name( XPTR( elf_file_cxy , elf_inode_ptr ) , elf_name ); 1781 } 1782 else // kernel process_zero 1783 { 1784 // TXT name and .elf name are not registered in kernel process_zero 1785 strcpy( txt_name , "txt0_rx" ); 1786 txt_owner_xp = process_xp; 1787 strcpy( elf_name , "kernel.elf" ); 1788 } 1751 1789 1752 1790 // display process info
Note: See TracChangeset
for help on using the changeset viewer.