Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site anasazi.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!noao!terak!anasazi!duane From: duane@anasazi.UUCP (Duane Morse) Newsgroups: net.unix Subject: Re: Shared Memory Message-ID: <162@anasazi.UUCP> Date: Tue, 23-Apr-85 11:05:02 EST Article-I.D.: anasazi.162 Posted: Tue Apr 23 11:05:02 1985 Date-Received: Fri, 26-Apr-85 06:45:08 EST References: <303@cvl.UUCP> Distribution: net Organization: Anasazi, Phoenix Az. Lines: 33 > > > > > How do you pass a key from one process to > > > > another process so that both processes have acess to the > > > > same "shmid"? > The above article from mod.unix seems > to be about what I'm trying to do, but I have been unable to find ANY > references in our on-line documentation to ftok() or sdtipc... Are they > for 4.2BSC, or Sys V, or what? We had the same need and essentially invented ftok before we stumbled across it. The basic idea is to create a file and to use the file's inode number (with the possible addition of a identifying character) as the key for a shared memory segment. Unix guarantees that the inode number will be unique within a file system, so as long as all of your shared memory "files" are on the same file system, you shouldn't have any problem with duplicate keys. Further, since only the inode number of the shared memory "file" is needed, the file itself can be of 0 length, thus saving 1K that would otherwise be allocated. The addition of an identifying character to the full key (inode numbers are shorts, so you have another 16 bits to play with in the shared memory key) serves two purposes. First, it may be needed to avoid conflicts with shared memory keys that don't follow the above scheme. Second, it provides flexibility in your naming conventions. For instance, perhaps it would be more convenient for you to have only one shared memory "file" and a number of different identifiers for different memory segments. Duane Morse International Anasazi @ Phoenix "file" is