BS2000-LMS

 view release on metacpan or  search on metacpan

LMS.xs  view on Meta::CPAN

#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.228 second using v1.01-cache-2.11-cpan-55f5a4728d2 )