Top Banner
The Operating System Machine Level Chapter 6
68

The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

The Operating SystemMachine Level

Chapter 6

Page 2: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Operating System Machine

Positioning of the operating system machine level.

Page 3: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

overview

a) OSM (Operating System Machine) is always interpreted

b) OSM is optional

c) ISA is sometimes interpreted

d) ISA can run without OSM. OSM can not run without ISA.

e) OSM adds system calls

f) 3 Main areas for this chapter– virtual memory– file I/O– parallel processing

Page 4: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Segmentation

a) Program assigned memory of base plus largest overlay

b) Segmentation is defined by program/compiler

c) Efficiency was controlled by programmer/compiler

d) Virtual memory dynamic– Programmer does not need to be involved– Machine can learn efficiency– Requires OSM

Page 5: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Paging

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

Page 6: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory

a) Steps for virtual memory – save main memory if required– find data on disk– load data from disk– change address map– continue- program does not know it was interrupted– How would this impact caching?

virtual address space vs. physical address space

Page 7: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Paging (1)

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

Page 8: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Paging (2)

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

Page 9: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Paging (3)

Formation of a main memory

address from a virtual address.

Page 10: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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 11: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

virtual memory

a) demanding paging as needed pages loaded into memory

b) page fault – trying to access memory not in memory

c) working set – pages necessary for the last k memlry references

d) Page Replacement– LRU – least recently used– FIFO

Thrashing

Page 12: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Page Replacement Policy

Failure of the LRU algorithm.

Page 13: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Segmentation (1)

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

Page 14: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Segmentation (2)

A segmented memory allows each table to grow

or shrink independently of the other tables.

Page 15: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Segmentation (3)

Comparison of paging and segmentation.

Page 16: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Segmentation (1)

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

Page 17: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Segmentation (2)

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

Page 18: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the Pentium 4 (1)

A Pentium 4 selector.

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

Page 19: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the Pentium 4 (2)

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

Page 20: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the Pentium 4 (3)

Mapping of a linear address onto a physical address.

Page 21: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the Pentium 4 (4)

Protection on the Pentium 4.

Page 22: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the UltraSPARC III (1)

Virtual to physical mappings on the UltraSPARC.

Page 23: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Memory on the UltraSPARC III (2)

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

Page 24: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Filesa) A disk is a collection of sectors with only a lineal relationship

to each other.

b) A file is s abstraction created by a programmer

c) A record is a abstraction created by a programmer

d) A database is a abstraction created by a programmer

e) Conventions are enforced by software

f) I/O is performed by setting bits and bytes/words in device registers.

g) Error correction shared between hardware and OSM

h) Device properties will control some functions of how the OSM used the device

Page 25: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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 26: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Files

a) Pointers (current record) or EOF are maintained by OSM

b) Allocation units and sectors on a disk may be different

c) Programs see records which are different than allocation units or sectors

d) Allocation units may or may not be consecutive (CD-ROM vs. disk)

e) a logical file may consist of more than one OSM file.

f) File organization is all OSM

g) Free space is tracked by OSM bit map vs. free list

h) Processing efficiency argues for large allocation blocks however space utilization argues for small blocks

Page 27: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Virtual I/O Instructions (2)

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

(b) A file not in consecutive sectors.

Page 28: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Implementation of Virtual I/O Instructions (3)

Two ways of keeping track of available sectors.

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

Page 29: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Directory Management Instructions

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

Page 30: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Directories

a) OSM functions for disk– Create file– Delete file– Rename file– Change protection status of file– Secure file– Encrypt file– Read file– Write file– Create directories– Delete directories– identify directories– allow embedded directories

Page 31: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Parallel processing

a) Programs and libraries are OSM abstractions

b) Reasons for parallel processing– Limitations of light speed -

http://archives.cnn.com/2000/TECH/space/07/20/speed.of.light.ap/– 1 nanosecond = 1 ft– Cooperating processors can speed calculations over one processor– requires multiple CPU’s– simulate with each process have a small time slot

Page 32: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Process creation

a) program runs as part of a process

b) process has state and address space

c) system call creates process

d) parents may or may not have control of process they start

e) Race condition– consumer– producer– circular buffer– sleep/resume– see program listing pg 464– fatal flaw

Page 33: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Virtual Instructions for Parallel Processing

(a) True parallel processing with multiple CPUs.

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

Page 34: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Race Conditions (1)

Use of a circular buffer.

Page 35: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Race Conditions (2)

Parallel processing with a fatal race condition.

Page 36: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Race Conditions (3)

Parallel processing with a fatal race condition.

Page 37: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Race Conditions (4)

Parallel processing with a fatal race condition.

Page 38: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Race Conditions (5)

Failure of the producer-consumer communication mechanism.

Page 39: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Process Synchronization Using Semaphores (1)

The effect of a semaphore operation.

Page 40: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Process Synchronization Using Semaphores (2)

Parallel processing using semaphores.

Page 41: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Process Synchronization Using Semaphores (3)

Parallel processing using semaphores.

Page 42: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Process Synchronization Using Semaphores (4)

Parallel processing using semaphores.

Page 43: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Unixa) UNIX – written in C

b) Berkley added paged virtual memory, long file names and TCP/IP

c) ATT came up with System III and then System V incompatible with Berkley UNIX

d) POSIX – standard for basic UNIX system

e) MINIX lead to Linux

f) All may have calls that go beyond standard

g) Caused by MSDOS being backward compatiable and running code on any version

h) Berkley was responsible for networking (sockets)

Page 44: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

MINIX

a) http://www.minix3.org/

Page 45: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX (1)

A rough breakdown of the UNIX system calls.

Page 46: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX (2)

The structure of a typical UNIX system.

Page 47: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

Streams

a) Originally each device driver was responsible for all functions

b) Streams allows modules to be shared by device drivers for flow control

Page 48: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

Windows XP

a) MS-DOS 1.0 was 8 k single user command line OS

b) MS-DOS 2.0 and 3.0 etc. add new features but kept command line format

c) Windows thru 3.x were front ends to DOS

d) Windows 95 (1995) still used DOS file system except for long names and increased number of blocks on disk

e) Windows 98 had improvements leading to DOJ law suit

f) Windows ME – slightly improved(?)

g) Windows NT complete rewrite

h) Windows 2000 – upgrade of NT

i) Windows XP – upgrade of 2000

Page 49: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

Windows XP

a) XP has server and client versions

b) XP– 32 bit operating system with each user having their own 32-bit demand page virtual address

c) .

Page 50: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Windows XP

The structure of Windows XP.

Page 51: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Virtual Memory

The address space of a single UNIX process.

Page 52: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of 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 memory

a) Berkley demand page virtual memory one address space

b) System V and Solaris include map file or portion of into memory

Page 53: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Windows XP Virtual Memory

The principal Windows XP API calls for managing virtual memory.

Page 54: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

XP Virtual Memory

a) Every user process has it’s own virtual address space

b) 2 GB for application and 2 GB for Kernel

c) demand page with 4 KB page size

d) 3 states free, reserved or committed– free – not in use –auto pagefault– committed code or data mapped to it– reserved – not available for mapping

Allows for memory mapped files

Page 55: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Virtual I/O (1)

The principal UNIX file system calls.

Page 56: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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 57: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Virtual I/O (3)

Part of a typical UNIX

directory system.

Page 58: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

UNIX IO

a) root directory is where directories start

b) subdirectories are under root

c) Special directories include bin, dev, lib and usr

d) Standard files o= Standard Input, 1 = Standard output and 2 = Standard Error

e) path starting a root is absolute path

f) link path to an existing file

g) inode contains file information including type, protection, lick

count, owner, length, owner group, disk addresses

Page 59: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Virtual I/O (4)

The principal UNIX directory management calls.

Page 60: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

XP Virtual IO

a) Supports FAT and NTFS

b) Uses ACL and SID for security

c) MFT – master file table

Page 61: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Windows XP Virtual I/O (1)

The principal Win32 API functions for file I/O.

The second column gives the nearest UNIX equivalent.

Page 62: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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 63: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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 64: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

Windows XP Virtual I/O (4)

The Windows XP master file table.

Page 65: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Process Management (1)

A process tree in UNIX.

Page 66: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

UNIX Process

a) parent/child via fork

b) one of the fork can then exec a program

c) Parent can continue or wait

d) processes communicate via pipes

e) Some UNIX systems use message queues

f) Threads are also allowed. Threads share address space

g) Threads synchronize by using mutexes

Page 67: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

UNIX Process Management (2)

The principal POSIX thread calls.

Page 68: The Operating System Machine Level Chapter 6. Operating System Machine Positioning of the operating system machine level.

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

XP Process Management

a) XP supports multiple processes

b) Each process has at least one thread

c) Scheduling is by thread

d) fibers are threads created in user space

e) Communicate thru pipes, named pipes, mailslots, sockets, remote procedure calls and shared files

f) threads synchronize by semaphores, mutexes, critical sections, and events