Ignore:
Timestamp:
Jul 15, 2015, 6:17:41 PM (9 years ago)
Author:
bellefin
Message:

Introduce mmc distributed lock
The locks are distributed in the kernel heaps (one lock in each cluster) and there is a global table in the kernel data segment which contains the addresses of all the locks.
The _mmc_boot_mode variable is defined in boot.c and kernel_init.c and defines which kind of lock is used.
The distributed locks are initialized inside the kernel_init() function.

Location:
soft/giet_vm/giet_drivers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/mmc_driver.c

    r545 r615  
    3939
    4040///////////////////////////////////////////////////////////////////////////////
    41 // Distributed locks protecting MMC components (one per cluster)
    42 ///////////////////////////////////////////////////////////////////////////////
     41// Locks protecting MMC components (one per cluster)
     42// There are two kinds of lock: the _mmc_lock table contains all the locks and
     43// and is stored in the kernel data segment, whereas the _mmc_distributed_lock
     44// contains the addresses of locks which are distributed in every cluster (each
     45// cluster contains the lock which protects its own mmc_component).
     46// The global variable mmc_boot_mode define the type of lock which is used,
     47// and must be defined in both kernel_init.c and boot.c files.
     48// - the boot code must use a spin_lock because the kernel heap is not set.
     49// - the kernel code can use a sqt_lock when the kernel heap is set.
     50///////////////////////////////////////////////////////////////////////////////
     51
     52extern unsigned int  _mmc_boot_mode;
    4353
    4454__attribute__((section(".kdata")))
    45 spin_lock_t  _mmc_lock[X_SIZE][Y_SIZE]  __attribute__((aligned(64)));
     55spin_lock_t           _mmc_lock[X_SIZE][Y_SIZE]  __attribute__((aligned(64)));
     56
     57__attribute__((section(".kdata")))
     58spin_lock_t*          _mmc_distributed_lock[X_SIZE][Y_SIZE];
     59
     60//////////////////////////////////////////////////////////////////////////////
     61// This function initializes the distributed locks stored in the kernel heaps
     62//////////////////////////////////////////////////////////////////////////////
     63
     64void _mmc_init_locks()
     65{
     66    unsigned int cx;    // cluster X coordinate
     67    unsigned int cy;    // cluster Y coordinate
     68   
     69    for ( cx = 0 ; cx < X_SIZE ; cx++ )
     70    {
     71        for ( cy = 0 ; cy < Y_SIZE ; cy++ )
     72        {
     73            _mmc_distributed_lock[cx][cy] = _remote_malloc( sizeof(spin_lock_t), cx, cy );
     74            _spin_lock_init( _mmc_distributed_lock[cx][cy] );
     75        }
     76    }
     77}
    4678
    4779///////////////////////////////////////////////////////////////////////////////
     
    105137
    106138    // get the lock protecting exclusive access to MEMC
    107     _spin_lock_acquire( &_mmc_lock[x][y] );
     139    if ( _mmc_boot_mode ) _spin_lock_acquire( &_mmc_lock[x][y] );
     140    else                  _spin_lock_acquire( _mmc_distributed_lock[x][y] );
    108141
    109142    // write inval arguments
     
    114147
    115148    // release the lock
    116     _spin_lock_release( &_mmc_lock[x][y] );
     149    if ( _mmc_boot_mode ) _spin_lock_release( &_mmc_lock[x][y] );
     150    else                  _spin_lock_release( _mmc_distributed_lock[x][y] );
    117151}
    118152
     
    140174
    141175    // get the lock protecting exclusive access to MEMC
    142     _spin_lock_acquire( &_mmc_lock[x][y] );
     176    if ( _mmc_boot_mode ) _spin_lock_acquire( &_mmc_lock[x][y] );
     177    else                  _spin_lock_acquire( _mmc_distributed_lock[x][y] );
    143178
    144179    // write inval arguments
     
    149184
    150185    // release the lock
    151     _spin_lock_release( &_mmc_lock[x][y] );
     186    if ( _mmc_boot_mode ) _spin_lock_release( &_mmc_lock[x][y] );
     187    else                  _spin_lock_release( _mmc_distributed_lock[x][y] );
    152188}
    153189
  • soft/giet_vm/giet_drivers/mmc_driver.h

    r496 r615  
    1111#include <hard_config.h>
    1212#include <kernel_locks.h>
     13#include <kernel_malloc.h>
    1314
    1415///////////////////////////////////////////////////////////////////////////////////
     
    124125///////////////////////////////////////////////////////////////////////////////////
    125126
     127extern void _mmc_init_locks();
     128
    126129extern unsigned int _mmc_instrument( unsigned int x,
    127130                                     unsigned int y,
Note: See TracChangeset for help on using the changeset viewer.