Ignore:
Timestamp:
Oct 8, 2018, 11:31:42 AM (3 years ago)
Author:
alain
Message:

1) Register the kernel process in the cluster manager local list.
2) Introduce a new service in idbg : display the set of busylocks taken by a given thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/process.c

    r564 r580  
    112112    cxy_t       chdev_cxy;
    113113    pid_t       parent_pid;
     114    lpid_t      process_lpid;
     115    lpid_t      parent_lpid;
    114116
    115117    // get parent process cluster and local pointer
     
    119121    // get parent_pid
    120122    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 );
    121127
    122128#if DEBUG_PROCESS_REFERENCE_INIT
     
    150156
    151157    // 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
    153160    {
    154161        // allocate a TXT channel
    155         if( pid == 1 )  txt_id = 0;                     // INIT
    156         else            txt_id = process_txt_alloc();   // KSH
     162        if( process_lpid == 1 )  txt_id = 0;                     // INIT
     163        else                     txt_id = process_txt_alloc();   // KSH
    157164
    158165        // attach process to TXT
     
    14871494void process_zero_create( process_t * process )
    14881495{
     1496    error_t error;
     1497    pid_t   pid;
    14891498
    14901499#if DEBUG_PROCESS_ZERO_CREATE
     
    14951504#endif
    14961505
     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
    14971516    // 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;
    14991520    process->ref_xp     = XPTR( local_cxy , process );
    15001521    process->owner_xp   = XPTR( local_cxy , process );
    1501     process->parent_xp  = XPTR_NULL;
     1522    process->parent_xp  = XPTR( local_cxy , process );
    15021523    process->term_state = 0;
    15031524
     
    15181539                           LOCK_PROCESS_CHILDREN );
    15191540
     1541    // register kernel process in cluster manager local_list
     1542    cluster_process_local_link( process );
     1543   
    15201544        hal_fence();
    15211545
     
    16861710    pid_t         pid;
    16871711    pid_t         ppid;
     1712    lpid_t        lpid;
    16881713    uint32_t      state;
    16891714    uint32_t      th_nr;
     
    17071732    process_cxy = GET_CXY( process_xp );
    17081733
    1709     // get PID and state
     1734    // get process PID, LPID, and state
    17101735    pid   = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) );
     1736    lpid  = LPID_FROM_PID( pid );
    17111737    state = hal_remote_l32( XPTR( process_cxy , &process_ptr->term_state ) );
    17121738
    1713     // get PPID
     1739    // get process PPID
    17141740    parent_xp  = hal_remote_l64( XPTR( process_cxy , &process_ptr->parent_xp ) );
    17151741    parent_cxy = GET_CXY( parent_xp );
     
    17251751    owner_ptr = GET_PTR( owner_xp );
    17261752
    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 ) );
    17411771   
    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    }
    17511789
    17521790    // display process info
Note: See TracChangeset for help on using the changeset viewer.