[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
OpenVMS Programming Concepts Manual
7.2.3 Using the Dedicated CPU Lock Manager With AffinityThe LCKMGR_SERVER process uses the affinity mechanism to set the process to the lowest CPU ID other than the primary. This can be changed by the dynamic system parameter LOCKMGR_CPU by placing a CPU ID there. The Dedicated CPU Lock Manager then attempts to use this CPU. If this CPU is not available, it reverts back to the lowest CPU other than the primary. The following shows how to change the CPU used by the LCKMGR_SERVER process:
To verify the CPU dedicated to the lock manager, use the following show system command:
Note that under the State field, it shows the process is currently running on CPU 2.
Compaq highly recommends that a process not be given hard affinity to
the CPU used by the Dedicated CPU Lock Manager. With hard affinity when
such a process becomes computable, it cannot obtain any CPU time,
because the LCKMGR_SERVER process is running at the highest possible
real-time priority of 63. However, the LCKMGR_SERVER detects once per
second if there are any computable processes that are set by the
affinity mechanism to the dedicated lock manager CPU. If so, the
LCKMGR_SERVER switches to a different CPU for one second to allow the
waiting process to run.
OpenVMS Version 7.3 and higher supports Fast Path for SCSI and Fibre Channel Controllers along with the existing support of CIPCA adapters. The Dedicated CPU Lock Manager supports both the LCKMGR_SERVER process and Fast Path devices on the same CPU. However, this may not produce optimal performance. Compaq thus recommends that the CPU used by the LCKMGR_SERVER process not have any Fast Path devices. This can be accomplished in the following ways:
7.2.5 Using the Dedicated CPU Lock Manager on the AlphaServer GS Series SystemsThe AlphaServer GS Series Systems (GS80, GS160, and the GS320) have NUMA memory characteristics. When using the Dedicated CPU Lock Manager on one of these systems, the best performance is obtained by utilizing a CPU and memory from within a single Quad Building Block (QBB). The Dedicated CPU Lock Manager does not yet have the ability to decide from where QBB memory should be allocated. However, there is a method to preallocate lock manager memory from the low QBB. This can be done with the LOCKIDTBL system parameter. This system parameter indicates the initial size of the Lock ID Table, along with the initial amount of memory to preallocate for lock manager data structures. To preallocate the proper amount of memory, this system parameter should be set to the highest number of locks plus resources on the system. The command MONITOR LOCK can provide this information. If MONITOR indicates the system has 100,000 locks and 50,000 resources, then setting LOCKIDTBL to the sum of these two values will ensure that enough memory is initially allocated. Adding in some additional overhead may also be beneficial. Setting LOCKIDTBL to 200,000 thus might be appropriate.
If necessary, use the LOCKMGR_CPU system parameter to help ensure that
the LCKMGR_SERVER runs on a CPU in the low QBB.
A resource can be any entity on the operating system (for example, files, data structures, databases, or executable routines). When two or more processes access the same resource, you often need to control their access to the resource. You do not want to have one process reading the resource while another process writes new data, because a writer can quickly invalidate anything being read by a reader. The lock management system services allow processes to associate a name with a resource and request access to that resource. Lock modes enable processes to indicate how they want to share access with other processes. To use the lock management system services, a process must request access to a resource (request a lock) using the Enqueue Lock Request (SYS$ENQ) system service. The following three arguments to the SYS$ENQ system service are required for new locks:
The lock management services compare the lock mode of the newly requested lock to the mode of other locks with the same resource name. New locks are granted in the following instances:
Processes can also use the SYS$ENQ system service to change the lock
mode of a lock. This is called a lock conversion.
Many resources can be divided into smaller parts. As long as a part of a resource can be identified by a resource name, the part can be locked. The term resource granularity describes the part of the resource being locked. Figure 7-1 depicts a model of a database. The database is divided into areas, such as a file, which in turn are subdivided into records. The records are further divided into items. Figure 7-1 Model Database The processes that request locks on the database shown in Figure 7-1 may lock the whole database, an area in the database, a record, or a single item. Locking the entire database is considered locking at a coarse granularity; locking a single item is considered locking at a fine granularity. In this example, overall access to the database can be represented by a root resource name. Access either to areas in the database or records within areas can be represented by sublocks. Root resources consist of the following:
Subresources consist of the following:
7.3.2 Resource DomainsBecause resource names are arbitrary names chosen by applications, one application may interfere (either intentionally or unintentionally) with another application. Unintentional interference can be easily avoided by careful design, such as by using a registered facility name as a prefix for all root resource names used by an application. Intentional interference can be prevented by using resource domains. A resource domain is a namespace for root resource names and is identified by a number. Resource domain 0 is used as a system resource domain. Usually, other resource domains are used by the UIC group corresponding to the domain number.
By using the SYS$SET_RESOURCE_DOMAIN system service, a process can gain
access to any resource domain subject to normal operating system access
control. By default, each resource domain allows read, write, and lock
access by members of the corresponding UIC group. See the OpenVMS Guide to System Security
for more information about access control.
The lock management system services refer to each resource by a name composed of the following four parts:
For two resources to be considered the same, these four parts must be identical for each resource. The name specified by the process represents the resource being locked. Other processes that need to access the resource must refer to it using the same name. The correlation between the name and the resource is a convention agreed upon by the cooperating processes. The access mode is determined by the caller's access mode unless a less privileged mode is specified in the call to the SYS$ENQ system service. Access modes, their numeric values, and their symbolic names are discussed in the OpenVMS Calling Standard. The default resource domain is selected by the UIC group number for the process. You can access the system domain by setting the LCK$M_SYSTEM when you request a new root lock. Other domains can be accessed using the optional RSDM_ID parameter to SYS$ENQ. You need the SYSLCK user privilege to request systemwide locks from user or supervisor mode. No additional privilege is required to request systemwide locks from executive or kernel mode.
When a lock request is queued, it can specify the identification of a
parent lock, at which point it becomes a sublock (see Section 7.5.8).
However, the parent lock must be granted, or the lock request is not
accepted. This enables a process to lock a resource at different
degrees of granularity.
The mode of a lock determines whether the resource can be shared with other lock requests. Table 7-2 describes the six lock modes.
7.3.5 Levels of Locking and CompatibilityLocks that allow the process to share a resource are called low-level locks; locks that allow the process almost exclusive access to a resource are called high-level locks. Null and concurrent read mode locks are considered low-level locks; protected write and exclusive mode locks are considered high-level. The lock modes, from lowest- to highest-level access, are:
Note that the concurrent write and protected read modes are considered to be of the same level. Locks that can be shared with other locks are said to have compatible lock modes. High-level lock modes are less compatible with other lock modes than are low-level lock modes. Table 7-3 shows the compatibility of the lock modes.
Key to Lock Modes: NL = Null 7.3.6 Lock Management QueuesA lock on a resource can be in one of the following three states:
A queue is associated with each of the three states (see Figure 7-2). Figure 7-2 Three Lock Queues
When you request a new lock, the lock management services first
determine whether the resource is currently known (that is, if any
other processes have locks on that resource). If the resource is new
(that is, if no other locks exist on the resource), the lock management
services create an entry for the new resource and the requested lock.
If the resource is already known, the lock management services
determine whether any other locks are waiting in either the conversion
or the waiting queue. If other locks are waiting in either queue, the
new lock request is queued at the end of the waiting queue. If both the
conversion and waiting queues are empty, the lock management services
determine whether the new lock is compatible with the other granted
locks. If the lock request is compatible, the lock is granted; if it is
not compatible, it is placed in the waiting queue. You can use a flag
bit to direct the lock management services not to queue a lock request
if one cannot be granted immediately.
Lock conversions allow processes to change the level of locks. For example, a process can maintain a low-level lock on a resource until it limits access to the resource. The process can then request a lock conversion. You specify lock conversions by using a flag bit (see Section 7.5.6) and a lock status block. The lock status block must contain the lock identification of the lock to be converted. If the new lock mode is compatible with the currently granted locks, the conversion request is granted immediately. If the new lock mode is incompatible with the existing locks in the granted queue, the request is placed in the conversion queue. The lock retains its old lock mode and does not receive its new lock mode until the request is granted.
When a lock is dequeued or is converted to a lower-level lock mode, the
lock management services inspect the first conversion request on the
conversion queue. The conversion request is granted if it is compatible
with the locks currently granted. Any compatible conversion requests
immediately following are also granted. If the conversion queue is
empty, the waiting queue is checked. The first lock request on the
waiting queue is granted if it is compatible with the locks currently
granted. Any compatible lock requests immediately following are also
granted.
A deadlock occurs when any group of locks are waiting for each other in a circular fashion. In Figure 7-3, three processes have queued requests for resources that cannot be accessed until the current locks held are dequeued (or converted to a lower lock mode). Figure 7-3 Deadlock If the lock management services determine that a deadlock exists, the services choose a process to break the deadlock. The chosen process is termed the victim. If the victim has requested a new lock, the lock is not granted; if the victim has requested a lock conversion, the lock is returned to its old lock mode. In either case, the status code SS$_DEADLOCK is placed in the lock status block. Note that granted locks are never revoked; only waiting lock requests can receive the status code SS$_DEADLOCK.
7.3.9 Lock Quotas and LimitsThe OpenVMS lock manager was modified for OpenVMS Version 7.1. Some internal restrictions on the number of locks and resources available on the system have been eased and a method to allow enqueue limit quota (ENQLM) of greater than 32767 has been added. No changes were made to the interface and no programming changes to applications are required to take advantage of these changes. While most processes do not require very many locks simultaneously (typically fewer than 100), large scale database or server applications can easily exceed this threshold. Specifically, the OpenVMS lock manager includes the following enhancements:
If you set an ENQLM value of 32767 in the SYSUAF, the operating system
treats it as no limit and allows an application to own up to 16,776,959
locks, the architectural maximum of the OpenVMS lock manager. The
following sections describe these features in more detail.
Before the release of OpenVMS Version 7.1, the previous limit for the total number of locks a single process could own was 32767. This limit was enforced unless the process ran in a privileged mode and used the NOQUOTA flag. Further attempts to acquire locks would result in an error (SS$_EXQUOTA). Because applications generally use the lock manager for internal synchronization, this error was usually fatal to the application. While most processes do not require very many locks simultaneously (typically fewer than 100), large scale database or server applications can easily exceed this threshold. Now with the release of OpenVMS Version V7.1, an ENQLM value of 32767 in a user's SYSUAF record is treated as if there is no quota limit for that user. This means that the user is allowed to own up to 16,776,959 locks, the architectural maximum of the OpenVMS lock manager. The current maximum SYSUAF ENQLM value of 32767 is not treated as a limit. Instead, when a process is created that reads ENQLM from the SYSUAF, if the value in the SYSUAF is 32767, it is automatically extended to the new maximum. The Create Process (SYS$CREPRC) system service has been modified to allow large quotas to be passed on to the target process. Therefore, a process can be created with an arbitrary ENQLM of any value up to the new maximum if it is initialized from a process with the SYSUAF quota of 32767. The behavior of the process quota and creation limit (PQL) parameters for the default and minimum ENQLM quotas for detached processes has not changed. The default SYSGEN values for the parameters have been raised accordingly.
|