Xref: utzoo comp.lang.c:32167 comp.unix.programmer:92 Path: utzoo!attcan!uunet!jarthur!usc!julius.cs.uiuc.edu!apple!agate!linus!nixbur!nixpbe!peun11!josef From: josef@nixpbe.UUCP (Moellers) Newsgroups: comp.lang.c,comp.unix.programmer Subject: Re: shared memory Keywords: shared memory Message-ID: Date: 24 Sep 90 06:33:21 GMT References: <566@gestetner.oz> Sender: news@nixpbe.nixdorf.de Followup-To: comp.lang.c Lines: 45 In <566@gestetner.oz> andrew@gestetner.oz (Andrew Hunt) writes: >I am having problems with UNIX shared memory system functions >(shmget, shmctl, shmop) - our system is SUN O/S 4.0.x. >I am trying to attach some data to a shared memory identifier. > assign global_start_address > assign global_size > global_shmid = shmget(IPC_PRIVATE,global_size,0777|IPC_CREAT); > shmat(global_shmid,global_start_address,SHM_RDONLY); >The shmget is always successful but the shmat fails. I have tried >to assign the global_start_address to many different sizes and >addresses. The addresses I have tried have been from malloc'ed memory, >stack space, initialised data space, uninitialised data space.... >I have experimented with changing permissions and have changed most of >the parameters but the only thing that has worked is to set > global_start_address = (char *)0; >which allow the system to find some space for me. >Does anyone know what areas of memory can be legally attached to >shared memory? The system will ALLWAYS find space for You. It's YOUR task to tell it ^^^^^ where to put it. ^^^^^ The address where to put it ("global_start_address") must not result in part or all of the shared memory segment overlaying part or all of Your allocated virtual address space. So: break <= global_start_address < SP - global_size Try something like global_start_address = 0x80000000, which, on a 32 bit system, should put the shared memory segment in the middle of Your 4GB virtual address space. -- | Josef Moellers | c/o Nixdorf Computer AG | | USA: mollers.pad@nixdorf.com | Abt. PXD-S14 | | !USA: mollers.pad@nixdorf.de | Heinz-Nixdorf-Ring | | Phone: (+49) 5251 104662 | D-4790 Paderborn |