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

D.15.19.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