Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Dec 1996 10:01:37 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        scrappy@hub.org (Marc G. Fournier)
Cc:        terry@lambert.org, hackers@freebsd.org
Subject:   Re: Almost have mmap() figured, I think...
Message-ID:  <199612171701.KAA08511@phaeton.artisoft.com>
In-Reply-To: <Pine.NEB.3.95.961216212824.283H-100000@hub.org> from "Marc G. Fournier" at Dec 16, 96 09:38:34 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> size = mmap( 0, sizeof(int) * FRAMES, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0));
> for(i = 0; i < FRAMES; i++)
>   framesize[i] = start + i * sizeof(int);
> 
> ?

or:

start = mmap( 0, (sizeof(int)+FRAMESIZE)*FRAMES, PROT_READ|PROT_WRITE,...
for(i = 0; i < FRAMES; i++) {
  framesize[i] = start;
  start += sizeof(int);
}

for(i = 0; i < FRAMES; i++) {
  frame[i] = start;
  start += FRAMESIZE;
}

...and again, use only one mapping.


> > Also: Are you mapping in both the client and the server?  Or just
> > the server?
>
> 	Not quite sure what you mean here...client has:

[ ... ]

OK, you are mapping in both.

I don't know if you are allowed to have PROT_READ|PROT_WRITE in one and
only PROT_READ in the other; John Dyson would be the guy to ask...

> 	I'm using "Advanced Programming in the Unix Environment" by
> Stevens as my new "bible", and it states that "MAP_SHARED or MAP_PRIVATE
> must be specified"...unfortunately, his only "example" happens to have
> two different files MMAP'd, and then he's doing an memcpy() between 
> them :(  Is the above incorrect?

The Stevens book is the bible... but that example you might want to
consider most relevent is in the cp code in /src/bin/cp/utils.c.

John: there is still "#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED" in that
code... is that right now?


> 	Binary data, so this may be correct, since the "data" that I'm
> getting on the opposite end is exactly the same as the data on the server
> end...

Hey, if it's working, don't fix it.

Also: look in the -current list archive for the mmap() functionality
testing code that was posted a while back...


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612171701.KAA08511>