350 likes | 480 Views
Lecture 4 System Mechanisms (2). xlanchen@03/18/2005. Contents. Trap dispatching The executive object manager Synchronization System worker threads Local procedure calls (LPCs). Object manager. EXPERIMENT Exploring the Object Manager. Uniform approach towards:
E N D
Lecture 4 System Mechanisms (2) xlanchen@03/18/2005
Contents • Trap dispatching • The executive object manager • Synchronization • System worker threads • Local procedure calls (LPCs) Understanding the Inside of Windows2000
Object manager • EXPERIMENT • Exploring the Object Manager Understanding the Inside of Windows2000
Uniform approach towards: • Object protection (C2 security) • Charging • Object naming • Object retention and garbage collection • Object access (via handles) • Standard object attributes • Standard object methods Understanding the Inside of Windows2000
Process Memory Section Event Timer Object directory Queues Thread File Semaphore Symbolic link Port (registry) key Executive Objects Understanding the Inside of Windows2000
Executive objects that contain kernel objects Understanding the Inside of Windows2000
Object Structure Understanding the Inside of Windows2000
Object properties • OM deletes object when: • #open handles drops to zero • #knl refs drops to zero • Obj names • Support identification, finding, sharing • Hierarchic (per machine) name space • Symbolic links, e.g. “C:” Understanding the Inside of Windows2000
Type Objects • Process objects and the process type object Understanding the Inside of Windows2000
EXPERIMENT • Viewing the Type Objects Understanding the Inside of Windows2000
Type Object Attributes • Type name • Pool type • Default quota • Access types • Generic access rights mapping • Synchronization • Methods Understanding the Inside of Windows2000
Object Methods • Open--When an object handle is opened • Close--When an object handle is closed • Delete--Before the object manager deletes an object • Query--name When a thread requests the name of an object, such as a file, that exists in a secondary object domain • Parse--When the object manager is searching for an object name that exists in a secondary object domain • Security--When a process reads or changes the protection of an object, such as a file, that exists in a secondary object domain Understanding the Inside of Windows2000
Object Handles & Process Handle Table Understanding the Inside of Windows2000
EXPERIMENT • Viewing Open Handles with Nthandle Understanding the Inside of Windows2000
Structure of a handle table entry Understanding the Inside of Windows2000
EXPERIMENT • Viewing the Handle Table with the Kernel Debugger Understanding the Inside of Windows2000
Handles and reference counts Understanding the Inside of Windows2000
Synchronization • Mutual exclusion • one, and only one, thread can access a particular resource at a time • Critical sections Understanding the Inside of Windows2000
Kernel Synchronization • Kernel critical sections • For single-processor • Simple operating systems: disable all interrupts • 2K: raising the processor's IRQL • For a multiprocessor • spinlock Understanding the Inside of Windows2000
Using a spinlock Understanding the Inside of Windows2000
Executive Synchronization • Dispatcher objects • WaitForSingleObject • WaitForMultipleObjects • A thread in a Win32 application can synchronize with a Win32 process, thread, event, semaphore, mutex, waitable timer, I/O completion port, or file object • Executive resources • available only to kernel-mode code • aren't accessible from the Win32 API Understanding the Inside of Windows2000
Waiting on a dispatcher object • A thread can synchronize with a dispatcher object by waiting on the object's handle Understanding the Inside of Windows2000
Selected kernel dispatcher objects Understanding the Inside of Windows2000
Wait data structures Understanding the Inside of Windows2000
EXPERIMENT • Looking at Wait Queues Understanding the Inside of Windows2000
System worker threads • Three types • Delayed worker threads • Critical worker threads • hypercritical worker threads Understanding the Inside of Windows2000
EXPERIMENT • Listing System Worker Threads Understanding the Inside of Windows2000
Windows 2000 Global Flags • NtGlobalFlag • Initialize • Gflags.exe • allows you to view and change the system global flags Understanding the Inside of Windows2000
Local procedure calls (LPCs) • An interprocess communication facility • For high-speed message passing • An internal mechanism available only to Windows 2000 operating system components Understanding the Inside of Windows2000
EXPERIMENT • Viewing LPC Port Objects Understanding the Inside of Windows2000
“Internal” IPC between address spaces, e.g. • Transport for local RPC • Calls to Win32 subsystem • Variants: • n <= 256 bytes done inband • n > 256 bytes via shmem section • n > shmem section – addr-to-addr copy • Typically client-server • Client connects to servers well-known LPC port • Server opens new port and tells client its address Understanding the Inside of Windows2000
LPC端口的使用 Understanding the Inside of Windows2000