Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!usc!wuarchive!emory!kd4nc!n4hgf!wht From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker) Newsgroups: comp.unix.wizards Subject: Re: shmat() system call? Keywords: shmat() systemV Message-ID: <187@n4hgf.Mt-Park.GA.US> Date: 16 Aug 90 02:37:45 GMT References: <27@astph.UUCP> Reply-To: wht@n4hgf.UUCP (Warren Tucker) Organization: Amateur Radio Station N4HGF Lines: 50 In article <27@astph.UUCP> jeff@astph.UUCP (8592x2) writes: > >Question concerning the shared memory attach call: > >I am writing a shared memory allocation manager for a multi-user >database. >I need to know if additional attaches by other processes will be >guaranteed to return the same address as that the first process >was returned. To be sure, specify the attach address, regardless of what the FM says. Make a small program that passes 0 for the address and see what it returns. Then, use that value hardcoded, possibly #defined for each arcitecture you plan to run the program on. I.E., /*---------------------- header file --------------------*/ #if defined(M_I286) #define SHMPTR char far * #define SYSPTR struct system_control * #else #define SHMPTR char * #define SYSPTR struct system_control * #endif #if defined(M_SYS5) #if defined(M_I386) #define SHM_ATTACH_ADDR ((SHMPTR)0x67000000L) /* 386 */ #else #define SHM_ATTACH_ADDR ((SHMPTR)0x00670000L) /* 286 */ #endif #else /* not xenix */ #ifdef (pyr) #define SHM_ATTACH_ADDR ((SHMPTR)0xC0000000L) /* PYRAMID */ #else #define SHM_ATTACH_ADDR ErrorInHeaderFile #endif #endif /*---------------------- code file --------------------*/ if((sys = shmat(*pshmid,SHM_ATTACH_ADDR,0)) != (SHMPTR)SHM_ATTACH_ADDR) { /* attach error: either returned (SHMPTR)-1 or wrong address */ } ----------------------------------------------------------------------- Warren Tucker, TuckerWare gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US "Tell the moon; don't tell the March Hare: He is here. Do look around."