0

I am writing in C a program with using Producer-Consumer.

I have a process comunicating with N consumers via a shared memory. In order to achieve this I am using semaphores. However my process needs to wait uncertain time for a consumer to send some data.

Is there any way to achieve this besides sleep(1) and keep checking for new data? In worst case this could lead to 1 second delay (process sleeps and consumer writes right after sleep).

I am using 1 set of 2 semaphores (1 semaphore for a priority queue between consumers and 1 semaphore for main process - consumer in critical section).

Magnus Hoff
  • 21,529
  • 9
  • 63
  • 82
user2147971
  • 135
  • 4

0 Answers0