58
The Operating System Machine Level Chapter 6

The Operating System Machine Level - UoM

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Operating System Machine Level - UoM

The Operating System Machine Level

Chapter 6

Page 2: The Operating System Machine Level - UoM

OSM

Figure 6-1. Positioning of the operating system machine level.

Page 3: The Operating System Machine Level - UoM

Paging (1)

Figure 6-2. A mapping in which virtual addresses 4096 to 8191 are mapped onto main memory addresses 0 to 4095.

Page 4: The Operating System Machine Level - UoM

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

Page 5: The Operating System Machine Level - UoM

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

Page 6: The Operating System Machine Level - UoM

Demand Paging and Working-Set Model (1)

Figure 6-4. Formation of a main memory address from a virtual address.

Page 7: The Operating System Machine Level - UoM

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 8: The Operating System Machine Level - UoM

Page-Replacement Policy

Figure 6-6. Failure of the LRU algorithm.

Page 9: The Operating System Machine Level - UoM

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.

Page 10: The Operating System Machine Level - UoM

Segmentation (2)

Figure 6-7. In a one-dimensional address space with growing tables, one table may bump into another.

Page 11: The Operating System Machine Level - UoM

Segmentation (3)

Figure 6-8. A segmented memory allows each table to grow or shrink independently of the other tables.

Page 12: The Operating System Machine Level - UoM

Segmentation (4)

Figure 6-9. Comparison of paging and segmentation.

Page 13: The Operating System Machine Level - UoM

Implementation of Segmentation (1)

Figure 6-10. (a)–(d) Development of external fragmentation. (e) Removal of the external fragmentation by compaction.

Page 14: The Operating System Machine Level - UoM

Implementation of Segmentation (2)

Figure 6-11. Conversion of a two-part MULTICS address into a main memory address.

Page 15: The Operating System Machine Level - UoM

Virtual Memory on the Core i7 (1)

Figure 6-12. A Core i7 selector.

Page 16: The Operating System Machine Level - UoM

Virtual Memory on the Core i7 (2)

Figure 6-13. A Core i7 code segment descriptor. Data segments differ slightly.

Page 17: The Operating System Machine Level - UoM

Virtual Memory on the Core i7 (3)

Figure 6-14. Conversion of a (selector, offset) pair to a linear address.

Page 18: The Operating System Machine Level - UoM

Virtual Memory on the Core i7 (4)

Figure 6-15. Mapping of a linear address

onto a physical address.

Page 19: The Operating System Machine Level - UoM

Virtual Memory on the Core i7 (5)

Figure 6-16. Protection on the Core i7.

Page 20: The Operating System Machine Level - UoM

Virtual Memory - OMAP4430 ARM CPU (1)

Figure 6-17. Virtual-to-physical mappings on OMAP4430 ARM CPU.

Page 21: The Operating System Machine Level - UoM

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.

Page 22: The Operating System Machine Level - UoM

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.

Page 23: The Operating System Machine Level - UoM

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

Page 24: The Operating System Machine Level - UoM

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

Page 25: The Operating System Machine Level - UoM

Files (2)

Figure 6-20. Reading a file consisting of logical records. (a) Before reading record 19. (b) After reading record 19.

Page 26: The Operating System Machine Level - UoM

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.

Page 27: The Operating System Machine Level - UoM

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.

Page 28: The Operating System Machine Level - UoM

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

Page 29: The Operating System Machine Level - UoM

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.

Page 30: The Operating System Machine Level - UoM

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.

Page 31: The Operating System Machine Level - UoM

Race Conditions (1)

Figure 6-25. Use of a circular buffer.

Page 32: The Operating System Machine Level - UoM

Race Conditions (2)

Figure 6-26. Parallel processing with a fatal race condition. (1 of 3)

Page 33: The Operating System Machine Level - UoM

Race Conditions (2)

Figure 6-26. Parallel processing with a fatal race condition. (2 of 3)

Page 34: The Operating System Machine Level - UoM

Race Conditions (2)

Figure 6-26. Parallel processing with a fatal race condition. (3 of 3)

Page 35: The Operating System Machine Level - UoM

Race Conditions (3)

Figure 6-27. Failure of the producer-consumer communication mechanism.

Page 36: The Operating System Machine Level - UoM

Process Synchronization Using Semaphores (1)

Figure 6-28. The effect of a semaphore operation.

Page 37: The Operating System Machine Level - UoM

Process Synchronization Using Semaphores (2)

Figure 6-29. Parallel processing using semaphores. (1 of 3)

Page 38: The Operating System Machine Level - UoM

Process Synchronization Using Semaphores (2)

Figure 6-29. Parallel processing using semaphores. (2 of 3)

Page 39: The Operating System Machine Level - UoM

Process Synchronization Using Semaphores (2)

Figure 6-29. Parallel processing using semaphores. (3 of 3)

Page 40: The Operating System Machine Level - UoM

UNIX (1)

Figure 6-30. A rough breakdown of the UNIX system calls.

Page 41: The Operating System Machine Level - UoM

UNIX (2)

Figure 6-31. The structure of a typical UNIX system.

Page 42: The Operating System Machine Level - UoM

UNIX (3)

Figure 6-32. The structure of Windows 7.

Page 43: The Operating System Machine Level - UoM

UNIX Virtual Memory

Figure 6-33. The address space of a single UNIX process.

Page 44: The Operating System Machine Level - UoM

Windows 7 Virtual Memory

Figure 6-34. The principal Windows 7 API

calls for managing virtual memory

Page 45: The Operating System Machine Level - UoM

UNIX I/O (1)

Figure 6-35. The principal UNIX file system calls.

Page 46: The Operating System Machine Level - UoM

UNIX I/O (2)

Figure 6-37. Part of a typical UNIX directory system.

Page 47: The Operating System Machine Level - UoM

UNIX I/O (3)

Figure 6-37. Part of a typical UNIX directory system.

Page 48: The Operating System Machine Level - UoM

UNIX I/O (4)

Figure 6-38. The principal UNIX directory-management calls

Page 49: The Operating System Machine Level - UoM

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

Page 50: The Operating System Machine Level - UoM

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.

Page 51: The Operating System Machine Level - UoM

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

Page 52: The Operating System Machine Level - UoM

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.

Page 53: The Operating System Machine Level - UoM

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.

Page 54: The Operating System Machine Level - UoM

Windows 7 I/O (5)

Figure 6-42. The Windows 7 master file table.

Page 55: The Operating System Machine Level - UoM

UNIX Process Management (1)

Figure 6-43. A process tree in UNIX.

Page 56: The Operating System Machine Level - UoM

UNIX Process Management (2)

Figure 6-44. The principal POSIX thread calls.

Page 57: The Operating System Machine Level - UoM

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

Page 58: The Operating System Machine Level - UoM

End

Chapter 6