2.1 PROCESSES 2.2 THREADS 2.3 INTERPROCESS COMMUNICATION 2.4 CLASSICAL IPC PROBLEMS 2.5 SCHEDULING 2.6 RESEARCH ON PROCESSES AND THREADS 2.7 SUMMARY
Trang 111CASE STUDY 2: WINDOWS 2000
Trang 5Win32 application program
Win32 Application Programming Interface
Trang 62222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
HKEY3LOCAL3MACHINE Properties of the hardware and software
HARDWARE Hardware description and mapping of hardware to driversSAM Security and account information for users
SECURITY System-wide security policies
SOFTWARE Generic information about installed application programsSYSTEM Information for booting the system
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
HKEY3USERS Information about the users; one subkey per user
USER-AST-ID User AST’s profile
AppEvents Which sound to make when (incoming email/fax, error, etc.)Console Command prompt settings (colors, fonts, history, etc.)
Control Panel Desktop appearance, screensaver, mouse sensitivity, etc.Environment Environment variables
Keyboard Layout Which keyboard: 102-key US, AZERTY, Dvorak, etc
Printers Information about installed printers
Software User preferences for Microsoft and third party software
Trang 8POSIX program POSIX subsystem
Win32 program Win32 subsystem
OS/2 program OS/2 subsystem
Kernel File sys
I/O mgr
Object
mgr
Process mgr
Memory mgr
Security mgr
Cache mgr
PnP mgr
Power mgr
Config mgr
LPC mgr
Win32 GDI Video driver
Trang 9registers
Device addresses Interrupts DMA Timers
Spin locks BIOS
Disk RAM
Hardware abstraction layer
Fig 11-8 Some of the hardware functions the HAL manages.
Trang 10Reference countsPointer to the type object
Type nameAccess typesAccess rightsQuota chargesSynchronizable?PageableOpen methodClose methodDelete methodQuery name methodParse methodSecurity method
Fig 11-9 The structure of an object.
Trang 12Thread 1
Mutex 1
Mutex 2
Mutex 3
Thread 2
Thread 3
Thread 4
Thread type object
Mutex type object
Handle
table for
process A
Handle table for process B
1010
1011
1110 1111 0101
Fig 11-11 The relationship between handle tables, objects, and type objects.
Trang 14Gdi32.dll User32.dll Kernel32.dll
Call Call Call
Operating system
User process
Enviroment
subsystem
process (csrss.exe)
Win32 subsys
Trang 17Kernel mode thread stackAccess token
Trang 20priori-Next thread to run Priority
Idle thread
Fig 11-19 Windows 2000 supports 32 priorities for threads.
Trang 2148
12Does a down on the
semaphore and blocks
Trang 22MS–DOS program 1
2 3
4 Trampoline
Operating system Ntvdm
Fig 11-21 How old MS-DOS programs are run under Windows 2000.
Trang 232222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
idle Not really a process, but home to the idle thread
system Creates smss.exe & paging files; reads registry; opens DLLssmss.exe First real proc; much initialization; creates csrss & winlogoncsrss.exe Win32 subsystem process
winlogon.exe Login daemon
lsass.exe Authentication manager
services.exe Looks in registry and starts services
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
Printer server Allows remote jobs to use the printer
File server Serves requests for local files
Telnet daemon Allows remote logins
Incoming email handler Accepts and stores inbound email
Incoming fax handler Accepts and prints inbound faxes
DNS resolver Internet domain name system server
Event logger Logs various system events
Plug-and-play manager Monitors hardware to see what is out there
Fig 11-22 The processes starting up during the boot phase The
ones above the line are always started The ones below it are
examples of services that could be started.
Trang 24A's page tables
Stacks, data, etc
Process B'sprivate codeand data
Process C
Nonpaged poolPaged poolC's page tablesStacks, data, etcHAL + OSSystem data
Process C'sprivate codeand data
Bottom and top
64 KB are invalid
Fig 11-23 Virtual address space layout for three user processes The white areas are private per process The shaded areas are shared among all processes.
Trang 25Shared
library
Data
StackStack
Data
Region
Fig 11-24 Mapped regions with their shadow pages on disk The
lib.dll file is mapped into two address spaces at the same time.
Trang 27vir-20 3
G
1L
1D
1A
1
CWt
1U
11W
1V
1Page frame
Notused
Fig 11-26 A page table entry for a mapped page on the Pentium.
Trang 28Mod-Standby page list
Free page list
Zeroed page list
Bad RAM page list Top
Bottom
Modified page writer(4)
Dealloc(5) Zero
page thread (7)
Page evicted from a working set (1) Process exist (3)
Fig 11-27 The various page lists and the transitions between them.
Trang 29XX
State Cnt WS Other PT Next
CleanDirtyCleanActiveCleanDirtyActiveDirtyFreeFreeZeroedActiveActiveZeroed
1312
10
7654
Trang 31User process
User program
Win32
Rest of windows
Hardware abstraction layer
Controller Controller Controller
Driver stack
Fig 11-30 Windows 2000 allows drivers to be stacked.
Trang 33/ * Open files for input and output * /
do {
if (s && count > 0) WriteFile(outhandle, buffer, count, &ocnt, NULL);
} while (s > 0 && count > 0);
CloseHandle(inhandle);
CloseHandle(outhandle);
Fig 11-32 A program fragment for copying a file using the
Win-dows 2000 API functions.
Trang 34Fig 11-33 The principal Win32 API functions for directory
management The second column gives the nearest UNIX
equivalent, when one exists.
Trang 35$Extend Extentions: quotas,etc
$Upcase Case conversion table
$Secure Security descriptors for all files
$BadClus List of bad blocks
$Bitmap Bitmap of blocks used
$AttrDef Attribute definitions
$Volume Volume file
$LogFile Log file to recovery
$MftMirr Mirror copy of MFT
Fig 11-34 The NTFS master file table.
Trang 37Data header
Info about data blocks Run #1 Run #2 Run #3
Standard info File name 0 9 20 4 64 2 80 3 Unused
Disk blocks Blocks numbers 20-23 64-65 80-82
Trang 38Second extension record
First extension record
Base record101
104
107
Fig 11-37 A file that requires three MFT records to store all its runs.
Trang 39Fig 11-38 The MFT record for a small directory.
Trang 40D:
Harddisk Volume 1
\Devices
2 Follow symbolic link
to get disk portion
\?? Directory
1 Look up C: in \??
Root directory maria web.htm MFT for HD volume 1
3 Look up path name
4 Create new file object
5 Return handle
to calling process Handle
Fig 11-39 Steps in looking up the file C:\maria\web.htm.
Trang 417 0
Original uncompressed file
Compressed Uncompressed
Fig 11-40 (a) An example of a 48-block file being compressed to
32 blocks (b) The MFT record for the file after compression.
Trang 42K retrieved
by applyinguser's privatekey to storedkey on diskDisk
ModifiedDES
C = Encrypted file
K encrypted withuser's public key
DecryptionEncryption
DESC
Fig 11-41 Operating of the encrypting file system.
Trang 43UserSID
GroupSID
RestrictedSIDs
Trang 44Security descriptor Header Owner's SID Group SID DACL SACL
Header Audit Marilyn 111111
Security descriptor Header
Allow Everyone
Deny Elvis 111111 Allow Cathy 110000 Allow Ida
ACE
ACE
File
100000 111111
Fig 11-43 An example security descriptor for a file.
Trang 46Kernel32.dllntdll.dll
Cache mangerI/O managerNTFS FAT–32SCSI IDE
Disk Disk
User process reads from a file
Call is handled in shared libraryActual system call is made
Call is caught by cache manager
If block is absent, page faultCall to file system to get blockCall to disk driver to read block
Fig 11-45 The path through the cache to the hardware.