473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Questions about mmap()

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.
Apr 8 '08 #1
8 2394
"Unknown Soldier" <no****@nospam.comwrote in message
news:ft**********@aioe.org...
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?
You want news:comp.unix.programmer
Here is the POSIX reference:
http://www.opengroup.org/onlinepubs/.../xsh/mmap.html
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 am curious about what you expect to gain by memory mapping a socket.
** Posted from http://www.teranews.com **
Apr 8 '08 #2
"Dann Corbit" <dc*****@connx.comwrote in message
news:7d******************@news.teranews.com...
"Unknown Soldier" <no****@nospam.comwrote in message
news:ft**********@aioe.org...
>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?

You want news:comp.unix.programmer
Here is the POSIX reference:
http://www.opengroup.org/onlinepubs/.../xsh/mmap.html
>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 am curious about what you expect to gain by memory mapping a socket.
<Supremely OT>
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
</Supremely OT>
** Posted from http://www.teranews.com **
Apr 8 '08 #3
Unknown Soldier <no****@nospam.comwrites:
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) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 8 '08 #4
On 8 Apr 2008 at 20:18, Dann Corbit wrote:
"Dann Corbit" <dc*****@connx.comwrote 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.

Apr 8 '08 #5
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
Apr 8 '08 #6
On Tue, 08 Apr 2008 20:50:23 +0100, Unknown Soldier
<no****@nospam.comwrote in comp.lang.c:
Hello,

I have a couple queries about mmap() that ppl here might be able to help
with.
ppl doesn't participate in this group any more. We killed him and ate
his liver.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Apr 9 '08 #7
ppl
Jack Klein wrote:
ppl doesn't participate in this group any more. We killed him and ate
his liver.
But... Why?

Apr 9 '08 #8
>ppl doesn't participate in this group any more. We killed him and ate
>his liver.

But... Why?
Friends don't let friends void main().

Apr 10 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hao Xu | last post by:
Hi everyone! I found that if you want to write to the memory got by mmap(), you have to get the file descriptor for mmap() in O_RDWR mode. If you got the file descriptor in O_WRONLY mode, then...
4
by: Fabiano Sidler | last post by:
Hi folks! I created an mmap object like so: --- snip --- from mmap import mmap,MAP_ANONYMOUS,MAP_PRIVATE fl = file('/dev/zero','rw') mm = mmap(fl.fileno(), 1, MAP_PRIVATE|MAP_ANONYMOUS) ---...
2
by: beejisbrigit | last post by:
Hi there, I was wondering if anyone had experience with File I/O in Java vs. C++ using mmap(), and knew if the performance was better in one that the other, or more or less negligible. My...
1
by: James T. Dennis | last post by:
I've been thinking about the Python mmap module quite a bit during the last couple of days. Sadly most of it has just been thinking ... and reading pages from Google searches ... and very little...
1
by: koara | last post by:
Hello all, i am using the mmap module (python2.4) to access contents of a file. My question regards the relative performance of mmap.seek() vs mmap.tell(). I have a generator that returns...
2
by: Neal Becker | last post by:
On linux, I don't understand why: f = open ('/dev/eos', 'rw') m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) gives 'permission denied', but...
0
by: Kris Kennaway | last post by:
If I do the following: def mmap_search(f, string): fh = file(f) mm = mmap.mmap(fh.fileno(), 0, mmap.MAP_SHARED, mmap.PROT_READ) return mm.find(string) def mmap_is_in(f, string): fh =...
0
by: Gabriel Genellina | last post by:
En Thu, 29 May 2008 19:17:05 -0300, Kris Kennaway <kris@FreeBSD.org> escribió: Looks like you should define the sq_contains member in mmap_as_sequence, and the type should have the...
1
by: magnus.lycka | last post by:
Does anyone recognize this little Python crasher? I'll file a bug report unless someone notices it as an already documented bug. I found some open mmap bugs, but it wasn't obvious to me that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.