/home/hillier_g/checkout/most4linux/most-kernel/rtseqlock.h File Reference

Provides real-time sequence locks. More...

Go to the source code of this file.

Data Structures

struct  rt_seqlock_t

Defines

#define RT_SEQLOCK_UNLOCKED   { 0, RTDM_LOCK_UNLOCKED }
#define rt_seqlock_init(x)
#define rt_write_seqlock_irqsave(sl, flags)
#define rt_write_sequnlock_irqrestore(sl, flags)

Functions

static void rt_write_seqlock (seqlock_t *sl)
static void rt_write_sequnlock (seqlock_t *sl)
static unsigned int rt_read_seqbegin (const seqlock_t *sl)
static int rt_read_seqretry (const seqlock_t *sl, unsigned int iv)


Detailed Description

Provides real-time sequence locks.

Provides real-time sequence lock. The implementation follows the structure of Linux sequence locks.

Reader/writer consistent mechanism without starving writers. This type of lock for data where the reader wants a consitent set of information and is willing to retry if the information changes. Readers never block but they may have to retry if a writer is in progress. Writers do not wait for readers.

This is not as cache friendly as brlock. Also, this will not work for data that contains pointers, because any writer could invalidate a pointer that a reader was following.

Expected reader usage:

  do {
      seq = rt_read_seqbegin(&foo);
      // ...
  } while (rt_read_seqretry(&foo, seq));

On non-SMP the spin locks disappear but the writer still needs to increment the sequence variables because an interrupt routine could change the state of the data.

Todo:
Implement trylock, this needs implementation of spin_trylock mechanisms in RTDM. Not difficult, but left out because it's not so very important and because of time shortage ... (the usual stuff)

Definition in file rtseqlock.h.


Define Documentation

#define RT_SEQLOCK_UNLOCKED   { 0, RTDM_LOCK_UNLOCKED }

Initialises a sequence lock statically at compile-time.

Definition at line 78 of file rtseqlock.h.

#define rt_seqlock_init (  ) 

Value:

do {                                                            \
        *(x) = (rt_seqlock_t)RT_SEQLOCK_UNLOCKED;                   \
    } while (0)
Initialises a sequence lock dynamically at runtime

Definition at line 83 of file rtseqlock.h.

#define rt_write_seqlock_irqsave ( sl,
flags   ) 

Value:

do {                                                            \
        rtdm_lock_get_irqsave(&sl->lock, flags);                    \
        ++sl->sequence;                                             \
        smp_wmb();                                                  \
    } while (0)
Same as rt_write_seqlock() but with IRQ protection.

Parameters:
sl the sequence lock
flags the flags of type rtdm_lockctx_t that are safed

Definition at line 154 of file rtseqlock.h.

#define rt_write_sequnlock_irqrestore ( sl,
flags   ) 

Value:

do {                                                            \
        smp_wmb();                                                  \
        sl->sequence++;                                             \
        rtdm_lock_put_irqrestore(&sl->lock, flags);                 \
    } while (0)
Same as rt_write_sequnlock() but with IRQ protection.

Parameters:
sl the sequence lock
flags the flags of type rtdm_lockctx_t that are safed

Definition at line 168 of file rtseqlock.h.


Function Documentation

static void rt_write_seqlock ( seqlock_t *  sl  )  [inline, static]

Lock out other writers and update the count. Acts like a normal spin_lock/unlock. Don't need preempt_disable() because that is in the spin_lock already.

Parameters:
sl the sequence lock

Definition at line 95 of file rtseqlock.h.

static void rt_write_sequnlock ( seqlock_t *  sl  )  [inline, static]

Unlocks other writer and update the count again.

Parameters:
sl the sequence lock

Definition at line 107 of file rtseqlock.h.

static unsigned int rt_read_seqbegin ( const seqlock_t *  sl  )  [inline, static]

Start of read calculation -- fetch last complete writer token

Parameters:
sl the sequence lock
Returns:
a the value of the sl->sequence at the beginning before reading has started (in a SMP-safe manner)

Definition at line 121 of file rtseqlock.h.

static int rt_read_seqretry ( const seqlock_t *  sl,
unsigned int  iv 
) [inline, static]

Test if reader processed invalid data.

Using xor saves one conditional branch (it's the same as == here).

Parameters:
sl the sequence lock
iv the value that was fetched
Returns:
true if the read must be repeated and false otherwise

Definition at line 142 of file rtseqlock.h.


Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0