[comp.lang.perl] perl and shared memory ?

koerberm@nixsin.UUCP (Mathias Koerber) (09/24/90)

Is there a possibility for perl to access sysV shm segments?
Maybe treated as a file, or via some calls or so?
If not, would Larry consider implementing it? I'd like to use perl
to monitor the contents of my shm segments, instead of having
to write a C-Program for everything.

Greetings, Mathias
-- 
Mathias Koerber           |Tel:   +65 / 7473828 ext 1852|Fax: +65 / 7474331
Nixdorf Computer Singapore|EUnet: koerber.sin@nixpbe    |nerv:  koerber.sin
2 Kallang Sector          |uunet: uunet!linus!nixbur!koerber.sin
Singapore 1334            |[Standard-disclaimer:All views personal...     ]

merlyn@iwarp.intel.com (Randal Schwartz) (09/26/90)

In article <1371@nixsin.UUCP>, koerberm@nixsin (Mathias Koerber) writes:
| Is there a possibility for perl to access sysV shm segments?
| Maybe treated as a file, or via some calls or so?
| If not, would Larry consider implementing it? I'd like to use perl
| to monitor the contents of my shm segments, instead of having
| to write a C-Program for everything.

Hmm.  I was just polishing up those sections for The Book.  Consider
your request fulfilled by Perl 4.0, available Real Soon Now.  The
coding was provided by someone who's name escapes me at the moment,
and Larry dropped it into the main code.

The new operators that deal with shared memory are shmctl, shmget,
shmread, and shmwrite.  And you also get msgctl, msgget, msgrcv, and
msgsnd.

Not being a big sys V fan, I don't know how useful all that stuff is,
but some of you are going to like it. :-)

print "Just another ", "System V "&&"", "Perl hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

ronald@robobar.co.uk (Ronald S H Khoo) (09/26/90)

In article <1990Sep25.172747.17739@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes:

> Consider
> your request fulfilled by Perl 4.0, available Real Soon Now.

Eh -- you already know what's in 4.0 ? :-)  Could you say what Larry did
with the dbm problems people were having with 3.0PL28 ?  If missed the
conclusion of the saga, apologies, but it has caused me to stay at PL18
(not hearing the conclusion, that is).

Thanks.  When the Modern Book Co. has \fIThe Book\fP in stock, I promise to
buy my teddy bear a copy :-)
-- 
   ronald@robobar.co.uk | +44 81 991 1142 (O) | +44 71 229 7741 (H) | YELL!
   "Nothing sucks like a VAX"   --   confirmed after recent radiator burst!
Hit 'R' <RETURN> to continue .....

chip@tct.uucp (Chip Salzenberg) (09/26/90)

According to merlyn@iwarp.intel.com (Randal Schwartz):
>The coding was provided by someone who's name escapes me at the moment,
>and Larry dropped it into the main code.

I'm the culprit.  Um, I mean, I'm the hero.

>The new operators that deal with shared memory are shmctl, shmget,
>shmread, and shmwrite.  And you also get msgctl, msgget, msgrcv, and
>msgsnd.

Don't forget semctl, semget and semop.

>Not being a big sys V fan, I don't know how useful all that stuff is,
>but some of you are going to like it. :-)

I wrote it because our local projects make significant use of SysV
IPC, and Perl is a great prototyping tool.  It's also quite handy for
doing random things like "createq":

    eval 'exec /bin/perl -S $0 ${1+"$@"}'
        if 0;    # Well, this is System V, after all :-(

    require 'sys/ipc.ph';
    $id = msgget(&IPC_PRIVATE, &IPC_CREAT|0666&~umask);
    die "Can't create message queue: $!\n" unless defined($id);
    print "Created message queue $id\n";

-- 
Chip Salzenberg at Teltronics/TCT     <chip@tct.uucp>, <uunet!pdn!tct!chip>

merlyn@iwarp.intel.com (Randal Schwartz) (09/27/90)

In article <1990Sep26.135823.1792@robobar.co.uk>, ronald@robobar (Ronald S H Khoo) writes:
| Eh -- you already know what's in 4.0 ? :-)  Could you say what Larry did
| with the dbm problems people were having with 3.0PL28 ?  If missed the
| conclusion of the saga, apologies, but it has caused me to stay at PL18
| (not hearing the conclusion, that is).

He fixed 'em.  They got broke in response to fix he installed in PL28.
Someone said that defined(foo) (for some types of foo, I can't recall
which) caused foo to come into existance, and therefore defined(foo)
was always true.  He fixed that, and broke dbm in the process (because
defined(%foo) and defined($foo{$someref}) *are* true after the
dbmopen, even though $foo{$someref} = $value never happened).  [Larry
will probably chime in if I got this explanation wrong.]

Code is coming real soon now.  All kinds of goodies in it.  (Still
waiting personally for Atari ST support, though.  Who was working on
that?)

print "Just another Perl hacker," # ok, I know, 'bout time I got fancy, sorry
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/