| Steve Graegert 2004-10-29, 5:52 pm |
| djake@excite.it wrote:
> Do you know how to syncronize under unix two processes to access a
> shared memory (read/write) in a non-blocking way. Therefore to have
> error when the memory is already locked (and not timout).
>
> Do you know how to do?
The solution would be the use of the following set of functions: shmget,
shmctl, shmat and shmdt. This involves IPC and is suitable for use with
unrelated processes. To synchronize access to regions of shared memory
you may want to incorporate semaphores. If you are using an SVR4-based
system, /dev/zero may also help. I can't provide a working sample (no
UNIX machine at hand). For more information on shared memory via IPC
take a look at this one: http://www.cs.cf.ac.uk/Dave/C/node27.html.
\Steve
|