Мне нужно синхронизировать N клиентских процессов с одним сервером. Эти процессы разветвляются основной функцией, в которой я объявил 3 семафора. Я решил использовать семафоры POSIX, но я не знаю, как делиться ими между этими процессами. Я думал, что общая память должна работать правильно, но у меня есть некоторые вопросы:
- Как я могу выделить нужное пространство памяти в моем сегменте?
- Можно ли использовать
sizeof(sem_t)
вsize_t
полеshmget
для того, чтобы выделить именно то пространство, в котором я нуждаюсь? - Есть ли у кого-нибудь примеры, подобные этой ситуации?