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

Thread::Semaphore manpage misleading?

Thread Next
Philip Newton
April 2, 2003 00:17
Thread::Semaphore manpage misleading?
Message ID:
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);

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.

Philip Newton <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About