RTEMS Logo

RTEMS 4.8.0 On-Line Library


Shared Memory Support Driver Acquiring a Shared Lock

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

16.2.3.2: Acquiring a Shared Lock

The Shm_Lock routine is responsible for acquiring the lock field. Interrupts should be disabled while that lock is acquired. If the lock is currently unavailble, then the locking routine should delay a few microseconds to allow the other node to release the lock. Doing this reduces bus contention for the lock. This routines usually is implemented as follows:

void Shm_Lock(
  Shm_Locked_queue_Control *lq_cb
)
{
  disable processor interrupts
    set Shm_isrstat to previous interrupt disable level

    while ( TRUE ) {
      atomically attempt to acquire the lock
      if the lock was acquired
        return
      delay some small period of time
    }
}


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2007OAR Corporation