Home Online Manual
Top
Back: getcores
Forward: ring_lib
FastBack:
FastForward:
Up: resources_lib
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

D.2.11.4 semaphore

Procedure from library resources.lib (see resources_lib).

Usage:
semaphore(n), n int

Return:
the index of a new semaphore initialized with n.

Example:
 
LIB "resources.lib";
int sem = semaphore(1);
system("semaphore", "acquire", sem);
==> 1
system("semaphore", "try_acquire", sem);
==> 0
system("semaphore", "release", sem);
==> 1
system("semaphore", "try_acquire", sem);
==> 1