develooper Front page | perl.perl5.porters | Postings from April 2003

Thread::Semaphore manpage misleading?

Thread Next
From:
Philip Newton
Date:
April 2, 2003 00:17
Subject:
Thread::Semaphore manpage misleading?
Message ID:
3E8AB826.7071.4D0108@localhost
The Thread::Semaphore manpage says:

    use Thread::Semaphore;
    my $s = new Thread::Semaphore;
    $s->up;     # Also known as the semaphore V -operation.
    # The guarded section is here
    $s->down;   # Also known as the semaphore P -operation.

    # The default semaphore value is 1.
    my $s = new Thread::Semaphore($initial_value);
    $s->up($up_value);
    $s->down($up_value);

However, the description of the "up" and "down" methods says that 
"down" blocks if the semaphore's count would drop below zero... so 
isn't the order rather

    $s->down;  # blocks until the semaphore is available
    # The guarded section is here
    $s->up;    # release semaphore

and similarly for the non-1 semaphore: $s->down($up_value) [or
$s->down($down_value) ?] and then $s->up($up_value)?

I'd've submitted a patch but I don't know what the "P" and "V" 
operations on semaphores are, so I don't know whether the comments are 
attached to the correct method and only the order is wrong, or whether 
the comments are correct but the methods in the synopsis are the wrong 
way around.

Cheers,
Philip
-- 
Philip Newton <pnewton@gmx.de>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About