BS2000-LMS
view release on metacpan or search on metacpan
979899100101102103104105106107108109110111112113114115116117#define MAX_TOC_ID 10
int
g_toc_semaphor = 0;
int
g_toc_id_used[MAX_TOC_ID] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/************************************************************************/
/* Description: */
/* -------------------------------------------------------------------- */
/*
lock
the poor man's semaphor: */
/* -------------------------------------------------------------------- */
/* Parameter: - */
/* Result : 1
if
semaphor got locked, 0 otherwise */
/************************************************************************/
int
lock_semaphor() /* invariant (proof
for
correctness): */
{
int
l_iCountdown = 10; /* g_toc_semaphor >= 0 */
++g_toc_semaphor; /* g_toc_semaphor >= 1 */
while
(1 < g_toc_semaphor) /* g_toc_semaphor>1 */
{ /* g_toc_semaphor >= 1 */
--g_toc_semaphor; /* g_toc_semaphor >= 0 */
if
(--l_iCountdown <= 0)
return
0;
( run in 0.568 second using v1.01-cache-2.11-cpan-55f5a4728d2 )