Ignore:
Timestamp:
Jul 4, 2012, 2:51:18 PM (12 years ago)
Author:
alain
Message:

Introducing various modifications in kernel initialisation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/libs/mwmr_channel.c

    r159 r165  
    1212// The mwmr_read() and mwmr_write() functions do not require a system call.
    1313// The channel itself must have been allocated in a non cacheable segment,
    14 // if the platform does not provide hardwate cache coherence.
     14// if the platform does not provide hardware cache coherence.
    1515//
    1616// ALL MWMR channels must be defined in the mapping_info data structure,
     
    3737//  mwmr_lock_aquire()
    3838// This blocking function returns only when the lock has been taken.
    39 // If the lock is already taken a random delay is introduced before retry.
    40 //////////////////////////////////////////////////////////////////////////////
    41 void mwmr_lock_acquire(unsigned int* plock)
     39// If the lock is already taken a fixed delay is introduced before retry.
     40//////////////////////////////////////////////////////////////////////////////
     41void mwmr_lock_acquire(unsigned int* lock_address)
    4242{
     43    register unsigned int*      plock = lock_address;
     44    register unsigned int       delay = 100;
    4345    asm volatile (
    4446            "mwmr_lock_try:                                     \n"
    4547            "ll   $2,    0(%0)                          \n" /* $2 <= lock current value */
    46             "bnez $2,    mwmr_lock_delay        \n" /* retry if lock already taken */
     48            "bnez $2,    mwmr_lock_delay        \n" /* retry after delay if lock busy */
    4749            "li   $3,    1                                      \n" /* $3 <= argument for sc */
    4850            "sc   $3,    0(%0)                          \n" /* try to get lock */
    4951            "bnez $3,    mwmr_lock_ok           \n" /* exit if atomic */
    50 
    5152            "mwmr_lock_delay:                           \n"
    52             "jal  rand                                  \n" /* rand() system call */
    53             "nop                                                        \n"
    54             "andi $4,   $2,     0xFF                    \n"     /* $4 <= random delay < 256 cycles */
    55 
    56             "mwmr_lock_loop:                            \n"
     53            "move $4,    %1                 \n" /* $4 <= delay */
     54            "mwmr_lock_loop:                \n"
     55            "beqz $4,    mwmr_lock_loop         \n" /* test end delay */
    5756            "addi $4,    $4,  -1                        \n" /* $4 <= $4 - 1 */
    58             "beqz $4,    mwmr_lock_loop         \n" /* test end delay */
    59             "nop                                                        \n"
    60             "j           mwmr_lock_try          \n" /* retry */
     57            "j           mwmr_lock_try          \n" /* retry ll */
    6158            "nop                                                        \n"
    6259            "mwmr_lock_ok:                                      \n"
    6360            :
    64             :"r"(plock)
     61            :"r"(plock), "r"(delay)
    6562            :"$2", "$3", "$4");
    6663}
     
    117114        {
    118115            mwmr->lock = 0;
    119             for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
     116            for ( x = giet_rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
    120117        }
    121118        else    // write as many items as possible, release lock and retry after delay
     
    135132        }
    136133        // random delay before retry
    137         for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
     134        for ( x = giet_rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
    138135    }
    139136}
     
    188185        {
    189186            mwmr->lock = 0;
    190             for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
     187            for ( x = giet_rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );
    191188        }
    192189        else    // read as many items as possible, release lock and retry after delay
     
    206203        }
    207204        // random delay before retry
    208         for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
     205        for ( x = giet_rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );
    209206    }
    210207}
Note: See TracChangeset for help on using the changeset viewer.