C program

Can anyone tell me how to.....

program to create multiple threads (one master thread and rest worker threads) and using the threads write into and read from shared memory

Restrictions:

Only one thread should be able to read at any instant of time into shared memory region.

Only one thread should be able to write at any instant of time into shared memory region.

Worker threads should inform the master thread after every read and write operation.

Master thread inform the worker thread (which is waiting to acquire shared memory region) that read or write operation is successful and it can acquire the memory for either reading and writing operations.

ok, whats your doubt here ?

Post us what you have tried so far.

What is the difficult here ? How could we help you progress further ? :slight_smile:

I have attached "C program". In the program I am trying to create shared memory. I am also trying to create multiple threads to read and write into shared memory. I am able to create shared memory and number of threads (reader and writer threads) but I am not able to perform read and write operations using the theads.

Could you please check the program and modify it.