Ignore:
Timestamp:
Oct 4, 2018, 11:47:36 PM (3 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

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

    r562 r564  
    3030#include <hal_kernel_types.h>
    3131#include <bits.h>
    32 #include <spinlock.h>
    33 #include <readlock.h>
    34 #include <remote_barrier.h>
     32#include <queuelock.h>
     33#include <remote_queuelock.h>
    3534#include <list.h>
    3635#include <xlist.h>
     
    6867 * 2) The local_root is the root of the local list of all process descriptors in cluster K.
    6968 *    A process descriptor P is present in K, as soon as P has a thread in cluster K.
     69 *    We use an xlist, because this list can be traversed by remote threads.
    7070 *
    7171 * 3) The copies_root[] array is indexed by lpid. There is one entry per owned process,
    7272 *    and each each entry contains the root of the xlist of copies for this process.
     73 $    We use an xlist, because process copies are distributed in all clusters.
    7374 ******************************************************************************************/
    7475
    7576typedef struct process_manager_s
    7677{
    77         xptr_t            pref_tbl[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! reference  process   */
    78         spinlock_t        pref_lock;              /*! lock protecting lpid allocation/release */
    79     uint32_t          pref_nr;                /*! number of processes owned by cluster    */
    80 
    81     xlist_entry_t     local_root;             /*! root of list of process in cluster      */
    82     remote_spinlock_t local_lock;             /*! lock protecting access to local list    */
    83     uint32_t          local_nr;               /*! number of process in cluster            */
    84 
    85     xlist_entry_t     copies_root[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! roots of lists    */
    86     remote_spinlock_t copies_lock[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! one lock per list */
    87     uint32_t          copies_nr[CONFIG_MAX_PROCESS_PER_CLUSTER];    /*! number of copies  */
     78        xptr_t             pref_tbl[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! owned  processes    */
     79        queuelock_t        pref_lock;              /*! lock protecting pref_tbl              */
     80    uint32_t           pref_nr;                /*! number of processes owned by cluster   */
     81
     82    xlist_entry_t      local_root;            /*! root of list of process in cluster      */
     83    remote_queuelock_t local_lock;            /*! lock protecting local list              */
     84    uint32_t           local_nr;              /*! number of process in cluster            */
     85
     86    xlist_entry_t      copies_root[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! roots of lists   */
     87    remote_queuelock_t copies_lock[CONFIG_MAX_PROCESS_PER_CLUSTER];  /*! one  per list    */
     88    uint32_t           copies_nr[CONFIG_MAX_PROCESS_PER_CLUSTER];    /*! number of copie  */
    8889}
    8990pmgr_t;
     
    9798typedef struct cluster_s
    9899{
    99         spinlock_t      kcm_lock;          /*! local, protect creation of KCM allocators      */
    100100
    101101    // global parameters
    102         uint32_t        paddr_width;       /*! numer of bits in physical address              */
     102    uint32_t        paddr_width;       /*! numer of bits in physical address              */
    103103    uint32_t        x_width;           /*! number of bits to code x_size  (can be 0)      */
    104104    uint32_t        y_width;           /*! number of bits to code y_size  (can be 0)      */
    105         uint32_t        x_size;            /*! number of clusters in a row    (can be 1)      */
    106         uint32_t        y_size;            /*! number of clusters in a column (can be 1)      */
    107     uint32_t        cluster_info[CONFIG_MAX_CLUSTERS_X][CONFIG_MAX_CLUSTERS_Y];
    108         cxy_t           io_cxy;            /*! io cluster identifier                          */
     105    uint32_t        x_size;            /*! number of clusters in a row    (can be 1)      */
     106    uint32_t        y_size;            /*! number of clusters in a column (can be 1)      */
     107    cxy_t           io_cxy;            /*! io cluster identifier                          */
    109108    uint32_t        dqdt_root_level;   /*! index of root node in dqdt_tbl[]               */
    110109    uint32_t        nb_txt_channels;   /*! number of TXT channels                         */
     
    113112    uint32_t        nb_fbf_channels;   /*! number of FBF channels                         */
    114113
     114    char            cluster_info[CONFIG_MAX_CLUSTERS_X][CONFIG_MAX_CLUSTERS_Y];
     115
    115116    // local parameters
    116         uint32_t        cores_nr;          /*! actual number of cores in cluster              */
     117    uint32_t        cores_nr;          /*! actual number of cores in cluster              */
    117118    uint32_t        ram_size;          /*! physical memory size                           */
    118119    uint32_t        ram_base;          /*! physical memory base (local address)           */
     
    120121        core_t          core_tbl[CONFIG_MAX_LOCAL_CORES];    /*! embedded cores               */
    121122
    122         list_entry_t    dev_root;          /*! root of list of devices in cluster             */
     123    list_entry_t    dev_root;          /*! root of list of devices in cluster             */
    123124
    124125    // memory allocators
    125         ppm_t           ppm;               /*! embedded kernel page manager                   */
    126         khm_t           khm;               /*! embedded kernel heap manager                   */
    127         kcm_t           kcm;               /*! embedded kernel KCMs manager                   */
     126    ppm_t           ppm;               /*! embedded kernel page manager                   */
     127    khm_t           khm;               /*! embedded kernel heap manager                   */
     128    kcm_t           kcm;               /*! embedded kernel KCMs manager                   */
    128129
    129130    kcm_t         * kcm_tbl[KMEM_TYPES_NR];              /*! pointers on allocated KCMs   */
     131    busylock_t      kcm_lock;                            /*! protect kcm_tbl[] updates    */
    130132
    131133    // RPC
    132         remote_fifo_t   rpc_fifo[CONFIG_MAX_LOCAL_CORES];    /*! one RPC FIFO per core        */
     134    remote_fifo_t   rpc_fifo[CONFIG_MAX_LOCAL_CORES];    /*! one RPC FIFO per core        */
    133135    uint32_t        rpc_threads[CONFIG_MAX_LOCAL_CORES]; /*! RPC threads per core         */
    134136
    135137    // DQDT
    136         dqdt_node_t     dqdt_tbl[CONFIG_DQDT_LEVELS_NR];     /*! embedded DQDT nodes          */
     138    dqdt_node_t     dqdt_tbl[CONFIG_DQDT_LEVELS_NR];     /*! embedded DQDT nodes          */
    137139
    138140    // Local process manager
     
    158160
    159161/******************************************************************************************
    160  * This generic function initialises the local cluster manager from information found
    161  * in the local boot-info structure. It initializes the following local resources:
    162  * - the global platform parameters,
    163  * - the specific cluster parameters,
    164  * - the lock protecting KCM creation,
    165  * - the local DQDT nodes,
    166  * - the PPM, KHM, and KCM allocators,
    167  * - the local core descriptors,
    168  * - the local RPC FIFO,
    169  * - the process manager.
    170  * It does NOT initialise the local device descriptors.
     162 * These two functions initialise the local cluster manager from information found
     163 * in the local boot-info structure <info> build by the boot-loader.
     164 * 1) the cluster_info_init() function is called first, to initialize the structural
     165 *    constants, and cannot use the TXT0 kernel terminal.
     166 * 2) the cluster_manager_init() function initialize various complex structures:
     167 *    - the local DQDT nodes,
     168 *    - the PPM, KHM, and KCM allocators,
     169 *    - the local core descriptors,
     170 *    - the local RPC FIFO,
     171 *    - the process manager.
     172 *    It does NOT initialise the local device descriptors.
     173 *    It can use the TXT0 kernel terminal.
    171174 ******************************************************************************************
    172175 * @ info : pointer on the local boot_info_t structure build by the bootloader.
    173176 *****************************************************************************************/
    174 error_t cluster_init( boot_info_t * info );
    175 
    176 /******************************************************************************************
    177  * This function randomly selects a cluster.
    178  ******************************************************************************************
    179  * @ returns the selected cluster identifier.
    180  *****************************************************************************************/
    181 cxy_t cluster_random_select( void );
     177void    cluster_info_init( boot_info_t * info );
     178error_t cluster_manager_init( boot_info_t * info );
    182179
    183180/******************************************************************************************
     
    189186bool_t cluster_is_undefined( cxy_t cxy );
    190187
    191 
    192 /*****************************************************************************************/
    193 /***************   Process Management Operations   ***************************************/
    194 /*****************************************************************************************/
     188/******************************************************************************************
     189 * This function uses the local cluster_info[][] array in cluster descriptor,
     190 * and returns true when the cluster identified by the <cxy> argument is active.
     191 ******************************************************************************************
     192 * @ cxy   : cluster identifier.
     193 * @ return true if cluster contains a kernel instance.
     194 *****************************************************************************************/
     195bool_t cluster_is_active( cxy_t  cxy );
     196
     197/******************************************************************************************
     198 * This function (pseudo) randomly selects a valid cluster.
     199 * It is called by the vfs_cluster_lookup() function to place a new (missing) inode.
     200 * It is called by the vmm_page_allocate() function to place a distributed vseg page.
     201 ******************************************************************************************
     202 * @ returns the selected cluster identifier.
     203 *****************************************************************************************/
     204cxy_t cluster_random_select( void );
    195205
    196206/******************************************************************************************
     
    290300void cluster_process_copies_unlink( struct process_s * process );
    291301
    292 /*********************************************************************************************
     302/******************************************************************************************
    293303 * This function displays on the kernel terminal TXT0 all user processes registered
    294304 * in the cluster defined by the <cxy> argument.
    295305 * It can be called by a thread running in any cluster, because is use remote accesses
    296306 * to scan the xlist of registered processes.
    297  *********************************************************************************************
     307 ******************************************************************************************
    298308 * @ cxy   : cluster identifier.
    299  ********************************************************************************************/
     309 *****************************************************************************************/
    300310void cluster_processes_display( cxy_t cxy );
    301311
    302 
    303 
    304 /*****************************************************************************************/
    305 /***************   Cores Management Operations   *****************************************/
    306 /*****************************************************************************************/
    307 
    308 /******************************************************************************************
    309  * This function returns the core local index that has the lowest usage in local cluster.
     312/******************************************************************************************
     313 * This function uses the local boot_inforeturns the core local index that has the lowest usage in local cluster.
    310314 *****************************************************************************************/
    311315lid_t cluster_select_local_core( void );
    312316
     317             
    313318#endif  /* _CLUSTER_H_ */
     319
Note: See TracChangeset for help on using the changeset viewer.