Re: how to best map/buffer a file to memory by being able to lock sequences thread-safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dennis Heuer wrote:

> i did not try obstacks yet, will have a look at them. what bothers me
> at the moment is that mremap() is not a standard and that it operates
> strangely to me:
> 
> ENOMEM
>     The region is private writable, and insufficient virtual memory is
> available to extend it. Also, this error will occur if MREMAP_MAYMOVE
> is not given and the extension would collide with another mapped region.
> 
> i thought that mmap'ed space is only virtually aligned. possibly it's
> better to write buffers oneself? the posix interfaces look strange to
> me. they seem halfhearted and weirdly incompatible.

I don't understand what you're saying in any of the preceding
paragraph.

> consider a file that is growing. how to best remap it?

If you don't need portability, use mremap() with MREMAP_MAYMOVE. If
you need portability, use munmap() and mmap().

The only advantage of mremap() (other than efficiency) is that it can
be used to remap private or anonymous mappings, while mmap/munmap will
only work if changes are written back to the file.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux