Have any of you guys used "Sempaphores" in Perl or MOD_PERL.
Thanks a lot for all the help. I used IPC::Shareable module and it works fine.
Thanks
Mahesh K. Ganesan
Tom Christiansen wrote:
> >> Can you kindly explain the above with an example.
>
> >I've never used IPC::Shareable. "perldoc IPC::Shareable" should tell you<SNIP>
>
> Here's my perennial example:
>
> use IPC::Shareable;
>
> $handle = tie $buffer, 'IPC::Shareable', undef, { destroy => 1 };
> $SIG{INT} = sub { die "$$ dying\n" };
>
> for (1 .. 10) {
> unless ($child = fork) { # i'm the child
> die "cannot fork: $!" unless defined $child;
> squabble();
> exit;
> }
> push @kids, $child; # in case we care about their pids
> }
>
> while (1) {
> print "Buffer is $buffer\n";
> sleep 1;
> }
> die "Not reached";
>
> sub squabble {
> my $i = 0;
> while (1) {
> next if $buffer =~ /^$$\b/o;
> $handle->shlock();
> $i++;
> $buffer = "$$ $i";
> $handle->shunlock();
> }
> }
>
> I've had problems with the build of IPC::Shareable on my current
> system. Its "make test" fails, and true enough, the Apache::SpeedLimit
> module conseuqently fails. Some random linux and/or glibc bug, perhaps.
>
> --tom
>
> Summary of my perl5 (revision 5.0 version 5 subversion 56) configuration:
> Platform:
> osname=linux, osvers=2.0.36, archname=i686-linux
> uname='linux jhereg.perl.com 2.0.36 #1 tue oct 13 22:17:11 edt 1998 i686 unknown
>'
> config_args=''
> hint=recommended, useposix=true, d_sigaction=define
> usethreads=undef useperlio=undef d_sfio=undef
> use64bits=undef usemultiplicity=undef
> Compiler:
> cc='cc', optimize='-O2', gccversion=2.7.2.3
> cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
> ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
> stdchar='char', d_stdstdio=define, usevfork=false
> intsize=4, longsize=4, ptrsize=4, doublesize=8
> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
> alignbytes=4, usemymalloc=n, prototype=define
> Linker and Libraries:
> ld='cc', ldflags =' -L/usr/local/lib'
> libpth=/usr/local/lib /lib /usr/lib
> libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
> libc=/lib/libc.so.6, so=so, useshrplib=false, libperl=libperl.a
> Dynamic Linking:
> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
> cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
>
> Characteristics of this binary (from libperl):
> Built under linux
> Compiled at Mar 13 1999 12:08:09
> %ENV:
> PERL_READLINE_NOWARN="1"
> @INC:
> /usr/local/perl/lib/i686-linux
> /usr/local/perl/lib
> /usr/local/site_perl/i686-linux
> /usr/local/site_perl
> .