Ignore:
Timestamp:
Feb 14, 2018, 3:40:19 PM (4 years ago)
Author:
alain
Message:

blip

File:
1 edited

Legend:

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

    r428 r433  
    8989        spinlock_init( &cluster->kcm_lock );
    9090
    91 cluster_dmsg("\n[DBG] %s for cluster %x enters\n",
    92 __FUNCTION__ , local_cxy );
     91#if CONFIG_DEBUG_CLUSTER_INIT
     92uint32_t cycle = (uint32_t)hal_get_cycles();
     93if( CONFIG_DEBUG_CLUSTER_INIT < cycle )
     94printk("\n[DBG] %s enters for cluster %x / cycle %d\n",
     95__FUNCTION__ , local_cxy , cycle );
     96#endif
    9397
    9498    // initialises DQDT
     
    109113    }
    110114
    111 cluster_dmsg("\n[DBG] %s : PPM initialized in cluster %x at cycle %d\n",
    112 __FUNCTION__ , local_cxy , hal_get_cycles() );
     115#if CONFIG_DEBUG_CLUSTER_INIT
     116cycle = (uint32_t)hal_get_cycles();
     117if( CONFIG_DEBUG_CLUSTER_INIT < cycle )
     118cluster_dmsg("\n[DBG] %s : PPM initialized in cluster %x / cycle %d\n",
     119__FUNCTION__ , local_cxy , cycle );
     120#endif
    113121
    114122    // initialises embedded KHM
     
    132140        }
    133141
    134 cluster_dmsg("\n[DBG] %s : cores initialized in cluster %x at cycle %d\n",
    135 __FUNCTION__ , local_cxy , hal_get_cycles() );
     142#if CONFIG_DEBUG_CLUSTER_INIT
     143cycle = (uint32_t)hal_get_cycles();
     144if( CONFIG_DEBUG_CLUSTER_INIT < cycle )
     145cluster_dmsg("\n[DBG] %s : cores initialized in cluster %x / cycle %d\n",
     146__FUNCTION__ , local_cxy , cycle );
     147#endif
    136148
    137149    // initialises RPC fifo
     
    164176    }
    165177
    166 cluster_dmsg("\n[DBG] %s Process Manager initialized in cluster %x at cycle %d\n",
    167 __FUNCTION__ , local_cxy , hal_get_cycles() );
     178#if CONFIG_DEBUG_CLUSTER_INIT
     179cycle = (uint32_t)hal_get_cycles();
     180if( CONFIG_DEBUG_CLUSTER_INIT < cycle )
     181cluster_dmsg("\n[DBG] %s Process Manager initialized in cluster %x / cycle %d\n",
     182__FUNCTION__ , local_cxy , cycle );
     183#endif
    168184
    169185    hal_fence();
     
    215231//  Process related functions
    216232////////////////////////////////////////////////////////////////////////////////////
     233
     234
     235//////////////////////////////////////////////////////
     236xptr_t cluster_get_owner_process_from_pid( pid_t pid )
     237{
     238    xptr_t      root_xp;       // xptr on root of list of processes in owner cluster
     239    xptr_t      lock_xp;       // xptrr on lock protecting this list
     240    xptr_t      iter_xp;       // iterator
     241    xptr_t      current_xp;    // xptr on current process descriptor
     242    process_t * current_ptr;   // local pointer on current process
     243    pid_t       current_pid;   // current process identifier
     244    bool_t      found;
     245
     246    cluster_t * cluster = LOCAL_CLUSTER;
     247
     248    // get owner cluster and lpid
     249    cxy_t  owner_cxy = CXY_FROM_PID( pid );
     250
     251    // get lock & root of list of process in owner cluster
     252    root_xp = XPTR( owner_cxy , &cluster->pmgr.local_root );
     253    lock_xp = XPTR( owner_cxy , &cluster->pmgr.local_lock );
     254
     255    // take the lock protecting the list of processes
     256    remote_spinlock_lock( lock_xp );
     257
     258    // scan list of processes in owner cluster
     259    found = false;
     260    XLIST_FOREACH( root_xp , iter_xp )
     261    {
     262        current_xp  = XLIST_ELEMENT( iter_xp , process_t , local_list );
     263        current_ptr = GET_PTR( current_xp );
     264        current_pid = hal_remote_lw( XPTR( owner_cxy , &current_ptr->pid ) );
     265
     266        if( current_pid == pid )
     267        {
     268            found = true;
     269            break;
     270        }
     271    }
     272
     273    // release the lock protecting the list of processes
     274    remote_spinlock_unlock( lock_xp );
     275
     276    // return extended pointer on process descriptor in owner cluster
     277    if( found ) return current_xp;
     278    else        return XPTR_NULL;
     279}
    217280
    218281//////////////////////////////////////////////////////////
     
    442505
    443506    // skip one line
    444     printk("\n");
     507    printk("\n***** processes in cluster %x / cycle %d\n", cxy , (uint32_t)hal_get_cycles() );
    445508
    446509    // loop on all reference processes in cluster cxy
Note: See TracChangeset for help on using the changeset viewer.