Shared Memory SYS V
Jerry Feldman
gaf at blu.org
Mon Sep 20 10:30:01 EDT 2004
On Mon, 20 Sep 2004 08:47:50 -0500 (EST)
Anthony Gabrielson <agabriel at home.tzo.org> wrote:
> Hello,
> I'm going to preface this question with its homework... I'm
> looking for some good examples of shmat with threads on the web.
> Either that or a good explanation. I need to use it in homework, and
> I will be away on a business trip the night its discussed. So if
> anyone has a good example or a good explantion of how to use it with
> its tools I would appreciate it.
You are talking two different things. shmat(2) is one of the shared
memory system calls. Normally, one would use semaphores (semop(2)) to
protect access to a shared region.
Threads is a different animule. POSIX threads use mutexes to protect
access to shared memory. However, using a mutex to protect a shared
memory object (shmat(2)) only provides protection from multiple threads
in the same process where semaphores are used between processes.
Additionally, threads would share memory defined locally within the
process.
I've used both shared memory (shmat(2)) and threads. I've also used
fcntl locking as a protection mechanism.
--
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20040920/3b1659f0/attachment.sig>
More information about the Discuss
mailing list