Shared Memory using thread in C on AIX

I am looking for C program source code. Could you please help me in finding the source code required mentioned below.

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.

thats a tiny program.you can

Anonymous's picture

thats a tiny program.you can write it by yourself.

for example:

in example.c...
function main() is the master function.worker1()&worker2() run as worker thread.
they share a buffer which defined as global var at the beginning.

the buffer need a synchronous lock.
lock it before read or write,and unlock it after read or write.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Webcast
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up and watch now

Sponsored by Skybot