Changeset 580 for trunk/kernel/kern


Ignore:
Timestamp:
Oct 8, 2018, 11:31:42 AM (6 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.

Location:
trunk/kernel/kern
Files:
5 edited

Legend:

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

    r564 r580  
    200200    cluster->pmgr.pref_nr = 0;
    201201    cluster->pmgr.pref_tbl[0] = XPTR( local_cxy , &process_zero );
    202     for( lpid = 1 ; lpid < CONFIG_MAX_PROCESS_PER_CLUSTER ; lpid++ )
     202    for( lpid = 0 ; lpid < CONFIG_MAX_PROCESS_PER_CLUSTER ; lpid++ )
    203203    {
    204204        cluster->pmgr.pref_tbl[lpid] = XPTR_NULL;
  • trunk/kernel/kern/kernel_init.c

    r577 r580  
    375375            // check channels
    376376            if( channels != 1 )
    377             printk("\n[PANIC] in %s : MMC device must be single channel\n", __FUNCTION__ );
     377            {
     378                printk("\n[PANIC] in %s : MMC device must be single channel\n",
     379                __FUNCTION__ );
     380                hal_core_sleep();
     381            }
    378382
    379383            // create chdev in local cluster
     
    386390            // check memory
    387391            if( chdev_ptr == NULL )
    388             printk("\n[PANIC] in %s : cannot create MMC chdev\n", __FUNCTION__ );
     392            {
     393                printk("\n[PANIC] in %s : cannot create MMC chdev\n",
     394                __FUNCTION__ );
     395                hal_core_sleep();
     396            }
    389397           
    390398            // make MMC specific initialisation
     
    427435                // check memory
    428436                if( chdev_ptr == NULL )
    429                 printk("\n[PANIC] in %s : cannot create DMA chdev\n", __FUNCTION__ );
     437                {
     438                    printk("\n[PANIC] in %s : cannot create DMA chdev\n",
     439                    __FUNCTION__ );
     440                    hal_core_sleep();
     441                }
    430442           
    431443                // make DMA specific initialisation
     
    503515        // check PIC device initialized
    504516        if( chdev_dir.pic == XPTR_NULL )
    505         printk("\n[PANIC] in %s : PIC device must be initialized first\n", __FUNCTION__ );
     517        {
     518            printk("\n[PANIC] in %s : PIC device must be initialized first\n",
     519            __FUNCTION__ );
     520            hal_core_sleep();
     521        }
    506522
    507523        // check external device functionnal type
    508524        if( (func != DEV_FUNC_IOB) && (func != DEV_FUNC_IOC) && (func != DEV_FUNC_TXT) &&
    509525            (func != DEV_FUNC_NIC) && (func != DEV_FUNC_FBF) )
    510         printk("\n[PANIC] in %s : undefined peripheral type\n", __FUNCTION__ );
     526        {
     527            printk("\n[PANIC] in %s : undefined peripheral type\n",
     528            __FUNCTION__ );
     529            hal_core_sleep();
     530        }
    511531
    512532        // loops on channels
     
    548568
    549569                    if( chdev == NULL )
    550                     printk("\n[PANIC] in %s : cannot allocate chdev for external device\n",
    551                     __FUNCTION__ );
     570                    {
     571                        printk("\n[PANIC] in %s : cannot allocate chdev\n",
     572                        __FUNCTION__ );
     573                        hal_core_sleep();
     574                    }
    552575
    553576                    // make device type specific initialisation
     
    646669    // check PIC existence
    647670    if( found == false )
    648     printk("\n[PANIC] in %s : PIC device not found\n", __FUNCTION__ );
     671    {
     672        printk("\n[PANIC] in %s : PIC device not found\n",
     673        __FUNCTION__ );
     674        hal_core_sleep();
     675    }
    649676
    650677    // allocate and initialize the PIC chdev in cluster 0
     
    657684    // check memory
    658685    if( chdev == NULL )
    659     printk("\n[PANIC] in %s : no memory for PIC chdev\n", __FUNCTION__ );
     686    {
     687        printk("\n[PANIC] in %s : no memory for PIC chdev\n",
     688        __FUNCTION__ );
     689        hal_core_sleep();
     690    }
    660691
    661692    // make PIC device type specific initialisation
     
    723754            else if((func == DEV_FUNC_NIC) && (is_rx != 0)) ptr = &iopic_input.nic_rx[channel];
    724755            else if( func == DEV_FUNC_IOB )                 ptr = &iopic_input.iob;
    725             else     printk("\n[PANIC] in %s : illegal source device for IOPIC input" );
     756            else
     757            {
     758                printk("\n[PANIC] in %s : illegal source device for IOPIC input\n",
     759                __FUNCTION__ );
     760                hal_core_sleep();
     761            }
    726762
    727763            // set one entry in all "iopic_input" structures
     
    814850                if     ( func == DEV_FUNC_MMC ) lapic_input.mmc = id;
    815851                else if( func == DEV_FUNC_DMA ) lapic_input.dma[channel] = id;
    816                 else     printk("\n[PANIC] in %s : illegal source device for LAPIC input" );
     852                else
     853                {
     854                    printk("\n[PANIC] in %s : illegal source device for LAPIC input\n",
     855                    __FUNCTION__ );
     856                    hal_core_sleep();
     857                }
    817858            }
    818859        }
     
    939980    // all cores check identifiers
    940981    if( error )
    941     printk("\n[PANIC] in %s : illegal core : gid %x / cxy %x / lid %d",
    942     __FUNCTION__, core_lid, core_cxy, core_lid );
     982    {
     983        printk("\n[PANIC] in %s : illegal core : gid %x / cxy %x / lid %d",
     984        __FUNCTION__, core_lid, core_cxy, core_lid );
     985        hal_core_sleep();
     986    }
    943987
    944988    // CP0 initializes cluster manager complex structures
     
    948992
    949993        if( error )
    950         printk("\n[PANIC] in %s : cannot initialize cluster manager in cluster %x\n",
    951         __FUNCTION__, local_cxy );
     994        {
     995             printk("\n[PANIC] in %s : cannot initialize cluster manager in cluster %x\n",
     996             __FUNCTION__, local_cxy );
     997             hal_core_sleep();
     998        }
    952999    }
    9531000
     
    10681115
    10691116            if( fatfs_ctx == NULL )
    1070             printk("\n[PANIC] in %s : cannot create FATFS context in cluster 0\n",
    1071             __FUNCTION__ );
     1117            {
     1118                printk("\n[PANIC] in %s : cannot create FATFS context in cluster 0\n",
     1119                __FUNCTION__ );
     1120                hal_core_sleep();
     1121            }
    10721122
    10731123            // 2. access boot device to initialize FATFS context
     
    10991149                                      &vfs_root_inode_xp );                // return
    11001150            if( error )
    1101             printk("\n[PANIC] in %s : cannot create VFS root inode in cluster 0\n",
    1102             __FUNCTION__ );
     1151            {
     1152                printk("\n[PANIC] in %s : cannot create VFS root inode in cluster 0\n",
     1153                __FUNCTION__ );
     1154                hal_core_sleep();
     1155            }
    11031156
    11041157            // 6. update the FATFS entry in vfs_context[] array
     
    11091162
    11101163            if( ((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster != 8 )
    1111             printk("\n[PANIC] in %s : illegal FATFS context in cluster 0\n",
    1112             __FUNCTION__ );
     1164            {
     1165                printk("\n[PANIC] in %s : illegal FATFS context in cluster 0\n",
     1166                __FUNCTION__ );
     1167                hal_core_sleep();
     1168            }
     1169               
    11131170        }
    11141171        else
     
    11161173            printk("\n[PANIC] in %s : unsupported VFS type in cluster 0\n",
    11171174            __FUNCTION__ );
     1175            hal_core_sleep();
    11181176        }
    11191177
     
    11531211            // check memory
    11541212            if( local_fatfs_ctx == NULL )
    1155             printk("\n[PANIC] in %s : cannot create FATFS context in cluster %x\n",
    1156             __FUNCTION__ , local_cxy );
     1213            {
     1214                printk("\n[PANIC] in %s : cannot create FATFS context in cluster %x\n",
     1215                __FUNCTION__ , local_cxy );
     1216                hal_core_sleep();
     1217            }
    11571218
    11581219            // 2. get local pointer on VFS context for FATFS
     
    11741235
    11751236            if( ((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster != 8 )
    1176             printk("\n[PANIC] in %s : illegal FATFS context in cluster %x\n",
    1177             __FUNCTION__ , local_cxy );
     1237            {
     1238                printk("\n[PANIC] in %s : illegal FATFS context in cluster %x\n",
     1239                __FUNCTION__ , local_cxy );
     1240                hal_core_sleep();
     1241            }
    11781242        }
    11791243
     
    12101274
    12111275        if( devfs_ctx == NULL )
    1212         printk("\n[PANIC] in %s : cannot create DEVFS context in cluster 0\n",
    1213         __FUNCTION__ , local_cxy );
     1276        {
     1277            printk("\n[PANIC] in %s : cannot create DEVFS context in cluster 0\n",
     1278            __FUNCTION__ , local_cxy );
     1279            hal_core_sleep();
     1280        }
    12141281
    12151282        // 2. initialize the DEVFS entry in the vfs_context[] array
  • 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
  • trunk/kernel/kern/thread.c

    r564 r580  
    12161216    xptr_t        lock_xp;             // extended pointer on lock protecting  this list
    12171217
     1218#if DEBUG_THREAD_GET_XPTR
     1219uint32_t cycle  = (uint32_t)hal_get_cycles();
     1220thread_t * this = CURRENT_THREAD;
     1221if( DEBUG_THREAD_GET_XPTR < cycle )
     1222printk("\n[DBG] %s : thread %x in process %x enters / pid %x / trdid %x / cycle %d\n",
     1223__FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
     1224#endif
     1225
    12181226    // get target cluster identifier and local thread identifier
    12191227    target_cxy         = CXY_FROM_TRDID( trdid );
     
    12351243    remote_queuelock_acquire( lock_xp );
    12361244
     1245#if( DEBUG_THREAD_GET_XPTR & 1 )
     1246if( DEBUG_THREAD_GET_XPTR < cycle )
     1247printk("\n[DBG]  %s : scan processes in cluster %x :\n", __FUNCTION__, target_cxy );
     1248#endif
     1249
    12371250    // scan the list of local processes in target cluster
    12381251    xptr_t  iter;
     
    12431256        target_process_ptr = GET_PTR( target_process_xp );
    12441257        target_process_pid = hal_remote_l32( XPTR( target_cxy , &target_process_ptr->pid ) );
     1258
     1259#if( DEBUG_THREAD_GET_XPTR & 1 )
     1260if( DEBUG_THREAD_GET_XPTR < cycle )
     1261printk(" - process %x\n", target_process_pid );
     1262#endif
     1263
    12451264        if( target_process_pid == pid )
    12461265        {
     
    12541273
    12551274    // check PID found
    1256     if( found == false ) return XPTR_NULL;
     1275    if( found == false )
     1276    {
     1277
     1278#if( DEBUG_THREAD_GET_XPTR & 1 )
     1279if( DEBUG_THREAD_GET_XPTR < cycle )
     1280printk("\n[DBG] %s : pid %x not found in cluster %x\n",
     1281__FUNCTION__, pid, target_cxy );
     1282#endif
     1283        return XPTR_NULL;
     1284    }
    12571285
    12581286    // get target thread local pointer
     
    12601288    target_thread_ptr = (thread_t *)hal_remote_lpt( xp );
    12611289
    1262     if( target_thread_ptr == NULL )  return XPTR_NULL;
     1290    if( target_thread_ptr == NULL )
     1291    {
     1292
     1293#if( DEBUG_THREAD_GET_XPTR & 1 )
     1294if( DEBUG_THREAD_GET_XPTR < cycle )
     1295printk("\n[DBG] %s : thread %x not registered in process %x in cluster %x\n",
     1296__FUNCTION__, trdid, pid, target_cxy );
     1297#endif
     1298        return XPTR_NULL;
     1299    }
     1300
     1301#if DEBUG_THREAD_GET_XPTR
     1302cycle  = (uint32_t)hal_get_cycles();
     1303if( DEBUG_THREAD_GET_XPTR < cycle )
     1304printk("\n[DBG] %s : thread %x in process %x exit / pid %x / trdid %x / cycle %d\n",
     1305__FUNCTION__, this->trdid, this->process->pid, pid, trdid, cycle );
     1306#endif
    12631307
    12641308    return XPTR( target_cxy , target_thread_ptr );
     
    12871331        // display error message on TXT0
    12881332        nolock_printk("\n[PANIC] in %s / thread %x in process %x [%x] cannot yield : "
    1289         "%d busylock(s) / cycle %d\n",
     1333        "hold %d busylock(s) / cycle %d\n",
    12901334        func_str, thread->trdid, thread->process->pid, thread,
    12911335        thread->busylocks, (uint32_t)hal_get_cycles() );
    12921336
    12931337#if DEBUG_BUSYLOCK
    1294 if( XPTR( local_cxy , thread ) == DEBUG_BUSYLOCK_THREAD_XP )
    1295 {
    1296     // get root of list of taken busylocks
    1297     xptr_t    root_xp  = XPTR( local_cxy , &thread->busylocks_root );
    1298     xptr_t    iter_xp;
    1299 
    1300     // scan list of busylocks
    1301     XLIST_FOREACH( root_xp , iter_xp )
    1302     {
    1303         xptr_t       lock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
    1304         cxy_t        lock_cxy  = GET_CXY( lock_xp );
    1305         busylock_t * lock_ptr  = GET_PTR( lock_xp );
    1306         uint32_t     lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) );
    1307         nolock_printk(" - %s in cluster %x\n", lock_type_str[lock_type] , lock_cxy );
    1308     }
     1338
     1339// get root of list of taken busylocks
     1340xptr_t    root_xp  = XPTR( local_cxy , &thread->busylocks_root );
     1341xptr_t    iter_xp;
     1342
     1343// scan list of busylocks
     1344XLIST_FOREACH( root_xp , iter_xp )
     1345{
     1346    xptr_t       lock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
     1347    cxy_t        lock_cxy  = GET_CXY( lock_xp );
     1348    busylock_t * lock_ptr  = GET_PTR( lock_xp );
     1349    uint32_t     lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) );
     1350    nolock_printk(" - %s in cluster %x\n", lock_type_str[lock_type] , lock_cxy );
    13091351}
     1352
    13101353#endif
    13111354
     
    13181361}  // end thread_assert_can yield()
    13191362
    1320 #if DEBUG_BUSYLOCK
    1321 
    1322 ////////////////////////////////////////////////////
    1323 void thread_display_busylocks( uint32_t   lock_type,
    1324                                bool_t     is_acquire )
    1325 {
    1326     xptr_t    iter_xp;
    1327 
    1328     // get cluster and local pointer of target thread
    1329     cxy_t      thread_cxy = GET_CXY( DEBUG_BUSYLOCK_THREAD_XP );
    1330     thread_t * thread_ptr = GET_PTR( DEBUG_BUSYLOCK_THREAD_XP );
    1331 
    1332     // get extended pointer on root of busylocks
    1333     xptr_t    root_xp = XPTR( thread_cxy , &thread_ptr->busylocks_root );
    1334 
    1335    // get pointers on TXT0 chdev
    1336     xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
    1337     cxy_t     txt0_cxy = GET_CXY( txt0_xp );
    1338     chdev_t * txt0_ptr = GET_PTR( txt0_xp );
    1339 
    1340     // get extended pointer on remote TXT0 lock
    1341     xptr_t  txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
    1342 
    1343     // get TXT0 lock
    1344     remote_busylock_acquire( txt0_lock_xp );
    1345 
    1346     if( is_acquire )
    1347     {
    1348         nolock_printk("\n### thread [%x,%x] ACQUIRE lock %s / root %x / locks :\n",
    1349         thread_cxy, thread_ptr, lock_type_str[lock_type], GET_PTR(root_xp) );
     1363//////////////////////////////////////////////////
     1364void thread_display_busylocks( xptr_t  thread_xp )
     1365{
     1366    if( DEBUG_BUSYLOCK )
     1367    {
     1368        xptr_t    iter_xp;
     1369
     1370        // get cluster and local pointer of target thread
     1371        cxy_t      thread_cxy = GET_CXY( thread_xp );
     1372        thread_t * thread_ptr = GET_PTR( thread_xp );
     1373
     1374        // get target thread TRDID and busylocks
     1375        trdid_t  trdid = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->trdid ));
     1376        uint32_t locks = hal_remote_l32(XPTR( thread_cxy , &thread_ptr->busylocks ));
     1377
     1378        // get target thread process and PID;
     1379        process_t * process = hal_remote_lpt(XPTR( thread_cxy , &thread_ptr->process ));
     1380        pid_t       pid     = hal_remote_l32(XPTR( thread_cxy , &process->pid ));
     1381
     1382        // get extended pointer on root of busylocks
     1383        xptr_t    root_xp = XPTR( thread_cxy , &thread_ptr->busylocks_root );
     1384
     1385        // get pointers on TXT0 chdev
     1386        xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     1387        cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     1388        chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     1389
     1390        // get extended pointer on remote TXT0 lock
     1391        xptr_t  txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     1392
     1393        // get TXT0 lock
     1394        remote_busylock_acquire( txt0_lock_xp );
     1395
     1396        // display header
     1397        nolock_printk("\n***** thread %x in process %x : %d busylocks at cycle %d\n",
     1398        trdid, pid, locks, (uint32_t)hal_get_cycles() );
     1399
     1400        // scan the xlist of busylocks when required
     1401        if( locks )
     1402        {
     1403            XLIST_FOREACH( root_xp , iter_xp )
     1404            {
     1405                xptr_t       lock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
     1406                cxy_t        lock_cxy  = GET_CXY( lock_xp );
     1407                busylock_t * lock_ptr  = GET_PTR( lock_xp );
     1408                uint32_t     lock_type = hal_remote_l32(XPTR( lock_cxy , &lock_ptr->type ));
     1409                nolock_printk(" - %s in cluster %x\n", lock_type_str[lock_type] , lock_cxy );
     1410            }
     1411        }
     1412
     1413        // release TXT0 lock
     1414        remote_busylock_release( txt0_lock_xp );
    13501415    }
    13511416    else
    13521417    {
    1353         nolock_printk("\n### thread [%x,%x] RELEASE lock %s / root %x / locks :\n",
    1354         thread_cxy, thread_ptr, lock_type_str[lock_type], GET_PTR(root_xp) );
    1355     }
    1356 
    1357     int i;
    1358 
    1359     XLIST_FOREACH( root_xp , iter_xp )
    1360     {
    1361         xptr_t       ilock_xp   = XLIST_ELEMENT( iter_xp , busylock_t , xlist );
    1362         cxy_t        ilock_cxy  = GET_CXY( ilock_xp );
    1363         busylock_t * ilock_ptr  = GET_PTR( ilock_xp );
    1364         uint32_t     ilock_type = hal_remote_l32( XPTR( ilock_cxy , &ilock_ptr->type ) );
    1365         nolock_printk(" - %s in cluster %x\n", lock_type_str[ilock_type] , ilock_cxy );
    1366     }
    1367 
    1368     // release TXT0 lock
    1369     remote_busylock_release( txt0_lock_xp );
    1370 }
    1371 #endif
     1418        // display a warning
     1419        printk("\n[WARNING] set the DEBUG_BUSYLOCK parmeter in kernel_config.h"
     1420        " to use the %s function\n", __FUNCTION__ );
     1421    }
     1422}  // end thread_display_busylock()
  • trunk/kernel/kern/thread.h

    r564 r580  
    467467
    468468/***************************************************************************************
    469  * This debug function display the list of busylocks currently owned by a thread
    470  * identified by the DEBUG_BUSYLOCK_THREAD_XP parameter.
    471  * It is called each time the target thread acquire or release a busylock
    472  * (local or remote). It is never called when DEBUG_BUSYLOCK_THEAD_CP == 0.
    473  ***************************************************************************************
    474  * @ lock_type  : type of acquired / released busylock.
    475  * @ is_acquire : change is an acquire when true / change is a release when false.
    476  **************************************************************************************/
    477 void thread_display_busylocks( uint32_t lock_type,
    478                                bool_t   is_acquire );
     469 * This debug function display the list of busylocks (local or remote) currently owned
     470 * by a thread identified by the <thread_xp> argument.
     471 * WARNING : it can be called by the idbg tool, but the DEBUG_BUSYLOCK parameter
     472 * must be set in the kernel_config.h file.
     473 ***************************************************************************************
     474 * @ thread_xp  : extended pointer on target thread.
     475 **************************************************************************************/
     476void thread_display_busylocks( xptr_t  thread_xp );
    479477
    480478
Note: See TracChangeset for help on using the changeset viewer.