- semop KEY,OPSTRING
-
Calls the System V IPC function semop(2) for semaphore operations such as signalling and waiting. OPSTRING must be a packed array of semop structures. Each semop structure can be generated with
pack("s!3", $semnum, $semop, $semflag). The length of OPSTRING implies the number of semaphore operations. Returns true if successful, false on error. As an example, the following code waits on semaphore $semnum of semaphore id $semid:シグナルを送信や、待ち合わせなどのセマフォ操作を行なうために、 System V IPC 関数 semop(2) を呼び出します。 OPSTRING は、semop 構造体の pack された配列でなければなりません。 semop 構造体は、それぞれ、
pack("s!3", $semnum, $semop, $semflag)のように 作ることができます。 セマフォ操作の数は、OPSTRING の長さからわかります。 成功時には真を、エラー時には偽を返します。 以下の例は、セマフォ ID $semid のセマフォ $semnum で 待ち合わせを行ないます。my $semop = pack("s!3", $semnum, -1, 0); die "Semaphore trouble: $!\n" unless semop($semid, $semop);To signal the semaphore, replace
-1with1. See also "SysV IPC" in perlipc and the documentation forIPC::SysVandIPC::Semaphore.セマフォにシグナルを送るには、
-1を1に変更してください。 "SysV IPC" in perlipc および、IPC::SysVとIPC::Semaphoreの文書も参照してください。Portability issues: "semop" in perlport.
移植性の問題: "semop" in perlport。