[Win32utils-devel] Need some help with latest win32-mmap

Berger, Daniel Daniel.Berger at qwest.com
Tue Oct 10 09:43:18 EDT 2006


> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> Johan Nilsson
> Sent: Tuesday, October 10, 2006 12:51 AM
> To: Development and ideas for win32utils projects
> Subject: Re: [Win32utils-devel] Need some help with latest win32-mmap
> 
> 
> Hi, 
> 
> > -----Original Message-----
> > From: win32utils-devel-bounces at rubyforge.org
> > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> > Daniel Berger
> > Sent: den 6 oktober 2006 22:03
> > To: win32utils-devel at rubyforge.org
> > Subject: [Win32utils-devel] Need some help with latest win32-mmap
> > 
> > Hi all,
> > 
> > I've got the latest win32-mmap code checked into CVS.
> > Unfortunately, it seems that I'm not able to open an existing 
> > mapping and retrieve set data.  Below is a simple example 
> > that seems like it ought to work but doesn't.  Any ideas?
> > 
> > # map1.rb
> > require 'win32/mmap'
> > include Win32
> > 
> > mmap = MMap.new(:name => 'alpha', :size => 20) p mmap.address
> > 
> > mmap.test = "hello"
> > 
> > mmap.close
> > 
> > # map2.rb
> > # mmap = MMap.open('alpha') # Boom!
> > 
> > mmap = MMap.new(:name => 'alpha', :size => 20) # Ok so far... p 
> > mmap.test # Boom!
> > 
> > mmap.close
> > 
> > I tried using MMap.open and MMap.new.  Neither seems to work
> > as expected.  What am I doing wrong?
> 
> I haven't checked the implementation and this is probably too 
> obvious to be the culprit, but:
> 
> If map1.rb runs to completion and closes the mmap before 
> map2.rb can attach by opening it, the memory map won't exist 
> unless you are using something else than the paging file as 
> backing storage. The Win32 mmaps are reference counted 
> through their handles as pretty much everything else.
> 
> Also, as you can see it that using MMap.new from map2.rb 
> works as the first step, but as this only creates a new 
> identically named mmap there is no 'test' data there. Hence 
> the 'boom' I'd guess.
> 
> HTH,
> 
> Johan Nilsson

Yes, you and Heesob are both right.  I was thinking the value stayed
resident.  Once I stuck a sleep call in there and ran it from a second
terminal it worked fine.  Duh.

In other news, it looks like I need to set a default size for MMap.open.
What sounds reasonabl? 1k?

Thanks,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.


More information about the win32utils-devel mailing list