Changeset 19 for trunk/kernel


Ignore:
Timestamp:
Jun 3, 2017, 4:46:59 PM (8 years ago)
Author:
max@…
Message:

cosmetic, and a few typos

Location:
trunk/kernel/kern
Files:
7 edited

Legend:

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

    r14 r19  
    11/*
    22 * cluster.c - Cluster-Manager related operations
    3  * 
     3 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Mohamed Lamine Karaoui (2015)
     
    6868
    6969    // initialize cluster global parameters
    70         cluster->paddr_width     = info->paddr_width; 
     70        cluster->paddr_width     = info->paddr_width;
    7171        cluster->x_width         = info->x_width;
    7272        cluster->y_width         = info->y_width;
     
    7777    // initialize cluster local parameters
    7878        cluster->cores_nr        = info->cores_nr;
    79     cluster->cores_in_kernel = info->cores_nr;   // all cpus start in kernel mode
    80 
    81     // initialize the lock protectig the embedded kcm allocator
     79    cluster->cores_in_kernel = info->cores_nr; // all cpus start in kernel mode
     80
     81    // initialize the lock protecting the embedded kcm allocator
    8282        spinlock_init( &cluster->kcm_lock );
    8383
    84     // initialises DQDT 
    85     cluster->dqdt_root_level = dqdt_init( info->x_size, 
    86                                           info->y_size, 
     84    // initialises DQDT
     85    cluster->dqdt_root_level = dqdt_init( info->x_size,
     86                                          info->y_size,
    8787                                          info->y_width );
    8888    cluster->threads_var = 0;
     
    9696    // initialises embedded KHM
    9797        khm_init( &cluster->khm );
    98  
    99     // initialises embedded KCM 
     98
     99    // initialises embedded KCM
    100100        kcm_init( &cluster->kcm , KMEM_KCM );
    101101
     
    107107                       info->core[lid].gid );      // gid from boot_info_t
    108108        }
    109        
     109
    110110    // initialises RPC fifo
    111111        rpc_fifo_init( &cluster->rpc_fifo );
     
    114114        spinlock_init( &cluster->pmgr.pref_lock );
    115115    cluster->pmgr.pref_nr = 0;
    116     cluster->pmgr.pref_tbl[0] = XPTR( local_cxy , &process_zero );   
     116    cluster->pmgr.pref_tbl[0] = XPTR( local_cxy , &process_zero );
    117117    for( lpid = 1 ; lpid < CONFIG_MAX_PROCESS_PER_CLUSTER ; lpid++ )
    118118    {
     
    131131        cluster->pmgr.copies_nr[lpid] = 0;
    132132        xlist_root_init( XPTR( local_cxy , &cluster->pmgr.copies_root[lpid] ) );
    133     }   
     133    }
    134134
    135135    hal_wbflush();
     
    148148    uint32_t y = cxy & ((1<<y_width)-1);
    149149
    150     if( x >= cluster->x_size ) return true; 
    151     if( y >= cluster->y_size ) return true; 
     150    if( x >= cluster->x_size ) return true;
     151    if( y >= cluster->y_size ) return true;
    152152
    153153    return false;
     
    188188            sel = lid;
    189189        }
    190     } 
     190    }
    191191    return sel;
    192192}
     
    198198//////////////////////////////////////////////////////////
    199199xptr_t cluster_get_reference_process_from_pid( pid_t pid )
    200 { 
     200{
    201201    xptr_t xp;   // extended pointer on process descriptor
    202202
     
    207207    lpid_t lpid      = LPID_FROM_PID( pid );
    208208
    209     // Check valid PID 
     209    // Check valid PID
    210210    if( lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER )
    211211    {
     
    215215
    216216    if( local_cxy == owner_cxy )   // local cluster is owner cluster
    217     { 
     217    {
    218218        xp = cluster->pmgr.pref_tbl[lpid];
    219219    }
     
    264264    {
    265265        error = EAGAIN;
    266     }   
     266    }
    267267
    268268    // release the processs_manager lock
     
    307307    list_entry_t * iter;
    308308    process_t    * process;
    309    
     309
    310310    LIST_FOREACH( root , iter )
    311311    {
     
    370370    xptr_t copies_entry = XPTR( local_cxy , &process->copies_list );
    371371
    372     // get lock protecting copies_list[lpid] 
     372    // get lock protecting copies_list[lpid]
    373373    remote_spinlock_lock( copies_lock );
    374374
     
    376376    hal_remote_atomic_add( XPTR( owner_cxy , &pm->copies_nr[lpid] ) , 1 );
    377377
    378     // release lock protecting copies_list[lpid] 
     378    // release lock protecting copies_list[lpid]
    379379    remote_spinlock_unlock( copies_lock );
    380380}
     
    396396    xptr_t copies_entry = XPTR( local_cxy , &process->copies_list );
    397397
    398     // get lock protecting copies_list[lpid] 
     398    // get lock protecting copies_list[lpid]
    399399    remote_spinlock_lock( copies_lock );
    400400
     
    402402    hal_remote_atomic_add( XPTR( owner_cxy , &pm->copies_nr[lpid] ) , -1 );
    403403
    404     // release lock protecting copies_list[lpid] 
     404    // release lock protecting copies_list[lpid]
    405405    remote_spinlock_unlock( copies_lock );
    406406}
     
    408408////////////////////////////////////////////////////////////////////////////////////////
    409409// TODO Il me semble que la seule chose que fait ce kernel thread à chaque réveil
    410 // est de mettre à jour la DQDT, et de se rendormir... A-t-on besoin d'un thread ? [AG] 
     410// est de mettre à jour la DQDT, et de se rendormir... A-t-on besoin d'un thread ? [AG]
    411411//////////////////////////////////////////////////////////////////////////////////////////
    412412
     
    437437        isRootMgr = (cluster == root_home) ? true : false;
    438438        cntr      = 0;
    439         period    = (isRootMgr) ? 
    440                 CONFIG_DQDT_ROOTMGR_PERIOD * MSEC_PER_TICK : 
     439        period    = (isRootMgr) ?
     440                CONFIG_DQDT_ROOTMGR_PERIOD * MSEC_PER_TICK :
    441441                CONFIG_DQDT_MGR_PERIOD * MSEC_PER_TICK;
    442442
     
    444444        event_set_priority(&event, E_CHR);
    445445        event_set_handler(&event, &manager_alarm_event_handler);
    446  
     446
    447447        info.event = &event;
    448448        thread_preempt_disable(CURRENT_THREAD);
     
    459459                        if((cntr % 10) == 0)
    460460                        {
    461                                 printk(INFO, "INFO: cpu %d, DQDT update ended [ %u - %u ]\n", 
    462                                        cpu_id, 
    463                                        tm_end, 
     461                                printk(INFO, "INFO: cpu %d, DQDT update ended [ %u - %u ]\n",
     462                                       cpu_id,
     463                                       tm_end,
    464464                                       tm_end - tm_start);
    465465
     
    480480{
    481481        struct thread_s *manager;
    482  
     482
    483483        manager = event_get_senderId(event);
    484  
     484
    485485        thread_preempt_disable(CURRENT_THREAD);
    486486
     
    488488
    489489        sched_wakeup(manager);
    490  
     490
    491491        thread_preempt_enable(CURRENT_THREAD);
    492492
     
    513513        {
    514514                ckey->val = key;
    515                 cluster->keys_tbl[key] = (void *) 0x1; // Reserved 
     515                cluster->keys_tbl[key] = (void *) 0x1; // Reserved
    516516                cluster->next_key = key;
    517517                event_set_error(event, 0);
  • trunk/kernel/kern/cluster.h

    r14 r19  
    11/*
    22 * cluster.h - Cluster-Manager definition
    3  * 
     3 *
    44 * authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *          Mohamed Lamine Karaoui (2015)
     
    5555 * This structure defines the process manager, that is part of the cluster manager.
    5656 * For any process P, the process descriptor is replicated in all clusters containing
    57  * at least one thread of process P, but only the "reference" cluster descriptor contains 
     57 * at least one thread of process P, but only the "reference" cluster descriptor contains
    5858 * the reference (complete) structures such as the GPT, the VSL, or the FDT.
    59  * The "owner" cluster is in charge to allocate a lpid (local process index), 
     59 * The "owner" cluster is in charge to allocate a lpid (local process index),
    6060 * for all process owned by a cluster K, and to register the "reference" cluster for
    61  * all process owned by K. 
    62  *
    63  * Warning : the "owner" cluster, and the "reference" cluster can be different clusters. 
     61 * all process owned by K.
     62 *
     63 * Warning : the "owner" cluster, and the "reference" cluster can be different clusters.
    6464 *
    6565 * The process manager of a cluster K maintains three structures:
     
    6969 *    A process descriptor P is present in K, as soon as P has a thread in cluster K.
    7070 * 3) The copies_root[] array is indexed by lpid. Each entry contains the root of
    71  *    the xlist of copies for a given process owned by cluster K.   
     71 *    the xlist of copies for a given process owned by cluster K.
    7272 ******************************************************************************************/
    7373
     
    8282    uint32_t          local_nr;               /*! number of process in cluster            */
    8383
    84     xlist_entry_t     copies_root[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! roots of lists    */ 
     84    xlist_entry_t     copies_root[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! roots of lists    */
    8585    remote_spinlock_t copies_lock[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! one lock per list */
    8686    uint32_t          copies_nr[CONFIG_MAX_PROCESS_PER_CLUSTER];    /*! number of copies  */
     
    9090/*******************************************************************************************
    9191 * This structure defines a cluster manager.
    92  * It contains both global platform informations, and cluster specific ressources
     92 * It contains both global platform information, and cluster specific resources
    9393 * managed by the local kernel instance.
    9494 ******************************************************************************************/
     
    135135    pmgr_t            pmgr;               /*! embedded process manager                    */
    136136
    137         char              name[CONFIG_SYSFS_NAME_LEN]; 
     137        char              name[CONFIG_SYSFS_NAME_LEN];
    138138
    139139//      sysfs_entry_t     node;
    140 } 
     140}
    141141cluster_t;
    142142
    143143/******************************************************************************************
    144144 * This global variable is allocated in the kernel_init.c file.
    145  * There is one cluster_manager per cluster, with the same local address, 
    146  * but different content, in all clusters containing a kernel instance. 
     145 * There is one cluster_manager per cluster, with the same local address,
     146 * but different content, in all clusters containing a kernel instance.
    147147 *****************************************************************************************/
    148148
     
    156156
    157157/******************************************************************************************
    158  * This generic function initialises the local cluster manager from informations found
     158 * This generic function initialises the local cluster manager from information found
    159159 * in the local boot-info structure. It initializes the following local resources:
    160160 * - the global platform parameters,
     
    170170 * @ info : pointer on the local boot_info_t structure build by the bootloader.
    171171 *****************************************************************************************/
    172 error_t cluster_init( boot_info_t * info );         
    173 
    174 /******************************************************************************************
    175  * This function cheks the validity of a cluster identifier. TODO useful ??? [AG]
     172error_t cluster_init( boot_info_t * info );
     173
     174/******************************************************************************************
     175 * This function checks the validity of a cluster identifier. TODO useful ??? [AG]
    176176 ******************************************************************************************
    177177 * @ cxy    : cluster identifier to be checked.
     
    200200xptr_t cluster_get_reference_process_from_pid( pid_t pid );
    201201
    202 /****************************************************************************************** 
     202/******************************************************************************************
    203203 * This function allocates a new PID in local cluster, that becomes the process owner.
    204  * It register the process descriptor extended pointer in the local processs manager
     204 * It registers the process descriptor extended pointer in the local processs manager
    205205 * pref_tbl[] array. This function is called by the rpc_process_alloc_pid() function for
    206206 * remote registration, or by the process_init_create() function for local registration.
     
    208208 * @ process    : [in]  extended pointer on the process descriptor.
    209209 * @ pid        : [out] allocated PID.
    210  * @ return 0 if success / return EAGAIN if no PID slot available 
     210 * @ return 0 if success / return EAGAIN if no PID slot available
    211211 *****************************************************************************************/
    212212error_t cluster_pid_alloc( xptr_t    process_xp,
    213213                           pid_t   * pid );
    214214
    215 /****************************************************************************************** 
     215/******************************************************************************************
    216216 * This function removes a PID from the local process manager pref_tbl[] array.
    217217 * It checks that removed process is owned by the local cluster and the lpid is legal.
     
    237237 * @ process     : pointer on local process descriptor.
    238238 *****************************************************************************************/
    239 void cluster_process_local_link( struct process_s * process ); 
     239void cluster_process_local_link( struct process_s * process );
    240240
    241241/******************************************************************************************
     
    244244 * @ process     : pointer on local process descriptor.
    245245 *****************************************************************************************/
    246 void cluster_process_local_unlink( struct process_s * process ); 
     246void cluster_process_local_unlink( struct process_s * process );
    247247
    248248/******************************************************************************************
     
    252252 * @ process     : pointer on local process descriptor.
    253253 *****************************************************************************************/
    254 void cluster_process_copies_link( struct process_s * process ); 
     254void cluster_process_copies_link( struct process_s * process );
    255255
    256256/******************************************************************************************
     
    260260 * @ process     : pointer on local process descriptor.
    261261 *****************************************************************************************/
    262 void cluster_process_copies_unlink( struct process_s * process ); 
     262void cluster_process_copies_unlink( struct process_s * process );
    263263
    264264
  • trunk/kernel/kern/core.c

    r14 r19  
    11/*
    22 * core.c - core descriptor access function.
    3  * 
     3 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Mohamed Lamine Karaoui (2015)
     
    4141
    4242/////////////////////////////////
    43 void core_init( core_t    * core, 
    44                 lid_t       lid, 
     43void core_init( core_t    * core,
     44                lid_t       lid,
    4545                gid_t       gid )
    4646{
     
    5353        core->usage             = 0;
    5454        core->spurious_irqs     = 0;
    55     core->rpc_threads       = 0;
     55        core->rpc_threads       = 0;
    5656
    5757        rpc_fifo_init( &core->rpc_fifo );
    5858
    59     list_root_init( &core->rpc_free_list );
    60 
    61     core->thread_rpc        = NULL;
    62     core->thread_idle       = NULL;
    63     core->fpu_owner         = NULL;
     59        list_root_init( &core->rpc_free_list );
     60
     61        core->thread_rpc        = NULL;
     62        core->thread_idle       = NULL;
     63        core->fpu_owner         = NULL;
    6464        core->rand_last         =  hal_time_stamp() & 0xFFF;
    6565
     
    7070inline uint32_t core_get_rand( core_t * core )
    7171{
    72     uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
    73                         CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
    74     core->rand_last = value;
    75     return value;
     72        uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
     73                            CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
     74        core->rand_last = value;
     75        return value;
    7676}
    7777
     
    7979inline uint64_t core_get_cycles( core_t * core )
    8080{
    81     uint32_t elapsed;
    82     uint64_t cycles;
     81        uint32_t elapsed;
     82        uint64_t cycles;
    8383        uint32_t time_stamp = core->time_stamp;
    8484        uint32_t time_now   = hal_time_stamp();
    85        
     85
    8686        // compute number of elapsed cycles, taking into account 32 bits register wrap
    8787        if(time_now < time_stamp) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    8888        else                      elapsed = (time_now - time_stamp);
    8989
    90     cycles = core->cycles + elapsed;
    91 
    92     // update core time
    93     core->time_stamp = time_now;
    94     core->cycles     = cycles;
     90        cycles = core->cycles + elapsed;
     91
     92        // update core time
     93        core->time_stamp = time_now;
     94        core->cycles     = cycles;
    9595        hal_wbflush();
    9696
     
    100100////////////////////////////////////
    101101void core_get_time( core_t   * core,
    102                     uint32_t * tm_ms, 
     102                    uint32_t * tm_ms,
    103103                    uint32_t * tm_us )
    104104{
    105105        // uint64_t cycles = core_get_cycles( core );
    106106
    107     // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
     107        // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
    108108
    109109        // *tm_ms = (cycles / CONFIG_CYCLES_PER_MS);
    110110        // *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    111111
    112     printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
     112        printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
    113113}
    114114
     
    116116void core_time_update( core_t * core )
    117117{
    118     uint32_t elapsed;
     118        uint32_t elapsed;
    119119        uint32_t ticks_nr   = core->ticks_nr;
    120120        uint64_t cycles     = core->cycles;
     
    122122        uint32_t time_now   = hal_time_stamp();
    123123
    124     // compute number of elapsed cycles taking into account 32 bits register wrap
     124        // compute number of elapsed cycles taking into account 32 bits register wrap
    125125        if( time_now < time_stamp ) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    126126        else                        elapsed = time_now - time_stamp;
    127    
     127
    128128        cycles  += elapsed;
    129129        ticks_nr = elapsed / core->ticks_period;
     
    140140        uint32_t ticks;
    141141
    142     // update cycles and ticks counter
     142        // update cycles and ticks counter
    143143        core_time_update( core );
    144144
    145     // get current ticks number
     145        // get current ticks number
    146146        ticks = core->ticks_nr;
    147147
    148     // handle pending alarms TODO ??? [AG]
     148        // handle pending alarms TODO ??? [AG]
    149149        // alarm_clock( &core->alarm_mgr , ticks );
    150150
    151     // handle scheduler TODO  improve the scheduling condition ... AG
    152     if( (ticks % 10) == 0 ) sched_yield();
    153        
    154     // update DQDT TODO  This update should depend on the cluster identifier,
    155     // to avoid simultaneous updates from various clusters ... AG
     151        // handle scheduler TODO  improve the scheduling condition ... AG
     152        if( (ticks % 10) == 0 ) sched_yield();
     153
     154        // update DQDT TODO  This update should depend on the cluster identifier,
     155        // to avoid simultaneous updates from various clusters ... AG
    156156        if( ((ticks % CONFIG_DQDT_PERIOD) == 0) && (core->lid == 0) ) dqdt_global_update();
    157157}
    158158
    159159////////////////////////////////////////
    160 void core_compute_stats( core_t * core ) 
     160void core_compute_stats( core_t * core )
    161161{
    162162        thread_t * idle  = core->thread_idle;
     
    167167        uint32_t   usage;
    168168
    169     // compute cumulated usage       
     169        // compute cumulated usage
    170170        ticks         = (ticks) ? ticks : 1;
    171171        idle_percent  = (idle->ticks_nr * 100) / ticks;
     
    174174        usage         = (busy_percent + core->usage) / 2;
    175175
    176     // update core descriptor
     176        // update core descriptor
    177177        core->usage = usage;
    178178        hal_wbflush();
     
    204204                                chdev_t  * chdev )
    205205{
    206     if     ( irq_type == WTI_TYPE ) core->wti_vector[irq_id] = chdev;
    207     else if( irq_type == HWI_TYPE ) core->hwi_vector[irq_id] = chdev;
    208     else                            core->pti_vector[irq_id] = chdev;
    209 }
     206        if     ( irq_type == WTI_TYPE ) core->wti_vector[irq_id] = chdev;
     207        else if( irq_type == HWI_TYPE ) core->hwi_vector[irq_id] = chdev;
     208        else                            core->pti_vector[irq_id] = chdev;
     209}
  • trunk/kernel/kern/core.h

    r16 r19  
    11/*
    22 * core.h - core descriptor and associated access functions définition
    3  * 
     3 *
    44 * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *          Mohamed Lamine Karaoui (2015)
     
    4949{
    5050        lid_t               lid;            /*! core local index in cluster                */
    51         gid_t               gid;            /*! core global identifier (hardware index)    */   
     51        gid_t               gid;            /*! core global identifier (hardware index)    */
    5252        uint64_t            cycles;         /*! total number of cycles (from hard reset)   */
    5353        uint32_t            time_stamp;     /*! previous time stamp (read from register)   */
     
    5858        struct thread_s   * thread_rpc;     /*! pointer on current RPC thread descriptor   */
    5959        struct thread_s   * thread_idle;    /*! pointer on idle thread descriptor          */
    60         struct thread_s   * fpu_owner;      /*! pointer on current FPU owner thread        */ 
     60        struct thread_s   * fpu_owner;      /*! pointer on current FPU owner thread        */
    6161    uint32_t            rand_last;      /*! last computed random value                 */
    6262        uint32_t            rpc_threads;    /*! total number of RPC threads for this core  */
     
    7171
    7272//      sysfs_entry_t       node;
    73 } 
     73}
    7474core_t;
    7575
     
    8787 ***************************************************************************************
    8888 * @ core      : pointer on core descriptor to initialise.
    89  * @ lid       : local core index 
     89 * @ lid       : local core index
    9090 * @ gid       : global core identifier (hardware index)
    9191 **************************************************************************************/
    92 void core_init( core_t   * core, 
    93                 lid_t      lid, 
     92void core_init( core_t   * core,
     93                lid_t      lid,
    9494                gid_t      gid );
    9595
     
    104104
    105105/***************************************************************************************
    106  * This function returns the current date (cycles) from both 
    107  * the hardware 32 bits cycles counter and the core descriptor cycles counter, 
     106 * This function returns the current date (cycles) from both
     107 * the hardware 32 bits cycles counter and the core descriptor cycles counter,
    108108 * taking into account the 32 bits hardware register overflow.
    109109 * The core descriptor time is updated.
     
    116116/***************************************************************************************
    117117 * This function returns the current date (seconds & micro-seconds) from both
    118  * the hardware 32 bits cycles counter and the core descriptor cycles counter, 
     118 * the hardware 32 bits cycles counter and the core descriptor cycles counter,
    119119 * taking into account the 32 bits hardware register overflow.
    120120 * The core descriptor time is updated.
     
    132132 * It updates the  cycles and ticks counter in the calling core descriptor.
    133133 * It handles all pending alarms depending on the ticks counter value.
    134  * It handles the scheduling, depending on the ticks counter value. 
     134 * It handles the scheduling, depending on the ticks counter value.
    135135 * It handles the global DQDT update, depending on the ticks counter vakue.
    136136 ***************************************************************************************
     
    140140
    141141/***************************************************************************************
    142  * This function updates the usage statistics for the calling core descriptor, 
     142 * This function updates the usage statistics for the calling core descriptor,
    143143 * based on the ratio between the idle_ticks and total_ticks.
    144144 ***************************************************************************************
     
    157157 * This function set/reset a selected entry in one interrupt vector for a remote core.
    158158 * The written value is an extended pointer on the "source" device (or the XPTR_NULL
    159  * value in case of reset). As it uses remote access, this function can be called by 
     159 * value in case of reset). As it uses remote access, this function can be called by
    160160 * any thread in any cluster.
    161161 ***************************************************************************************
  • trunk/kernel/kern/dqdt.c

    r14 r19  
    11/*
    22 * dqdt.c - Distributed Quaternary Decision Tree implementation.
    3  * 
     3 *
    44 * Author : Alain Greiner (2016)
    55 *
     
    6363        }
    6464    }
    65 } 
    66    
     65}
     66
    6767////////////////////////////////////
    6868uint32_t dqdt_init( uint32_t x_size,
     
    113113        node->children[2] = XPTR_NULL;
    114114        node->children[3] = XPTR_NULL;
    115  
     115
    116116        // compute masks depending on level : 0x1, 0x3, 0x7, 0xF, 0x1F etc.
    117117        mask  = (1<<level)-1;
     
    121121        if( ((x & mask) == 0) && ((y & mask) == 0) );
    122122        {
    123             // set parent extended pointer 
     123            // set parent extended pointer
    124124            p_cxy = ((x & ~pmask)<<y_width) + (y & ~pmask);
    125125            node->parent = XPTR( p_cxy , &cluster->dqdt_tbl[level+1] );
    126126
    127             // set child[0] extended pointer (same [x,y] coordinates) 
     127            // set child[0] extended pointer (same [x,y] coordinates)
    128128            if ( level > 0 )
    129129            {
     
    188188    if ( parent != XPTR_NULL )
    189189    {
    190         dqdt_propagate( parent, threads_var, pages_var );         
     190        dqdt_propagate( parent, threads_var, pages_var );
    191191    }
    192192}
     
    217217{
    218218        cluster_t * cluster = LOCAL_CLUSTER;
    219    
    220     // register change for future propagation in DQDT 
     219
     220    // register change for future propagation in DQDT
    221221    hal_atomic_add( &cluster->threads_var , increment );
    222222
     
    229229{
    230230        cluster_t * cluster = LOCAL_CLUSTER;
    231    
    232     // register change for future propagation in DQDT 
     231
     232    // register change for future propagation in DQDT
    233233    hal_atomic_add( &cluster->pages_var , increment );
    234234
     
    270270        {
    271271            cxy  = (cxy_t)GET_CXY( child );
    272             ptr  = (dqdt_node_t *)GET_PTR( child ); 
     272            ptr  = (dqdt_node_t *)GET_PTR( child );
    273273            if( for_memory ) load = hal_remote_lw( XPTR( cxy , &ptr->pages ) );
    274274            else             load = hal_remote_lw( XPTR( cxy , &ptr->threads ) );
     
    276276            {
    277277                load_min = load;
    278                 select   = i; 
    279             }     
     278                select   = i;
     279            }
    280280        }
    281281    }
    282282
    283283    // select the child with the lowest load
    284     return dqdt_select_cluster( node_copy.children[select], for_memory ); 
     284    return dqdt_select_cluster( node_copy.children[select], for_memory );
    285285}
    286286
     
    294294
    295295    // call recursive function
    296     return dqdt_select_cluster( root , false ); 
     296    return dqdt_select_cluster( root , false );
    297297}
    298298
     
    306306
    307307    // call recursive function
    308     return dqdt_select_cluster( root , true ); 
    309 }
    310 
     308    return dqdt_select_cluster( root , true );
     309}
     310
  • trunk/kernel/kern/dqdt.h

    r14 r19  
    11/*
    22 * kern/dqdt.h - Distributed Quad Decision Tree
    3  * 
     3 *
    44 * Author : Alain Greiner (2016)
    55 *
     
    3535 * - If X_SIZE or Y_SIZE are equal to 1, it makes the assumption that the cluster
    3636 *   topology is a one dimensionnal vector, an build the smallest one-dimensionnal
    37  *   quad-tree covering this one-dimensionnal vector. If the number of clusters 
     37 *   quad-tree covering this one-dimensionnal vector. If the number of clusters
    3838 *   is not a power of 4, the tree is truncated as required.
    3939 *   TODO : the mapping for the one dimensionnal topology is not implemented yet [AG].
    40  * 
    41  * - If both Y_SIZE and Y_SIZE are larger than 1, it makes the assumption that 
    42  *   the cluster topology is a 2D mesh. The [X,Y] coordinates of a cluster are 
    43  *   obtained from the CXY identifier using the following rules : 
     40 *
     41 * - If both Y_SIZE and Y_SIZE are larger than 1, it makes the assumption that
     42 *   the cluster topology is a 2D mesh. The [X,Y] coordinates of a cluster are
     43 *   obtained from the CXY identifier using the following rules :
    4444 *      X = CXY >> Y_WIDTH   /  Y = CXY & ((1<<Y_WIDTH)-1)
    45  *   If the mesh X_SIZE and Y_SIZE dimensions are not equal, or are not power of 2, 
     45 *   If the mesh X_SIZE and Y_SIZE dimensions are not equal, or are not power of 2,
    4646 *   we build the smallest two dimensionnal quad-tree covering all clusters,
    4747 *   and this tree is truncated as required.
    4848 *   The root node is always implemented in cluster [0,0]
    4949 *   The mesh size is supposed to contain at most 32 * 32 clusters.
    50  *   There are at most 6 DQDT nodes in a cluster 
     50 *   There are at most 6 DQDT nodes in a cluster
    5151 *   . Level 0 nodes exist on all clusters and have no children.
    52  *   . Level 1 nodes exist when both X and Y coordinates are multiple of 2 
     52 *   . Level 1 nodes exist when both X and Y coordinates are multiple of 2
    5353 *   . Level 2 nodes exist when both X and Y coordinates are multiple of 4
    5454 *   . Level 3 nodes exist when both X and Y coordinates are multiple of 8
     
    7676
    7777/****************************************************************************************
    78  * This local function initializes the local DQDT structures. 
     78 * This local function initializes the local DQDT structures.
    7979 * The information describing the hardware platform topology and the cluster
    8080 * indexing policy is defined by the three arguments below.
    81  * This initialisation is done in parallel, locally in each cluster, because the DQDT 
     81 * This initialisation is done in parallel, locally in each cluster, because the DQDT
    8282 * is allocated as a global variable in the cluster_manager, and the local addresses
    8383 * are identical in all clusters.
     
    118118 * This local function updates both the total number of threads,
    119119 * in the level 0 DQDT node, and the variation of the number of threads
    120  * for future propagation to the DQDT upper levels. 
     120 * for future propagation to the DQDT upper levels.
    121121 * It should be called on each thread creation or destruction.
    122122 ****************************************************************************************
     
    128128 * This local function updates both the total number of allocated pages,
    129129 * in the level 0 DQDT node, and the variation of the number of pages
    130  * for future propagation to the DQDT upper levels. 
     130 * for future propagation to the DQDT upper levels.
    131131 * It should be called on each memory allocation or release.
    132132 ****************************************************************************************
     
    146146/****************************************************************************************
    147147 * This function can be called in any cluster. It traverses the DQDT tree
    148  * from the root to the bottom, to analyse the memory load and select the cluster 
     148 * from the root to the bottom, to analyse the memory load and select the cluster
    149149 * with the lowest memory load for dynamic memory allocation with no locality constraint.
    150150 ****************************************************************************************
  • trunk/kernel/kern/kernel_init.c

    r14 r19  
    8282// This variable defines the local cluster manager
    8383__attribute__((section(".kdata")))
    84 cluster_t            cluster_manager                         CONFIG_CACHE_LINE_ALIGNED; 
     84cluster_t            cluster_manager                         CONFIG_CACHE_LINE_ALIGNED;
    8585
    8686// This variables define the kernel process0 descriptor
    8787__attribute__((section(".kdata")))
    88 process_t            process_zero                            CONFIG_CACHE_LINE_ALIGNED;           
     88process_t            process_zero                            CONFIG_CACHE_LINE_ALIGNED;
    8989
    9090// This variable defines extended pointers on the distributed chdevs
     
    197197                {
    198198                    cxy_t  cxy = (x<<info->y_width) + y;
    199                     hal_remote_swd( XPTR( cxy , &chdev_dir.txt[0] ) , 
     199                    hal_remote_swd( XPTR( cxy , &chdev_dir.txt[0] ) ,
    200200                                    XPTR( local_cxy , &txt0_chdev ) );
    201201                }
     
    204204                    kinit_dmsg("\n[INFO] %s : core[%x][0] created TXT0 chdev"
    205205                       " / paddr = %l at cycle %d\n",
    206                        __FUNCTION__ , local_cxy , chdev_func_str( func ), 
     206                       __FUNCTION__ , local_cxy , chdev_func_str( func ),
    207207                       XPTR(local_cxy , &txt0_chdev) , hal_time_stamp() );
    208208        }
     
    257257    // make ICU specific initialisation
    258258    // TODO remove these three parameters
    259     dev_icu_init( chdev_ptr , dev->param0 , dev->param1 , dev->param2 );     
     259    dev_icu_init( chdev_ptr , dev->param0 , dev->param1 , dev->param2 );
    260260
    261261    // initialize the ICU field in the chdev_dir[x][y] structures
     
    532532                }  // end if match
    533533
    534                 // increment chdev global index (matching or not)           
     534                // increment chdev global index (matching or not)
    535535                chdev_gid++;
    536536
     
    608608        uint32_t   i;
    609609    gid_t      global_id;
    610    
     610
    611611    // get global identifier from hardware register
    612612    global_id = hal_get_gid();
     
    624624    }
    625625    return EINVAL;
    626 }                     
     626}
    627627
    628628///////////////////////////////////////////////////////////////////////////////////////////
    629629// This function is the entry point for the kernel initialisation.
    630 // It is executed by all cores in all clusters, but only core[0], called CP0,   
     630// It is executed by all cores in all clusters, but only core[0], called CP0,
    631631// initializes the shared resources such as the cluster manager, or the local peripherals.
    632 // To comply with the multi-kernels paradigm, it access only local cluster memory, using
    633 // only informations contained in the local boot_info_t structure, set by the bootloader.
     632// To comply with the multi-kernels paradigm, it accesses only local cluster memory, using
     633// only information contained in the local boot_info_t structure, set by the bootloader.
    634634///////////////////////////////////////////////////////////////////////////////////////////
    635635// @ info    : pointer on the local boot-info structure.
     
    681681    }
    682682
    683     // CP0 initialize local cluster manager (cores and memory allocators)
     683    // CP0 initializes the local cluster manager (cores and memory allocators)
    684684    if( core_lid == 0 )
    685685    {
     
    713713        core    = &cluster->core_tbl[core_lid];
    714714
    715     // CP0 initialize process_zero descriptor
     715    // CP0 initializes the process_zero descriptor
    716716    if( core_lid == 0 ) process_zero_init( info );
    717717
    718     // CP0 allocate and initialise internal peripheral chdev descriptors.
     718    // CP0 allocates and initialises the internal peripheral chdev descriptors.
    719719    // Each CP0[cxy] scan the set of its internal (private) peripherals,
    720720    // and allocate memory for the corresponding chdev descriptors.
Note: See TracChangeset for help on using the changeset viewer.