[comp.sys.mips] mmap

drclark@daisy.waterloo.edu (David R. Clark) (06/03/91)

The following program (actually a slight variation of it) works on one of
our local systems (Sequent).  On an M2000 running 4.51 the call to mmap fails
(invalid arguments).  Any ideas?  What I really want to do is choose an arbitrary
region of memory that does not overlap the current program or data space and then
map data into the region.  Until I get the simple version working though, I am stuck.

#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
main() {

	int f;
	int t;
	char *s;

	f = open("AND",O_RDWR,0);

	if (f == -1) perror("open");

	s = malloc(getpagesize());
	if (mmap(s,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,f,0) == -1)
		perror("mmap");
	printf("%s",s);
}

trevc@tecate.mips.com (Trevor Cotton) (06/03/91)

In article <1991Jun3.151307.20857@watdragon.waterloo.edu>, drclark@daisy.waterloo.edu (David R. Clark) writes:
|> The following program (actually a slight variation of it) works on one of
|> our local systems (Sequent).  On an M2000 running 4.51 the call to mmap fails
|> (invalid arguments).  Any ideas?  What I really want to do is choose an arbitrary
|> region of memory that does not overlap the current program or data space and then
|> map data into the region.  Until I get the simple version working though, I am stuck.
|> 
|> #include <sys/mman.h>
|> #include <sys/types.h>
|> #include <fcntl.h>
|> main() {
|> 
|> 	int f;
|> 	int t;
|> 	char *s;
|> 
|> 	f = open("AND",O_RDWR,0);
|> 
|> 	if (f == -1) perror("open");
|> 
|> 	s = malloc(getpagesize());
|> 	if (mmap(s,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,f,0) == -1)
|> 		perror("mmap");
|> 	printf("%s",s);
|> }

RISC/os 4.5x supports only a subset of the mmap and munmap system calls.
Only mapping of character devices is allowed, and only one device can
be mapped by a process. 
What is "AND" in your example?

RISC/os 5.0 will add memory mapped file functionality that operates in
accordance with SVR4 semantics.

We hope to start beta testing of RISC/os 5.0 around the end of July.

-- 
--trevc--

  Trevor Cotton, Sustaining Engineering, MIPS Computer Systems Inc.
  MS 6-05, 930 DeGuigne Drive, Sunnyvale, CA 94088-3650
  Tel: +1 408 524 7286  Fax: +1 408 524 7521
  Email: {wyse,ames,decwrl,pyramid}!mips!trevc    trevc@mips.com

amir@smsc.sony.com (Amir 806) (06/06/91)

In article <4210@spim.mips.COM> trevc@mips.com writes:
>In article <1991Jun3.151307.20857@watdragon.waterloo.edu>, drclark@daisy.waterloo.edu (David R. Clark) writes:
>|> The following program (actually a slight variation of it) works on one of
>|> our local systems (Sequent).  On an M2000 running 4.51 the call to mmap fails
>|> (invalid arguments).  Any ideas? ....
>
>RISC/os 4.5x supports only a subset of the mmap and munmap system calls.
>Only mapping of character devices is allowed, and only one device can
>be mapped by a process. 
>What is "AND" in your example?
 
AND is any ordinary file I think.  Anyway, it does fail on our MIPS box.

>RISC/os 5.0 will add memory mapped file functionality that operates in
>accordance with SVR4 semantics.
>
>We hope to start beta testing of RISC/os 5.0 around the end of July.
>

Good.  I just tested this on our SVR4 port and it works fine.



-- 
Amir H. Majidimehr
Operating Systems Group
Sony Microsystems
amir@sony.com  | ...!{uunet,mips}!sonyusa!amir

drclark@daisy.uwaterloo.ca (David R. Clark) (06/06/91)

I had responded by email but for those interested, the file AND was a regular
file and so not map-able under 4.5x .  Thanks again.