1Session::Lock::SemaphorUes(e3r)Contributed Perl DocumentSaetsisoinon::Lock::Semaphore(3)
2
3
4
6 Apache::Session::Lock::Semaphore - Provides mutual exclusion through
7 sempahores
8
10 use Apache::Session::Lock::Semaphore;
11
12 my $locker = new Apache::Session::Lock::Semaphore;
13
14 $locker->acquire_read_lock($ref);
15 $locker->acquire_write_lock($ref);
16 $locker->release_read_lock($ref);
17 $locker->release_write_lock($ref);
18 $locker->release_all_locks($ref);
19
21 Apache::Session::Lock::Sempahore fulfills the locking interface of
22 Apache::Session. Mutual exclusion is achieved through system sema‐
23 phores and the IPC::Semaphore module.
24
26 The module must know how many semaphores to use, and what semaphore key
27 to use. The number of semaphores has an impact on performance. More
28 semaphores meansless lock contention. You should use the maximum num‐
29 ber of sempahores that your platform will allow. On stock NetBSD,
30 OpenBSD, and Solaris systems, this is probably 16. On Linux 2.2, this
31 is 32. This module tries to guess the number based on your operating
32 system, but it is safer to configure it yourself.
33
34 To set the number of semaphores, you need to pass an argument in the
35 usual Apache::Session style. The name of the argument is NSems, and
36 the value is an integer power of 2. For example:
37
38 tie %s, 'Apache::Session::Blah', $id, {NSems => 16};
39
40 You may also need to configure the semaphore key that this package
41 uses. By default, it uses key 31818. You can change this using the
42 argument SemaphoreKey:
43
44 tie %s, 'Apache::Session::Blah', $id, {NSems => 16, SemaphoreKey => 42};
45
47 There are a few problems that people frequently encounter when using
48 this package.
49
50 If you get an invalid argument message, that usually means that the
51 system is unhappy with the number of semaphores that you requested.
52 Try decreasing the number of semaphores. The semaphore blocks that
53 this package creates are persistent until the system is rebooted, so if
54 you request 8 sempahores one time and 16 sempahores the next, it won't
55 work. Use the system commands ipcs and ipcrm to inspect and remove
56 unwanted semphore blocks.
57
58 Cygwin
59
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
66 This module was written by Jeffrey William Baker <jwbaker@acm.org>.
67
69 Apache::Session
70
71
72
73perl v5.8.8 2004-02-24 Session::Lock::Semaphore(3)