Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Dec 1996 19:12:25 -0500 (EST)
From:      "Marc G. Fournier" <scrappy@hub.org>
To:        hackers@freebsd.org
Subject:   Thanks to all (re: MMAP)
Message-ID:  <Pine.NEB.3.95.961217190125.8167C-100000@hub.org>

next in thread | raw e-mail | index | archive | help

Hi...

	Thanks to everyone for the invaluable help with getting
this mmap() stuff understood...

	The most recent problem that I was seeing was *purely*
a coding error, and nothing more :(  Everything else works like a
charm :)

	Terry...thanks for the pointers about how to reduce the
number of maps required...will implement that final one, of 
merging sizeof(int) + FRAMESIZE, tonight...

	But, have one question concerning that first.

	When I do the socket and want to send the size across the
socket, I use:

	write(sockfd, (char *)&datasize, sizeof(datasize));

	How would I do similar with the mmap()'d region?  What
I'm doing right now is, other then inefficient:


  for (;;) {
    for(ii = 0; ii < FRAMES; ii++) {
      readn(sockfd, (char *)&datasize, sizeof(datasize));
      if (datasize == 0)
        break;

      sprintf(vsize + (ii * sizeof(int)), "%d", datasize);
      readn(sockfd, video + (ii * FRAMESIZE), datasize);

    }
  }


	Is this as correct as any other way?  I know it works, but
if I merge the two into one mmap'd region, I would think I'd be
looking at something like:


  for (;;) {
    for(ii = 0; ii < FRAMES; ii++) {
      readn(sockfd, (char *)&datasize, sizeof(datasize));
      if (datasize == 0)
        break;

      sprintf(vsize + (ii * (sizeof(int) + FRAMESIZE)), "%d", datasize);

      readn(sockfd, video + (ii * (sizeof(int) + FRAMESIZE)) + sizeof(int), 
            datasize);

    }
  }

	But I would have thought that there was a better method of doing
the sprintf() above?  Somehow, it *feels* wrong...

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.961217190125.8167C-100000>