Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Questions about mmap()

Reply
Thread Tools

Questions about mmap()

 
 
Unknown Soldier
Guest
Posts: n/a
 
      04-08-2008
Hello,

I have a couple queries about mmap() that ppl here might be able to help
with.

1. What's the best way to resize an mmap()d area when you've enlarged
the file? Can you call mmap() again with the existing mapped location,
or do you need to remap it from scratch?

2. If I have a file descriptor returned by a call to socket(), can I
used mmap() as an alterantive to read()? Will there be problems
depending on whether the socket is blocking?

Thanks.
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      04-08-2008
Unknown Soldier wrote, On 08/04/08 20:50:
> Hello,
>
> I have a couple queries about mmap() that ppl here might be able to help
> with.


<snip>

The people over on comp.unix.programmer are more likely to be able to
provide quality help on this since I am guessing you are using the Unix
mmap function. mmap is a system extension rather than being part of the
C language as defined by the C standard.
--
Flash Gordon
 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      04-08-2008
On 8 Apr 2008 at 19:50, Unknown Soldier wrote:
> Hello,
>
> I have a couple queries about mmap() that ppl here might be able to help
> with.
>
> 1. What's the best way to resize an mmap()d area when you've enlarged
> the file? Can you call mmap() again with the existing mapped location,
> or do you need to remap it from scratch?


There's no guarantee that the original mapping is contained in a large
enough space in the process's virtual address space for the new mapping
to fit, so you really need to unmap and the remap the whole thing.

On Linux, there's an mremap function that takes care of this for you
(it's analogous to realloc), but you should be aware that this function
isn't in POSIX, so relying on it will make your program non-portable.

> 2. If I have a file descriptor returned by a call to socket(), can I
> used mmap() as an alterantive to read()? Will there be problems
> depending on whether the socket is blocking?


I don't think so - what would that even mean? It doesn't make sense.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      04-08-2008
Unknown Soldier <(E-Mail Removed)> writes:
> I have a couple queries about mmap() that ppl here might be able to
> help with.

[snip]

Some people here might try, but you'll get better answers in
comp.unix.programmer. The mmap() function is defined by POSIX, not by
the C language standard.

--
Keith Thompson (The_Other_Keith) <(E-Mail Removed)>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      04-08-2008
On 8 Apr 2008 at 20:18, Dann Corbit wrote:
> "Dann Corbit" <(E-Mail Removed)> wrote in message
>> I am curious about what you expect to gain by memory mapping a socket.

>
> I guess that there is a benefit:
> Multiple outstanding I/O operations on a single file descriptor using
> threads:
> http://www.squid-cache.org/mail-arch...9805/0139.html


That's an interesting (albeit bizarre) idea... as far as I can see,
though, all the sample code on that page first mmaps a file, then
read()s from a socket into the mmap'd area, rather than actually
attempting to mmap the socket itself.

 
Reply With Quote
 
ppl
Guest
Posts: n/a
 
      04-09-2008
Jack Klein wrote:

> ppl doesn't participate in this group any more. We killed him and ate
> his liver.
>


But... Why?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Few Questions (HW questions already answered by me) padh.ayo@gmail.com C Programming 10 12-06-2006 05:48 PM
Malloc and free questions - learner questions pkirk25 C Programming 50 10-04-2006 02:22 PM
Questions on Canon 300D and etc. questions regarding digital photography Progressiveabsolution Digital Photography 12 03-24-2005 05:18 PM
Newbie questions - Couple of VC++ questions regarding dlls and VB6 Ali Syed C Programming 3 10-13-2004 10:15 PM
Re: Questions....questions....questions Patrick Michael A+ Certification 0 06-16-2004 04:53 PM



Advertisments