Click
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
SpinlockIRQ Class Reference

A spinlock that disables interrupts. More...

#include <sync.hh>

Public Types

typedef unsigned long flags_t
 

Public Member Functions

 SpinlockIRQ ()
 Creates a SpinlockIRQ.
 
flags_t acquire () CLICK_ALWAYS_INLINE
 Acquires the SpinlockIRQ.
 
void release (flags_t) CLICK_ALWAYS_INLINE
 Releases the SpinlockIRQ.
 

Detailed Description

A spinlock that disables interrupts.

The SpinlockIRQ class abstracts a spinlock, or polling mutex, that also turns off interrupts. Spinlocks are a type of mutual-exclusion lock in which acquiring the lock is a polling operation (basically a "while (lock.acquired()) do nothing;" loop). The SpinlockIRQ variant can be used to protect Click data structures from interrupts and from other threads. Very few objects in Click need this protection; the Click Master object, which protects the task list, uses it, but that's hidden from users. Spinlocks should not be held for long periods of time: use them for quick updates and such.

In the Linux kernel, SpinlockIRQ is equivalent to a combination of local_irq_save and the spinlock_t type.

The SpinlockIRQ operations are acquire(), which acquires the lock, and release(), which releases the lock.

It is NOT OK for a SpinlockIRQ thread to acquire a lock it has already acquired.

Constructor & Destructor Documentation

◆ SpinlockIRQ()

SpinlockIRQ::SpinlockIRQ ( )
inline

Creates a SpinlockIRQ.

Member Function Documentation

◆ acquire()

SpinlockIRQ::flags_t SpinlockIRQ::acquire ( )
inline

Acquires the SpinlockIRQ.

Returns
The current state of the interrupt flags.

◆ release()

void SpinlockIRQ::release ( flags_t  flags)
inline

Releases the SpinlockIRQ.

Parameters
flagsThe value returned by SpinlockIRQ::acquire().

The documentation for this class was generated from the following file: