Skip to content

Zone

Critical zone synchronization utilities.

#include <sync/zone.h>

Constants

Name Value Description
IN_ZONE(zptr) Zone enter and exit wrapper.

Structures

Zone

Struct describing a zone.

Field Type Description
owner Tid Current owner. -1 means no owner.
locked _Atomic int Atomic integer showing the zone is entered.
event Handle On contention, the event to use.

Functions

ZoneInit

Err ZoneInit(Zone *z);

Create a Zone.

Parameter Direction Description
z in Pointer to a zone object to initialize.

Returns: ZUZU_OK on success, negative error code if the Event object couldn't be created.

ZoneDestroy

Err ZoneDestroy(Zone *z);

Destroy a Zone.

Parameter Direction Description
z in Pointer to a zone object to destroy.

Returns: ZUZU_OK on success, negative error code if the Event object couldn't be destroyed.

ZoneEnter

Err ZoneEnter(Zone *z);

Try entering a Zone and block if it is occupied.

Parameter Direction Description
z in The zone to enter to.

Returns: ZUZU_OK on success.

ZoneExit

void ZoneExit(Zone *z);

Exit a Zone.

Parameter Direction Description
z in The zone to exit from.

ZoneTryEnter

Err ZoneTryEnter(Zone *z);

Try entering a Zone and return with an error if occupied.

Parameter Direction Description
z in The zone to enter to.

Returns: ZUZU_OK on success, ERR_BUSY if the zone is occupied.