Changeset 443 for trunk/kernel/kern/process.c
- Timestamp:
- May 16, 2018, 4:15:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/process.c
r441 r443 135 135 process->pid = pid; 136 136 process->ref_xp = XPTR( local_cxy , process ); 137 process->owner_xp = XPTR( local_cxy , process ); 137 138 process->parent_xp = parent_xp; 138 139 process->term_state = 0; … … 320 321 local_process->parent_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->parent_xp ) ); 321 322 local_process->ref_xp = reference_process_xp; 323 local_process->owner_xp = reference_process_xp; 322 324 local_process->term_state = 0; 323 325 … … 409 411 cluster_process_copies_unlink( process ); 410 412 411 // remove process from children_list if process is inowner cluster413 // remove process from children_list if process owner cluster 412 414 if( CXY_FROM_PID( pid ) == local_cxy ) 413 415 { … … 426 428 } 427 429 428 // release the process PID to cluster manager if owner cluster430 // release the process PID to cluster manager if process owner cluster 429 431 if( CXY_FROM_PID( pid ) == local_cxy ) cluster_pid_release( pid ); 430 432 … … 800 802 // allocate memory for local process descriptor 801 803 process_ptr = process_alloc(); 804 802 805 if( process_ptr == NULL ) return NULL; 803 806 804 807 // initialize local process descriptor copy 805 808 error = process_copy_init( process_ptr , ref_xp ); 809 806 810 if( error ) return NULL; 807 811 } … … 1021 1025 } 1022 1026 1023 1024 1027 // release lock protecting th_tbl 1025 1028 hal_fence(); … … 1030 1033 } // end process_register_thread() 1031 1034 1032 /////////////////////////////////////////////// 1033 void process_remove_thread( thread_t * thread ) 1034 { 1035 ///////////////////////////////////////////////// 1036 bool_t process_remove_thread( thread_t * thread ) 1037 { 1038 uint32_t count; // number of threads in local process descriptor 1039 1035 1040 assert( (thread != NULL) , __FUNCTION__ , "thread argument is NULL" ); 1036 1041 … … 1043 1048 spinlock_lock( &process->th_lock ); 1044 1049 1045 assert( (process->th_nr) , __FUNCTION__ , "process th_nr cannot be 0\n" ); 1050 count = process->th_nr; 1051 1052 assert( (count > 0) , __FUNCTION__ , "process th_nr cannot be 0\n" ); 1046 1053 1047 1054 // remove thread from th_tbl[] … … 1049 1056 process->th_nr--; 1050 1057 1058 // release lock protecting th_tbl 1051 1059 hal_fence(); 1052 1053 // release lock protecting th_tbl1054 1060 spinlock_unlock( &process->th_lock ); 1061 1062 return (count == 1); 1055 1063 1056 1064 } // process_remove_thread() … … 1401 1409 process->pid = 0; 1402 1410 process->ref_xp = XPTR( local_cxy , process ); 1411 process->owner_xp = XPTR( local_cxy , process ); 1403 1412 process->parent_xp = XPTR_NULL; 1404 1413 process->term_state = 0; … … 1531 1540 process_t * process_ptr; 1532 1541 cxy_t process_cxy; 1542 1533 1543 xptr_t parent_xp; // extended pointer on parent process 1534 1544 process_t * parent_ptr; 1535 1545 cxy_t parent_cxy; 1536 1546 1547 xptr_t owner_xp; // extended pointer on owner process 1548 process_t * owner_ptr; 1549 cxy_t owner_cxy; 1550 1537 1551 pid_t pid; 1538 1552 pid_t ppid; 1539 1553 uint32_t state; 1540 xptr_t ref_xp;1541 1554 uint32_t th_nr; 1542 1555 1543 xptr_t txt_file_xp; // extended pointer on TXT_RX pseudo file1544 xptr_t chdev_xp;// extended pointer on TXT_RX chdev1545 chdev_t * chdev_ptr;1546 cxy_t chdev_cxy;1547 xptr_t owner_xp;// extended pointer on TXT owner process1556 xptr_t txt_file_xp; // extended pointer on TXT_RX file descriptor 1557 xptr_t txt_chdev_xp; // extended pointer on TXT_RX chdev 1558 chdev_t * txt_chdev_ptr; 1559 cxy_t txt_chdev_cxy; 1560 xptr_t txt_owner_xp; // extended pointer on TXT owner process 1548 1561 1549 1562 xptr_t elf_file_xp; // extended pointer on .elf file … … 1558 1571 process_ptr = GET_PTR( process_xp ); 1559 1572 process_cxy = GET_CXY( process_xp ); 1560 1561 // check reference process1562 ref_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->ref_xp ) );1563 assert( (process_xp == ref_xp) , __FUNCTION__ , "process is not the reference\n");1564 1573 1565 1574 // get PID and state … … 1576 1585 th_nr = hal_remote_lw( XPTR( process_cxy , &process_ptr->th_nr ) ); 1577 1586 1578 // get TXT name and process owner 1579 txt_file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) ); 1587 // get pointers on owner process descriptor 1588 owner_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->owner_xp ) ); 1589 owner_cxy = GET_CXY( owner_xp ); 1590 owner_ptr = GET_PTR( owner_xp ); 1591 1592 // get extended pointer on TXT_RX file descriptor attached to process 1593 txt_file_xp = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->fd_array.array[0] ) ); 1580 1594 1581 1595 assert( (txt_file_xp != XPTR_NULL) , __FUNCTION__ , 1582 1596 "process must be attached to one TXT terminal\n" ); 1583 1597 1584 chdev_xp = chdev_from_file( txt_file_xp ); 1585 chdev_cxy = GET_CXY( chdev_xp ); 1586 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 1598 // get TXT_RX chdev pointers 1599 txt_chdev_xp = chdev_from_file( txt_file_xp ); 1600 txt_chdev_cxy = GET_CXY( txt_chdev_xp ); 1601 txt_chdev_ptr = GET_PTR( txt_chdev_xp ); 1602 1603 // get TXT_RX name and ownership 1587 1604 hal_remote_strcpy( XPTR( local_cxy , txt_name ) , 1588 XPTR( chdev_cxy , chdev_ptr->name ) ); 1589 owner_xp = (xptr_t)hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) ); 1605 XPTR( txt_chdev_cxy , txt_chdev_ptr->name ) ); 1606 1607 txt_owner_xp = (xptr_t)hal_remote_lwd( XPTR( txt_chdev_cxy, 1608 &txt_chdev_ptr->ext.txt.owner_xp ) ); 1590 1609 1591 1610 // get process .elf name 1592 1611 elf_file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->vfs_bin_xp ) ); 1593 1594 1612 elf_file_cxy = GET_CXY( elf_file_xp ); 1595 1613 elf_file_ptr = (vfs_file_t *)GET_PTR( elf_file_xp ); … … 1598 1616 1599 1617 // display process info 1600 if( owner_xp == process_xp )1601 { 1602 printk("PID %X | PPID %X | STS %X | %s (FG) | %X | %d | %s\n",1618 if( txt_owner_xp == process_xp ) 1619 { 1620 nolock_printk("PID %X | PPID %X | STS %X | %s (FG) | %X | %d | %s\n", 1603 1621 pid, ppid, state, txt_name, process_ptr, th_nr, elf_name ); 1604 1622 } 1605 1623 else 1606 1624 { 1607 printk("PID %X | PPID %X | STS %X | %s (BG) | %X | %d | %s\n",1625 nolock_printk("PID %X | PPID %X | STS %X | %s (BG) | %X | %d | %s\n", 1608 1626 pid, ppid, state, txt_name, process_ptr, th_nr, elf_name ); 1609 1627 } … … 1988 2006 xptr_t current_xp; 1989 2007 xptr_t iter_xp; 1990 1991 // check terminal index 2008 cxy_t txt0_cxy; 2009 chdev_t * txt0_ptr; 2010 xptr_t txt0_xp; 2011 xptr_t txt0_lock_xp; 2012 reg_t txt0_save_sr; // save SR to take TXT0 lock in busy mode 2013 1992 2014 assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) , 1993 2015 __FUNCTION__ , "illegal TXT terminal index" ); 2016 2017 // get pointers on TXT0 chdev 2018 txt0_xp = chdev_dir.txt_tx[0]; 2019 txt0_cxy = GET_CXY( txt0_xp ); 2020 txt0_ptr = GET_PTR( txt0_xp ); 2021 2022 // get extended pointer on TXT0 lock 2023 txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 1994 2024 1995 2025 // get pointers on TXT_RX[txt_id] chdev … … 2002 2032 lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock ); 2003 2033 2034 // get lock on attached process list 2035 remote_spinlock_lock( lock_xp ); 2036 2037 // get TXT0 lock in busy waiting mode 2038 remote_spinlock_lock_busy( txt0_lock_xp , &txt0_save_sr ); 2039 2004 2040 // display header 2005 printk("\n***** processes attached to TXT_%d\n", txt_id ); 2006 2007 // get lock 2008 remote_spinlock_lock( lock_xp ); 2041 nolock_printk("\n***** processes attached to TXT_%d / cycle %d\n", 2042 txt_id , (uint32_t)hal_get_cycles() ); 2009 2043 2010 2044 // scan attached process list … … 2015 2049 } 2016 2050 2017 // release lock 2051 // release TXT0 lock in busy waiting mode 2052 remote_spinlock_unlock_busy( txt0_lock_xp , txt0_save_sr ); 2053 2054 // release lock on attached process list 2018 2055 remote_spinlock_unlock( lock_xp ); 2019 2056
Note: See TracChangeset
for help on using the changeset viewer.