BS2000-LMS

 view release on metacpan or  search on metacpan

LMS.xs  view on Meta::CPAN

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#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 )