Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct bsem:
- int futex;
- void init( &bsem ):
- bsem.futex = 0 // niezablokowany
- wait( &bsem ):
- while( TRUE ):
- if ( compare_and_swap(bsem.futex,0,1) == 0) // jesli byl niezablokowany to zamien na 1 (zablokuj)
- break;
- futex(bsem.futex, WAIT, 1); // jeśli był 1 to śpij
- signal( &bsem ):
- if compare_and_swap( bsem.futex, 1, 0) == 1:
- futex( bsem.futex, WAKE, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement