40465

Overloading memory mapped file loader (C++)

Question:

Is it possible to overload memory mapped file loader? In case of page fault, Linux kernel would not load the requested data from disk, but instead of it, user-defined function would be called, which would fill the memory page.

I would like to use this for memory mapping of huge compressed raster file. Used compression algorithm allows fast block decompression. User-defined loading function would decompress the file page by page on the fly.

The compressed files are read-only. User-space solution is preferred.

Answer1:

<blockquote>

Is it possible to overload memory mapped file loader? In case of page fault, Linux kernel would not load the requested data from disk, but instead of it, user-defined function would be called, which would fill the memory page.

</blockquote>

It is possible and some libraries do just that. See <a href="https://www.gnu.org/software/libsigsegv/" rel="nofollow">libsigsegv</a>.

Install a signal handler for SIGSEGV with sigaction using the following signature for your handler:

void sigsegv_handler(int, siginfo_t* si, void*) { si->si_addr; // Memory location which caused the page fault. // mmap the missing page and return here // On error alternatives: // * restore the previous SIGSEGV handler and return (the default one dumps core), or // * abort() (dumps core), or // * _exit(EXIT_FAILURE). }

Recommend

  • Simplest way to save array into raster file in Python
  • Paper.js Loading Images and the Active Layer
  • Calculate distance between 2 lon lats but avoid going through a coastline in R
  • Unity iOS Build size is way big
  • AVAudioPlayer - Why is there a gap between loops (uncompressed audio)
  • Multiplying column elements of sparse Matrix
  • Easier way to do non-recursive list on gcs bucket outside appengine
  • PDF: How to Optimize Filesize & Convert to PNG (embedded fonts problem)
  • Extracting individual digits from a float
  • Visualizing a large matrix in matlab
  • Regex for nested values
  • Unzip archive in .Net CORE 1.0
  • How gzip file gets stored in HDFS
  • Save image as is in photo album using swift
  • File extension of zlib zipped html page?
  • NSIS decompiler
  • rewrite uppercase url to lowercase url htaccess
  • Access user's phone number on iOS 7
  • git add error : “fatal : malloc, out of memory”
  • Check all values in string[] for length?
  • Scala multiline string placeholder
  • Loading .coffee files via a view in Rails
  • Is there a way to do normal logging with EureakLog?
  • Time complexity of a program which involves multiple variables
  • one Local Olampyad Questions on Informatic in 2011
  • Combining SpatialPolygonsDataFrame of two neighbour countries
  • Asynchronous UI Testing in Xcode With Swift
  • How to delay loading a property with linq to sql external mapping?
  • Retrieving value from sql ExecuteScalar()
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Get object from AWS S3 as a stream
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Large data - storage and query
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Why winpcap requires both .lib and .dll to run?
  • Matrix multiplication with MKL
  • How to set the response of a form post action to a iframe source?
  • Trying to get generic when generic is not available
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android