Page 345 - DCAP103_Principle of operating system
P. 345
Principles of Operating Systems
Notes Users can create new objects or open existing objects by making Win32 calls such as
CreateSemaphore or OpenSemaphore. These are the calls to library procedures that ultimately
result in the appropriate system calls being made. The result of any successful call that creates
or opens an object is a 64-bit handle table entry that is stored in the process’ private handle
table in kernel memory. The 32-bit index of the handle’s position in the table is returned to the
user to use on subsequent calls.
The 64-bit handle table entry in the kernel contains two 32-bit words. One word contains a 29-bit
pointer to the object’s header. The low-order 3 bits are used as flags (e.g., whether the handle is
inherited by child processes). These bits are masked off before the pointer is followed. The other
word contains a 32-bit rights mask. It is needed because permissions checking is done only at
the time the object is created or opened. If a process has only read permission to an object, all
the other rights bits in the mask will he 0s, giving the operating system the ability to reject any
operation on the object other than reading it.
The handle tables for two processes and their relationships to some objects are illustrated in
Figure 11.5. In this example, process A has access to threads 1 and 2 and access to mutexes
1 and 2. Process B has access to thread 3 and mutexes 2 and 3. The corresponding entries in the
handle tables hold the rights to each of these objects. For example, process A might have the rights
to lock and unlock its mutexes, but not the right to destroy them. Note that mutex 2 is shared by
both processes allowing threads in them to synchronize. The other mutexes are not shared, which
might mean that the threads within process A use mutex 1 for their internal synchronization
and the threads within process and B use mutex 3 for their internal synchronization.
Figure 11.5: The Relationship between Handle Tables, Objects and Type Objects
11.1.6 Object Name Space
As objects are created and deleted during execution, the object manager needs a way to keep
track of them. To do this job, it maintains a name space, in which all the objects in the system
are located. The name space can be used by a process to locate and open a handle for some
other process’ object, provided it has been granted permission to do so. The object name space
is one of three name spaces maintained by Windows 2000. The other ones are the file system
338 LOVELY PROFESSIONAL UNIVERSITY