Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shared memory

6 views
Skip to first unread message

David Robins

unread,
Apr 17, 2003, 9:45:31 AM4/17/03
to perl6-i...@perl.org
The recent mini-discussion on memory allocation reminded me of an issue I
wanted to raise for the Parrot memory API: will it support sharing of Parrot
objects (between processes)? There's some mention of arenas but it only
seems to mean for different types of object.

(OK, I found
<http://archive.develooper.com/perl6-i...@perl.org/msg05760.html> which
indicates that yes, sharing will be supported, so I rephrase the question to
"_how_ will sharing be supported?", and "is this a good time to start
looking at it?", and "let's discuss it"; also
<http://archive.develooper.com/perl6-i...@perl.org/msg01706.html>
relates; BTW, those threads are a year and a half or more old.)

As you probably know, there are a couple issues that need to be addressed
when sharing structures like PMCs: locking and concurrency, and keeping
allocation within the shared arena. Locking can probably be handled by a
shared object PMC wrapper, allocation might be more difficult (but perhaps
it would be enough if, before each op, the shared PMC sets
interp->arena_base to a shm allocator and restores it afterwards?). If, for
example, an array is shared, then anything added to it must be allocated
within the shared memory area. Furthermore, since the local address of a
shared arena may vary, canonical in-arena addresses need to be relative to
the start of the arena.

I have a shared memory module for perl5 that does all this (allows sharing
of arrays, hashes, and scalars), which I'll submit to CPAN after some
cleaning up. (It works by using tie and an adaption of Ralf Engelschalls's
mm library to manage its own arena, using sysV shm and sems for locking;
it doesn't flatten the structures like other IPC::* modules do.)

Dave
Isa. 40:31

0 new messages