PatchworkOS
Loading...
Searching...
No Matches
lock_t Struct Reference

A simple ticket lock implementation. More...

#include <lock.h>

Data Fields

atomic_uint16_t nextTicket
 
atomic_uint16_t nowServing
 
uint32_t canary
 
uintptr_t calledFrom
 

Detailed Description

A simple ticket lock implementation.

This lock disables interrupts when acquired, and restores the interrupt state when released. It is not recursive, and attempting to acquire a lock that is already held by the same CPU will result in a deadlock.

In debug builds, the lock contains a canary value to detect memory corruption and a deadlock detection mechanism that will panic if a deadlock is detected.

Definition at line 42 of file lock.h.

Field Documentation

◆ calledFrom

uintptr_t lock_t::calledFrom

Definition at line 48 of file lock.h.

◆ canary

uint32_t lock_t::canary

Definition at line 47 of file lock.h.

◆ nextTicket

atomic_uint16_t lock_t::nextTicket

Definition at line 44 of file lock.h.

◆ nowServing

atomic_uint16_t lock_t::nowServing

Definition at line 45 of file lock.h.


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