473,656 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2414
"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.progr ammer. The mmap() function is defined by POSIX, not by
the C language standard.

--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
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.progr ammer 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.l earn.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
3528
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 writing to the memory got by mmap() will lead to segmentation fault. Anyone knows why? Is this a rule or a bug? What if I just want to write to the file and nothing else?
4
3696
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) --- snap --- Now, when I try to resize mm to 10 byte
2
4923
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 instinct would say C++ is faster, but Java has made some improvements with its FileChannel class.
1
5460
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 of it as been coding. Mostly it's just academic curiosity (I might be teaching an "overview of programming" class in a few months, and I'd use Python for most of the practical examples to cover a broad range of programming topics, including the...
1
2689
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 stuff from the file, piece by piece. Since other things may happen to the mmap object in between consecutive next() calls (such as another iterator's next()), i have to store the file position before yield and restore it afterwards by means of tell()...
2
4627
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 this c++ code works: #include <sys/mman.h> #include <fcntl.h>
0
1142
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 = file(f)
0
1116
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 Py_TPFLAGS_HAVE_SEQUENCE_IN flag set (all in mmapmodule.c) -- Gabriel Genellina
1
1671
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 this problem was one of those... Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for more information. Segmenteringsfel (core dumped)
0
8382
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.