Project

win32-mmap

0.01
No release in over 3 years
Low commit activity in last 3 years
The win32-mmap library provides an interface for memory mapped IO on MS Windows.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

win32-mmap

Gem Version

This package provides a Ruby interface for memory mapped I/O on MS Windows.

Prerequisites

  • ffi
  • test-unit (Testing only)

Installation

gem install win32-mmap

Usage

  require 'win32/mmap'
  include Win32

  map1 = MMap.new(:file => "C:\\test.map", :size => 1024)
  map1.foo = 'hello'
  map1.bar = 77
  map1.close

  map2 = MMap.new(:file => "C:\\test.map")
  p map2.foo # 'hello'
  p map2.bar # 77
  map2.close

About Memory Mapped Files under Windows

Under Windows, code and data are both represented by pages of memory backed by files on disk, code by executable image and data by system pagefile (i.e. swapfile). These are called memory mapped files. Memory mapped files can be used to provide a mechanism for shared memory between processes. Different processes are able to share data backed by the same swapfile, whether it's the system pagefile or a user-defined swapfile.

Windows has a tight security system that prevents processes from directly sharing information among each other, but mapped memory files provide a mechanism that works with the Windows security system by using a name that all processes use to open the swapfile.

A shared section of the swapfile is translated into pages of memory that are addressable by more than one process, Windows uses a system resource called a prototype page table entry (PPTE) to enable more than one process to address the same physical page of memory, thus multiple process can share the same data without violating the Windows system security.

In short, memory mapped files provide shared memory under Windows.

(This explanation was largely borrowed from Roger Lee's Win32::MMF Perl module.)

License

Artistic 2.0

Copyright

(C) 2003-2013 Daniel J. Berger, All Rights Reserved

Warranty

This package is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.

Authors

  • Daniel J. Berger
  • Park Heesob