1Apache::Session::Lock::USseemrapChoonrter(i3b)uted PerlADpoaccuhmee:n:tSaetsisoinon::Lock::Semaphore(3)
2
3
4
6 Apache::Session::Lock::Semaphore - Provides mutual exclusion through
7 semaphores
8
10 use Apache::Session::Lock::Semaphore;
11
12 my $locker = Apache::Session::Lock::Semaphore->new;
13 die "no semaphores" unless $locker;
14
15 $locker->acquire_read_lock($ref);
16 $locker->acquire_write_lock($ref);
17 $locker->release_read_lock($ref);
18 $locker->release_write_lock($ref);
19 $locker->release_all_locks($ref);
20
22 Apache::Session::Lock::semaphore fulfills the locking interface of
23 Apache::Session. Mutual exclusion is achieved through system
24 semaphores and the IPC::Semaphore module.
25
27 The module must know how many semaphores to use, and what semaphore key
28 to use. The number of semaphores has an impact on performance. More
29 semaphores means less lock contention. You should use the maximum
30 number of semaphores that your platform will allow. On stock NetBSD,
31 OpenBSD, and Solaris systems, this is probably 16. On Linux 2.2, this
32 is 32. This module tries to guess the number based on your operating
33 system, but it is safer to configure it yourself.
34
35 To set the number of semaphores, you need to pass an argument in the
36 usual Apache::Session style. The name of the argument is NSems, and the
37 value is an integer power of 2. For example:
38
39 tie %s, 'Apache::Session::Blah', $id, {NSems => 16};
40
41 You may also need to configure the semaphore key that this package
42 uses. By default, it uses key 31818. You can change this using the
43 argument SemaphoreKey:
44
45 tie %s, 'Apache::Session::Blah', $id, {NSems => 16, SemaphoreKey => 42};
46
48 There are a few problems that people frequently encounter when using
49 this package.
50
51 If you get an invalid argument message, that usually means that the
52 system is unhappy with the number of semaphores that you requested.
53 Try decreasing the number of semaphores. The semaphore blocks that
54 this package creates are persistent until the system is rebooted, so if
55 you request 8 semaphores one time and 16 semaphores the next, it won't
56 work. Use the system commands ipcs and ipcrm to inspect and remove
57 unwanted semphore blocks.
58
59 Cygwin
60 IPC on Cygwin requires running cygserver. Without it, program will exit
61 with "Bad System call" message. It cannot be intercepted with eval.
62
63 Read /usr/share/doc/Cygwin/cygserver.README for more information.
64
65 Darwin/MacOS X
66 Darwin and MacOS X may not have semaphores, see
67 <http://sysnet.ucsd.edu/~bellardo/darwin/sysvsem.html>
68
69 *BSD
70 Error "No space left on device" means that maximum number of semaphores
71 is reached. See
72 <http://www.postgresql.org/docs/7.3/static/kernel-resources.html> for
73 more information.
74
76 This module was written by Jeffrey William Baker <jwbaker@acm.org>.
77
79 Apache::Session
80
81
82
83perl v5.34.0 2022-01-20Apache::Session::Lock::Semaphore(3)