Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (5 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

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

    r19 r23  
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Mohamed Lamine Karaoui (2015)
    6  *         Alain Greiner (2016)
     6 *         Alain Greiner (2016,2017)
    77 *
    88 * Copyright (c) UPMC Sorbonne Universites
     
    4949///////////////////////////////////////////////////////////////////////////////////////////
    5050
    51 process_t process_zero;     // allocated in kernel_init.c file
     51extern process_t process_zero;     // allocated in kernel_init.c file
    5252
    5353
     
    121121
    122122    // initialise local_list in process manager
    123         spinlock_init( &cluster->pmgr.local_lock );
    124     list_root_init( &cluster->pmgr.local_root );
     123        remote_spinlock_init( XPTR( local_cxy , &cluster->pmgr.local_lock ) );
     124    xlist_root_init( XPTR( local_cxy , &cluster->pmgr.local_root ) );
    125125    cluster->pmgr.local_nr = 0;
    126126
     
    162162{
    163163    cluster_t * cluster = LOCAL_CLUSTER;
    164         hal_atomic_inc( &cluster->cores_in_kernel );
     164        hal_atomic_add( &cluster->cores_in_kernel , 1 );
    165165}
    166166
     
    169169{
    170170    cluster_t * cluster = LOCAL_CLUSTER;
    171         hal_atomic_dec( &cluster->cores_in_kernel );
     171        hal_atomic_add( &cluster->cores_in_kernel , -1 );
    172172}
    173173
     
    199199xptr_t cluster_get_reference_process_from_pid( pid_t pid )
    200200{
    201     xptr_t xp;   // extended pointer on process descriptor
     201    xptr_t ref_xp;   // extended pointer on reference process descriptor
    202202
    203203    cluster_t * cluster = LOCAL_CLUSTER;
     
    208208
    209209    // Check valid PID
    210     if( lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER )
    211     {
    212         printk("\n[PANIC] in %s : illegal PID\n", __FUNCTION__ );
    213         hal_core_sleep();
    214     }
     210    if( lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER )  return XPTR_NULL;
    215211
    216212    if( local_cxy == owner_cxy )   // local cluster is owner cluster
    217213    {
    218         xp = cluster->pmgr.pref_tbl[lpid];
     214        ref_xp = cluster->pmgr.pref_tbl[lpid];
    219215    }
    220216    else                              // use a remote_lwd to access owner cluster
    221217    {
    222         xp = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.pref_tbl[lpid] ) );
    223     }
    224 
    225     return xp;
     218        ref_xp = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.pref_tbl[lpid] ) );
     219    }
     220
     221    return ref_xp;
    226222}
    227223
     
    303299process_t * cluster_get_local_process_from_pid( pid_t pid )
    304300{
    305     process_t    * ret     = NULL;
    306     list_entry_t * root    = &LOCAL_CLUSTER->pmgr.local_root;
    307     list_entry_t * iter;
    308     process_t    * process;
    309 
    310     LIST_FOREACH( root , iter )
    311     {
    312         process = LIST_ELEMENT( iter , process_t , local_list );
    313         if( process->pid == pid )
     301    xptr_t         process_xp;
     302    process_t    * process_ptr;
     303    xptr_t         root_xp;
     304    xptr_t         iter_xp;
     305    bool_t         found;
     306
     307    found   = false;
     308    root_xp = XPTR( local_cxy , &LOCAL_CLUSTER->pmgr.local_root );
     309
     310    XLIST_FOREACH( root_xp , iter_xp )
     311    {
     312        process_xp  = XLIST_ELEMENT( iter_xp , process_t , local_list );
     313        process_ptr = (process_t *)GET_PTR( process_xp );
     314        if( process_ptr->pid == pid )
    314315        {
    315             ret = process;
     316            found = true;
    316317            break;
    317318        }
    318319    }
    319     return ret;
     320
     321    if (found ) return process_ptr;
     322    else        return NULL;
    320323
    321324}  // end cluster_get_local_process_from_pid()
     
    327330
    328331    // get lock protecting the process manager local list
    329     spinlock_lock( &pm->local_lock );
    330 
    331     list_add_first( &pm->local_root , &process->local_list );
     332    remote_spinlock_lock( XPTR( local_cxy , &pm->local_lock ) );
     333
     334    xlist_add_first( XPTR( local_cxy , &pm->local_root ),
     335                     XPTR( local_cxy , &process->local_list ) );
    332336    pm->local_nr++;
    333337
    334338    // release lock protecting the process manager local list
    335     spinlock_unlock( &pm->local_lock );
     339    remote_spinlock_unlock( XPTR( local_cxy , &pm->local_lock ) );
    336340}
    337341
     
    342346
    343347    // get lock protecting the process manager local list
    344     spinlock_lock( &pm->local_lock );
    345 
    346     list_unlink( &process->local_list );
     348    remote_spinlock_lock( XPTR( local_cxy , &pm->local_lock ) );
     349
     350    xlist_unlink( XPTR( local_cxy , &process->local_list ) );
    347351    pm->local_nr--;
    348352
    349353    // release lock protecting the process manager local list
    350     spinlock_unlock( &pm->local_lock );
     354    remote_spinlock_unlock( XPTR( local_cxy , &pm->local_lock ) );
    351355}
    352356
Note: See TracChangeset for help on using the changeset viewer.