Inter Process Communication

unix IPC
i would like to know the method of usage of semaphores on shared memory segments the topic seems very difficult to understand mainly when difrent proceses communicate instantly and how do i avaoid deadlock situation

Semaphores are just flags that a program (programmer) uses to see if the flags are set or clear. By kernel rules, so to speak, the flags are guarenteed to be atomic.

When reading and writing shared memory, you must wrap your opens, reads and writes in each process to check the a semaphore to see if it is set or clear.

Semaphores can be used with lots of things, however they are often used as you ask, with shared memory access.

A very good book to read on the complete subject of IPC in Unix is
"Unix Network Programming"

by Prentice Hall

ISBN 0-13-949876-1

It just about covers the lot.