The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition,...

48
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 The Operating System Machine Level Chapter 6

Transcript of The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition,...

Page 1: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

The Operating SystemMachine Level

Chapter 6

Page 2: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Operating System Machine

Positioning of the operating system machine level.

Page 3: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Paging

A mapping in which virtual addresses 4096 to 8191 are mappedonto main memory addresses 0 to 4095.

Page 4: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Paging (1)

The first 64 KB of virtual address space divided into 16 pages, with each page being 4K.

Page 5: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Paging (2)

A 32 KB main memory divided up into eight page frames of 4 KB each.

Page 6: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Paging (3)

Formation of a main memory

address from a virtual address.

Page 7: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Demand Paging and the Working Set Model

A possible mapping of the first 16 virtual pages

onto a main memory with eight page frames.

Page 8: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Page Replacement Policy

Failure of the LRU algorithm.

Page 9: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Segmentation (1)

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

Page 10: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Segmentation (2)

A segmented memory allows each table to grow

or shrink independently of the other tables.

Page 11: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Segmentation (3)

Comparison of paging and segmentation.

Page 12: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Segmentation (1)

(a)-(d) Development of external fragmentation. (e) Removal of the external fragmentation by compaction.

Page 13: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Segmentation (2)

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

Page 14: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the Pentium 4 (1)

A Pentium 4 selector.

A Pentium 4 code segment descriptor. Data segments differ slightly.

Page 15: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the Pentium 4 (2)

Conversion of a (selector, offset) pair to a linear address.

Page 16: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the Pentium 4 (3)

Mapping of a linear address onto a physical address.

Page 17: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the Pentium 4 (4)

Protection on the Pentium 4.

Page 18: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the UltraSPARC III (1)

Virtual to physical mappings on the UltraSPARC.

Page 19: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Memory on the UltraSPARC III (2)

Data structures used in translating virtual addresses on theUltraSPARC. (a) TLB. (b) TSB. (c) Translation table.

Page 20: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Virtual I/O Instructions (1)

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

Page 21: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Virtual I/O Instructions (2)

Disk allocation strategies. (a) A file in consecutive sectors.

(b) A file not in consecutive sectors.

Page 22: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Implementation of Virtual I/O Instructions (3)

Two ways of keeping track of available sectors.

(a) A free list. (b) A bit map.

Page 23: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Directory Management Instructions

A user file directory and the contents of a typical entry in a file directory.

Page 24: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Virtual Instructions for Parallel Processing

(a) True parallel processing with multiple CPUs.

(b) Parallel processing simulated by switching one CPU among three processes.

Page 25: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Race Conditions (1)

Use of a circular buffer.

Page 26: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Race Conditions (2)

Parallel processing with a fatal race condition.

Page 27: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Race Conditions (3)

Parallel processing with a fatal race condition.

Page 28: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Race Conditions (4)

Parallel processing with a fatal race condition.

Page 29: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Race Conditions (5)

Failure of the producer-consumer communication mechanism.

Page 30: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Process Synchronization Using Semaphores (1)

The effect of a semaphore operation.

Page 31: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Process Synchronization Using Semaphores (2)

Parallel processing using semaphores.

Page 32: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Process Synchronization Using Semaphores (3)

Parallel processing using semaphores.

Page 33: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Process Synchronization Using Semaphores (4)

Parallel processing using semaphores.

Page 34: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX (1)

A rough breakdown of the UNIX system calls.

Page 35: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX (2)

The structure of a typical UNIX system.

Page 36: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP

The structure of Windows XP.

Page 37: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Virtual Memory

The address space of a single UNIX process.

Page 38: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP Virtual Memory

The principal Windows XP API calls for managing virtual memory.

Page 39: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Virtual I/O (1)

The principal UNIX file system calls.

Page 40: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Virtual I/O (2)

A program fragment for copying a file using the UNIX systemcalls. This fragment is in C because Java hides the

low-level system calls and we are trying to expose them.

Page 41: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Virtual I/O (3)

Part of a typical UNIX

directory system.

Page 42: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Virtual I/O (4)

The principal UNIX directory management calls.

Page 43: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP Virtual I/O (1)

The principal Win32 API functions for file I/O.

The second column gives the nearest UNIX equivalent.

Page 44: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP Virtual I/O (2)

A program fragment for copying a file using the Windows XP APIfunctions. This fragment is in C because Java hides the low-level

system calls and we are trying to expose them.

Page 45: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP Virtual I/O (3)

The principal Win32 API functions for directory management.The second column gives the nearest UNIX equivalent, when one

exists.

Page 46: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

Windows XP Virtual I/O (4)

The Windows XP master file table.

Page 47: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Process Management (1)

A process tree in UNIX.

Page 48: The Operating System Machine Level · Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0 UNIX Virtual

Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved. 0-13-148521-0

UNIX Process Management (2)

The principal POSIX thread calls.