Book HomeJava and XSLTSearch this book

8.136. IPC::Semaphore

System V Semaphore IPC object class. Uses constants defined in IPC::SysV.

new

$sem = new IPC::Semaphore(key, nsems, flags)

Creates a new semaphore set associated with key and containing nsems semaphores. Uses flags to set the permissions. Creates the new set if the following are true:

getall

$sem->getall

Returns the values of the semaphore set as an array.

getncnt

$sem->getncnt(sem)

Returns the number of processes waiting for the semaphore sem to become greater than its current value.

getpid

$sem->getpid(sem)

Returns the process ID of the last process that operated on semaphore sem.

getval

$sem->getval(sem)

Returns the current value of semaphore sem.

getzcnt

$sem->getzcnt(sem)

Returns the number of processes waiting for the semaphore sem to become 0.

id

$sem->id

Returns the system identifier for the semaphore set.

op

$sem->op(oplist)

Passes a list of operations to the semop function. oplist is the list of operations, consisting of a concatenation of smaller lists. Each of the smaller lists has three values: the semaphore number, the operation, and a flag. See the semop function in Chapter 5, "Function Reference" for more information.

remove

$sem->remove

Removes and destroys the semaphore set.

set

$sem->set(stat
$sem->set(name=>value[, name=>value...])

Accepts either a stat object as returned by the stat method or a list of name/value pairs and sets the following values of the stat structure associated with the semaphore set:

uid
gid
mode (the permission bits)
setall

$sem->setall(values)

Sets the values of all the semaphores in the set to those given by the values list. The number of values on the list must match the number of semaphores in the set.

setval

$sem->setval(n, value)

Sets the nth value in the semaphore set to value.

stat

$ds = $sem->stat

Returns an object of type IPC::Semaphore::stat (which is a subclass of Class::Struct) that provides the following fields:

uid    gid    cuid    cgid
mode   ctime  otime   nsems


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.