gPTP Documentation
|
#include <linux_hal_common.hpp>
Public Member Functions | |
bool | lock (bool *got=NULL) |
Lock mechanism. Gets a ticket and try locking the process. More... | |
bool | unlock () |
Unlock mechanism. Increments the release counter and unblock other threads waiting for a condition flag. More... | |
bool | init () |
Initializes all flags and counters. Create private structures. More... | |
TicketingLock () | |
~TicketingLock () | |
TicketingLock: Implements the ticket lock algorithm. A ticket lock consists of two counters, one containing the number of requests to acquire the lock, and the other the number of times the lock has been released. A processor acquires the lock by performing a fetch and increment operation on the request counter and waiting until the result its ticket is equal to the value of the release counter. It releases the lock by incrementing the release counter.
TicketingLock::TicketingLock | ( | ) |
Default constructor sets some flags to false that will be initialized on the init method. Protects against using lock/unlock without calling init.
TicketingLock::~TicketingLock | ( | ) |
Deletes the object and private structures.
bool TicketingLock::init | ( | ) |
Initializes all flags and counters. Create private structures.
bool TicketingLock::lock | ( | bool * | got = NULL | ) |
Lock mechanism. Gets a ticket and try locking the process.
got | [out] If non-null, it is set to TRUE when the lock is acquired. FALSE otherwise. |
bool TicketingLock::unlock | ( | ) |
Unlock mechanism. Increments the release counter and unblock other threads waiting for a condition flag.