the operating system machine level - uom
TRANSCRIPT
The Operating System Machine Level
Chapter 6
OSM
Figure 6-1. Positioning of the operating system machine level.
Paging (1)
Figure 6-2. A mapping in which virtual addresses 4096 to 8191 are mapped onto main memory addresses 0 to 4095.
Paging (2)
On a machine with virtual memory, the following sequence of steps would occur:
• Contents of main memory saved on disk
• Words 8192 to 12287 located on disk
• Words 8192 to 12287 loaded into main memory
• Address map changed to map addresses 8192 to 12287
onto memory locations 0 to 4095
• Execution continues as though nothing had happened
Implementation of Paging
Figure 6-3.
(a) The first 64 KB of virtual address space divided into 16 pages
(b) A 32-KB main memory divided up into 8 page frames of 4 KB
Demand Paging and Working-Set Model (1)
Figure 6-4. Formation of a main memory address from a virtual address.
Demand Paging and Working-Set Model (2)
Figure 6-5. A possible mapping of the first 16 virtual pages onto a main memory with eight page frames.
Page-Replacement Policy
Figure 6-6. Failure of the LRU algorithm.
Segmentation (1)
Tables used/created by compiler:
• Symbol table, containing names, attributes of variables• Source text saved for printed listing• Table containing integer and floating-point constants
• Parse tree, containing syntactic analysis of program
• Stack for procedure calls within compiler.
Segmentation (2)
Figure 6-7. In a one-dimensional address space with growing tables, one table may bump into another.
Segmentation (3)
Figure 6-8. A segmented memory allows each table to grow or shrink independently of the other tables.
Segmentation (4)
Figure 6-9. Comparison of paging and segmentation.
Implementation of Segmentation (1)
Figure 6-10. (a)–(d) Development of external fragmentation. (e) Removal of the external fragmentation by compaction.
Implementation of Segmentation (2)
Figure 6-11. Conversion of a two-part MULTICS address into a main memory address.
Virtual Memory on the Core i7 (1)
Figure 6-12. A Core i7 selector.
Virtual Memory on the Core i7 (2)
Figure 6-13. A Core i7 code segment descriptor. Data segments differ slightly.
Virtual Memory on the Core i7 (3)
Figure 6-14. Conversion of a (selector, offset) pair to a linear address.
Virtual Memory on the Core i7 (4)
Figure 6-15. Mapping of a linear address
onto a physical address.
Virtual Memory on the Core i7 (5)
Figure 6-16. Protection on the Core i7.
Virtual Memory - OMAP4430 ARM CPU (1)
Figure 6-17. Virtual-to-physical mappings on OMAP4430 ARM CPU.
Virtual Memory - OMAP4430 ARM CPU (2)
Figure 6-18. Data structures used in translating virtual addresses on the OMAP4430 ARM CPU.
(a) Address translation table. (b) TLB.
Hardware Virtualization
Figure 6-19. Hardware virtualization allows multiple operating systems to run simultaneously on the same host hardware. The hypervisor implements sharing of host memory and I/O devices.
OSM-Level I/O Instructions
Types of errors noted by device register bits:
• Disk arm failed to seek properly
• Nonexistent memory specified as buffer
• Disk I/O started before previous one finished• Read timing error• Nonexistent disk addressed• Nonexistent cylinder addressed
• Nonexistent sector addressed
• Checksum error on read
• Write-check error after write operation
Files (1)
The read system call must have the following parameters:
• An indication of which open file is to be read• A pointer to a buffer in memory in which to put the data• The number of bytes to be read
Files (2)
Figure 6-20. Reading a file consisting of logical records. (a) Before reading record 19. (b) After reading record 19.
Implementation of OSM-Level I/O Instructions (1)
Figure 6-21. Disk allocation strategies. (a) A file in consecutive sectors. (b) A file not in consecutive sectors.
Implementation of OSM-Level I/O Instructions (2)
Figure 6-22. Two ways of keeping track of available sectors. (a) A free list. (b) A bit map.
Directory Management Instructions
System calls are provided for at least the following:
• Create a file and enter it in a directory• Delete a file from a directory
• Rename a file
• Change the protection status of a file
OSM-Level Instructions for Parallel Processing (1)
Figure 6-23. A user file directory and the contents of a typical entry in a file directory.
OSM-Level Instructions for Parallel Processing (2)
Figure 6-24. (a) True parallel processing with multiple CPUs. (b) Parallel processing simulated by switching
one CPU among three processes.
Race Conditions (1)
Figure 6-25. Use of a circular buffer.
Race Conditions (2)
Figure 6-26. Parallel processing with a fatal race condition. (1 of 3)
Race Conditions (2)
Figure 6-26. Parallel processing with a fatal race condition. (2 of 3)
Race Conditions (2)
Figure 6-26. Parallel processing with a fatal race condition. (3 of 3)
Race Conditions (3)
Figure 6-27. Failure of the producer-consumer communication mechanism.
Process Synchronization Using Semaphores (1)
Figure 6-28. The effect of a semaphore operation.
Process Synchronization Using Semaphores (2)
Figure 6-29. Parallel processing using semaphores. (1 of 3)
Process Synchronization Using Semaphores (2)
Figure 6-29. Parallel processing using semaphores. (2 of 3)
Process Synchronization Using Semaphores (2)
Figure 6-29. Parallel processing using semaphores. (3 of 3)
UNIX (1)
Figure 6-30. A rough breakdown of the UNIX system calls.
UNIX (2)
Figure 6-31. The structure of a typical UNIX system.
UNIX (3)
Figure 6-32. The structure of Windows 7.
UNIX Virtual Memory
Figure 6-33. The address space of a single UNIX process.
Windows 7 Virtual Memory
Figure 6-34. The principal Windows 7 API
calls for managing virtual memory
UNIX I/O (1)
Figure 6-35. The principal UNIX file system calls.
UNIX I/O (2)
Figure 6-37. Part of a typical UNIX directory system.
UNIX I/O (3)
Figure 6-37. Part of a typical UNIX directory system.
UNIX I/O (4)
Figure 6-38. The principal UNIX directory-management calls
UNIX I/O (5)
Typical i-node contents:
• File type, the 9 RWX protection bits, and a few others• Number of links to the file (number of directory entries)
• The owner’s identity
• The owner’s group• The file length in bytes• Thirteen disk addresses• The time the file was last read
• The time the file was last written
• The time the i-node was last changed
Windows 7 I/O (1)
Figure 6-39. The principal Win32 API functions for file I/O. The second column gives the nearest UNIX equivalent.
Windows 7 I/O (2)
Seven parameters of CreateFile:
• Pointer to name of file to create or open
• Flags whether file can be read, written, or both
• Flags whether multiple processes can open file at once• Pointer to security descriptor, who can access file• Flags telling what to do if file exists/does not exist• Flags dealing with attributes
• Handle of file whose attributes are to be cloned for new file
Windows 7 I/O (3)
Figure 6-40. A program fragment for copying a file using the Windows 7 API functions. This fragment is in C because
Java hides the low-level system calls and we are trying to expose them.
Windows 7 I/O (4)
Figure 6-41. The principal Win32 API functions for directory management. The second column gives the nearest UNIX
equivalent, when one exists.
Windows 7 I/O (5)
Figure 6-42. The Windows 7 master file table.
UNIX Process Management (1)
Figure 6-43. A process tree in UNIX.
UNIX Process Management (2)
Figure 6-44. The principal POSIX thread calls.
Windows 7 Process Management (1)
Ten parameters for CreateProcess:
• Pointer to the name of executable file
• Command line itself (unparsed)
• Pointer to security descriptor for process
• Pointer to security descriptor for initial thread
• Bit telling whether new process inherits creator’s handles
• Miscellaneous flags (e.g., error mode, priority, debugging)
• Pointer to environment strings
• Pointer to name of new process’ current working directory• Pointer to structure describing initial window on screen
• Pointer to structure that returns 18 values to called
End
Chapter 6