From: cmlee@netcom.com (Chen-Ming Lee) Subject: mmap() error: "Out of memory" Date: Wed, 5 May 1993 09:04:40 GMT Hi all! I am trying to use mmap() to emulate share memory. However, it's always giving me "Out of memory" error no matter how I set it up. Has any one tried to use it with success? Here's a sample code: main() { int fd; char *mptr; fd=open("foo", O_RDONLY); mptr=mmap(0, sizeof(int),PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); /* ** At this point mptr gets the return value of -1 no matter how ** I vary the parameters to mmap(). */ } Thanks for the help! - Tom, cmlee@netcom.com -- Tom, cmlee@netcom.com, cmlee@soda.berkeley.edu --
From: haible@ma2s3.uucp (Bruno Haible) Subject: Re: mmap() error: "Out of memory" Date: 5 May 1993 16:33:22 GMT cmlee@netcom.com (Chen-Ming Lee) writes: > main() > { > int fd; > char *mptr; > > fd=open("foo", O_RDONLY); > mptr=mmap(0, sizeof(int),PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); > /* > ** At this point mptr gets the return value of -1 no matter how > ** I vary the parameters to mmap(). > */ > } You cannot use O_RDONLY in combination with PROT_WRITE. Use O_RDONLY and PROT_READ if you want read access only, O_RDWR and PROT_READ|PROT_WRITE if you need read/write access to your file "foo". Bruno Haible haible@ma2s2.mathematik.uni-karlsruhe.de
From: sct@dcs.ed.ac.uk (Stephen Tweedie) Subject: Re: mmap() error: "Out of memory" Date: 6 May 93 11:57:44 GMT On 5 May 93 09:04:40 GMT, cmlee@netcom.com (Chen-Ming Lee) said: > I am trying to use mmap() to emulate share memory. However, it's > always giving me "Out of memory" error no matter how I set it up. > Has any one tried to use it with success? No! Linux does not yet have full mmap() support. If you want shared memory, you can get the excellent ipcdelta set of Linux patches which implement the SysV IPC routines - shared memory, message queues and semaphores. Cheers, Stephen Tweedie. --- Stephen Tweedie < sct@uk.ac.ed.dcs> (Internet: < sct@dcs.ed.ac.uk>) Department of Computer Science, Edinburgh University, Scotland.