RTEMS Logo

RTEMS 4.9.2 On-Line Library


Shared Memory Support Driver Locking Primitives

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

16.2.3: Locking Primitives

  • Shared Memory Support Driver Initializing a Shared Lock
  • Shared Memory Support Driver Acquiring a Shared Lock
  • Shared Memory Support Driver Releasing a Shared Lock
  • This is a collection of routines that are invoked by the portable part of the Shared Memory Driver to manage locks in the shared memory buffer area. Accesses to the shared memory must be atomic. Two nodes in a multiprocessor system must not be manipulating the shared data structures simultaneously. The locking primitives are used to insure this.

    To avoid deadlock, local processor interrupts should be disabled the entire time the locked queue is locked.

    The locking primitives operate on the lock field of the Shm_Locked_queue_Control data structure. This structure is defined as follows:

    typedef struct {
      vol_u32 lock;  /* lock field for this queue    */
      vol_u32 front; /* first envelope on queue      */
      vol_u32 rear;  /* last envelope on queue       */
      vol_u32 owner; /* receiving (i.e. owning) node */
    } Shm_Locked_queue_Control;
    

    where each field is defined as follows:

    lock
    is the lock field. Every node in the system must agree on how this field will be used. Many processor families provide an atomic "test and set" instruction that is used to manage this field.
    front
    is the index of the first message on this locked queue.
    rear
    is the index of the last message on this locked queue.
    owner
    is the node number of the node that currently has this structure locked.


    PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

    Copyright © 1988-2008 OAR Corporation