From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,2453cc2dc48eb971 X-Google-Attributes: gidfc89c,public X-Google-Thread: fee84,2453cc2dc48eb971 X-Google-Attributes: gidfee84,public From: magrasjc@texas.net Subject: Re: mmap/shared memory and mutex/semaphores Date: 1997/06/12 Message-ID: <33A0C144.5498@texas.net>#1/1 X-Deja-AN: 248033537 References: <339F1672.1396@texas.net> Organization: Texas Networking, Inc. Newsgroups: comp.unix.osf.osf1,comp.unix.programmer magrasjc@texas.net wrote: > > Greetings fellow unixheads, > > I need to use a posix semaphore to control access to shared memory. > > This thing is giving me problems. Any experience especially when > to invalidate the shared memory/mapped file segment since the > data space and semaphore will be handled together. Some updates and new questions. I have found that if the server in this relationship "broadcasts" the address returned by calling mmap() with the first paramater=0 and the clients call mmap with the broadcasted (via shared memory) address as the first paramater to mmap() and fourth value containing MAP_FIXED. I got what I wanted a mmap()'ed file whose mapped space starts with 3 posix semaphores. I dont know if the 3 posix semaphores are wise. The posix semaphores+shmget() shared mem+mmap() are all inside 1 C++ object. The constructors work fine for clients and server processes. The server tries to read and blocks correctly. The client tries to write and the mmap descriptor returned in no longer valid. Suggestions? other info POSIX inter-process mutexes are optional. The first posixsem guards access to the client server transaction. the second posixsem is for controlling server access. the third posixsem is controlling client access to the mmap()'d file. Thanks in advance for your advice, J.C. Magras -- Unix Software Engineer looking for C++/UNIX/Motif/Perl/Tk/Flex Software Engineering position **NOW**. Currently in Austin at (512) 672-5778/magrasjc@texas.net. have Answering machine.