Mistake on this page?
Report an issue in GitHub or email us
Static Public Member Functions
CriticalSectionLock Class Reference

RAII object for disabling, then restoring, interrupt state Usage: More...

#include <CriticalSectionLock.h>

Static Public Member Functions

static void enable ()
 Mark the start of a critical section. More...
 
static void disable ()
 Mark the end of a critical section. More...
 

Detailed Description

RAII object for disabling, then restoring, interrupt state Usage:

// RAII style usage
unsigned int atomic_counter_increment(unsigned int &counter) {
CriticalSectionLock lock;
// Code in this block will run with interrupts disabled
// Interrupts will be restored to their previous state automatically
// at the end of function scope
return ++counter;
}
// free locking usage
unsigned int atomic_counter_decrement(unsigned int &counter) {
// Code in this block will run with interrupts disabled
counter--;
CriticalSectionLock::disable(); // need explicitly to disable critical section lock
// interrupts will be restored to their previous state here
return counter;
}

Definition at line 56 of file CriticalSectionLock.h.

Member Function Documentation

static void disable ( )
static

Mark the end of a critical section.

static void enable ( )
static

Mark the start of a critical section.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.