Locking

Description | Download | Table of Contents | Modules | Compound List | File List | Functions


Overview
Compiler
Documentation
Examples
Misc
Help
IDE & Tools

Download
Install

Links
Projects







Functions

__inline__ unsigned short lock (void)
 Lock the processor to prevent interrupts to occur. More...

__inline__ void unlock (void)
 Unlock the processor to accept interrupts. More...

__inline__ void restore (unsigned short mask)
 Restore the interrupt mask of the processor. More...


Detailed Description

Locking operations are defined to allow the use of two strategies to protect critical sections from interrupts:

Lock/Unlock
This simple strategy consists in disabling interrupts (sei ) and enabling them after the critical section. In general, this method assumes the processor accepts interrupts when lock() is called. This strategy is not suitable to implement functions that will be called with interrupts masked because this will create a side-effect: enable interrupts.

Example:

        lock ();
        ...
        unlock ();
      

Lock/Restore
This strategy is suitable to protect critical sections in functions that will be called with interrupts masked. The processor mask is saved before locking interrupts. It is restored at the end of the critical section. When entering the critical section, if interrupts are masked, they will remain masked at end of critical section. There is no side effect.

Example:

        unsigned short mask;

        mask = lock ();
        ...
        restore (mask);
      

Function Documentation

__inline__ unsigned short lock ( void ) [static]
 

Lock the processor to prevent interrupts to occur.

Lock the processor to prevent interrupts to occur. When the processor is locked, interrupts are not accepted. They are deferred until the processor is unlocked. The previous locking mask is returned in the high part (bits 15..8) to avoid a tab instruction.

Returns:
the previous locking mask.
See also:
unlock, restore

Definition at line 86 of file asm-m68hc11/locks.h.

__inline__ void restore ( unsigned short mask ) [static]
 

Restore the interrupt mask of the processor.

Restore the interrupt mask of the processor. The mask is assumed to be in the high part (bits 15..8) to avoid a tba instruction.

Parameters:
mask   the previous interrupt mask to restore
See also:
lock, unlock

Definition at line 113 of file asm-m68hc11/locks.h.

__inline__ void unlock ( void ) [static]
 

Unlock the processor to accept interrupts.

Unlock the processor to accept interrupts. When the processor is unlocked, interrupts are accepted. Use this operation if you want, authoritatively, accept the interrupts.

See also:
lock, restore

Definition at line 101 of file asm-m68hc11/locks.h.

Description | Download | Table of Contents | Modules | Compound List | File List | Functions

    Last modified,
    Apr 16, 2001
[ Copying ]     [ Feedback to Stephane.Carrez@worldnet.fr ]