wargames/semtex/semtex12.sem.c
int try_down(int *sem)
{
        if(*sem)
                return 0;
        (*sem)++;
        if(*sem > 1) {
                (*sem)--;
                return 0;
        }
        return *sem;
}
/* Try and get the semaphore, but return 0 if held */
Try and get the semaphore, but return 0 if held
Try and get the semaphore but return 0 if held
int try_down(int *sem)
{
        if(*sem)
                return 0;
        (*sem)++;
        if(*sem > 1) {
                (*sem)--;
                return 0;
        }
        return *sem;
}
int try_down ( int * sem ) { if ( * sem ) return 0 ; ( * sem ) ++ ; if ( * sem > 1 ) { ( * sem ) -- ; return 0 ; } return * sem ; }
Try and get the semaphore, but return 0 if held
Try and get the semaphore but return 0 if held