#include <stdio.h>
#include <fcntl.h>
#include <semaphore.h>
int main() {
sem_t *semaphore;
int x;
semaphore = sem_open("example_semaphore", O_CREAT, 0644, 1);
// Use semaphore
x++;
sem_close(semaphore); // Close semaphore
sem_unlink("example_semaphore"); // Unlink semaphore from the system
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVkZSA8c2VtYXBob3JlLmg+CgppbnQgbWFpbigpIHsKICAgIHNlbV90ICpzZW1hcGhvcmU7CiAgICBpbnQgeDsKCiAgICBzZW1hcGhvcmUgPSBzZW1fb3BlbigiZXhhbXBsZV9zZW1hcGhvcmUiLCBPX0NSRUFULCAwNjQ0LCAxKTsKCiAgICAvLyBVc2Ugc2VtYXBob3JlCiAgICB4Kys7CgogICAgc2VtX2Nsb3NlKHNlbWFwaG9yZSk7IC8vIENsb3NlIHNlbWFwaG9yZQogICAgc2VtX3VubGluaygiZXhhbXBsZV9zZW1hcGhvcmUiKTsgLy8gVW5saW5rIHNlbWFwaG9yZSBmcm9tIHRoZSBzeXN0ZW0KICAgIHJldHVybiAwOwp9