Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Dec 1996 21:38:34 -0500 (EST)
From:      "Marc G. Fournier" <scrappy@hub.org>
To:        Terry Lambert <terry@lambert.org>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Almost have mmap() figured, I think...
Message-ID:  <Pine.NEB.3.95.961216212824.283H-100000@hub.org>
In-Reply-To: <199612170201.TAA07421@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 16 Dec 1996, Terry Lambert wrote:

> start = mmap( 0, FRAMESIZE * FRAMES, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0));
> for( i = 0; i < FRAMES; i++)
> 	frame[i] = start + i * FRAMESIZE;
>
	Okay, that one makes sense...

	Then, would it make sense to also have:

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);

?

> And use one file... 8-).
>
	Okay, will convert that over...makes for one less point of failure :)

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

====
  while(ii < FRAMES) {
    if((fd = open(framestr, O_RDONLY)) < 0) {
      exit(-1);
    }
    if((video[ii] = mmap(0, FRAMESIZE, PROT_READ, MAP_SHARED, fd, 0)) ==
          (caddr_t) -1) {
      exit(-1);
    }
    close(fd);
 
    /* Get Video Stream Buffer */
    if((fd = open(framestr, O_RDONLY)) < 0) {
      exit(-1);
    }
    if((vsize[ii] = mmap(0, sizeof(int), PROT_READ, MAP_SHARED, fd, 0)) ==
          (caddr_t) -1) {
      exit(-1);
    }
    close(fd);
 
    ii++;
  }
====

	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 problem comes up when I try and print out the frame itself,
> > using 'printf("%s\n", frame[ii]);'...the value printed out each time
> > is exactly the same: <FF><D8><FF><E0>
> 
> What is the data in the frame?  Maybe that's right?  printf("%s", ...)
> will stop printing if it hit a <FF><D8><FF><E0><00>...
> 
	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...

Marc G. Fournier                                 scrappy@hub.org
Systems Administrator @ hub.org              scrappy@freebsd.org




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.95.961216212824.283H-100000>