Top Banner
CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3
64
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: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

CIS250

OPERATING SYSTEMS

Ch 1 – notes/review

Ch 2

Ch 3

Page 2: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Chapter 1 -Time-Sharing/Multi-Tasking System

• Jobs switch so quickly, user may interact• On-Line between user, system, keyboard and

CRT; TSO• Short response time, more complex• Jobs are swapped in and out of memory• Virtual Memory - job executes without being

completely in memory; programs can be larger than physical memory

Page 3: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Chapter 1 – life after mainframes: Personal Computers

Introduced• Single Processor - IBM DOS

• Multi-processors– many CPUs sharing the same bus and clock;

tightly coupled; increased throughput, overhead.

– Saved money, increased reliability– Graceful degradation - one CPU failure doesn’t

stop the systemic

Page 4: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Chapter 1 - Review

What is an Operating system?

What is a kernel?

Describe the evolution of computers.

What types of systems are there?

Page 5: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Chapter Two

Computer System Structures

Page 6: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Objectives

• Describe a computer system operation

• List and define the types of system structures

• Discuss hardware protection

• Review the general system architecture

Page 7: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

A computer system consists of...

• A CPU and Device controllers– execute concurrently (not simultaneously)– compete for memory cycles– each device controller controls specific device (audio,

drives, video)

• CPU and Device controllers are connected by a system bus

• Memory Controller synchronizes access to Memory

Page 8: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

When we turn on the computer...

• Bootstrap program locates the operating system kernel and loads it into memory

• CPU registers, device controllers, and memory are initialized

• Operating system waits for an interrupt– hardware interrupt gives a signal to the CPU– software interrupt is triggered by a system call

Page 9: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

For example• Power up• bootstrap is loaded into memory• O/S runs the init• A request for I/O causes an interrupt in the form of a

signal • CPU stops and transfers execution to a fixed

location which contains the starting address of the appropriate service routine

• Control passed back to CPU upon completion

Page 10: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Interrupts

• To handle quickly, may use a table of pointers– Stored in low memory; routine called via the

table - Contains address of service routine– also known as array or interrupt vector

• Interrupted process must have its address saved on a system stack (so that it knows where to resume processing)– address is loaded onto the program counter

Page 11: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Array/Interrupt Vector Example

• O/S - running process with address FFF0D

• I/O requests to read; produces interrupt

• O/S saves the address of process on the system stack; disables other interrupts; gets the address of the I/O service from the vector; service routine is run

• Get FFF0D from stack; return to program counter; enable other interrupts

Page 12: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating SystemsArchitecture Definitions

• Array/Interrupt Vector - a table of pointers stored in low memory– purpose: handle interrupts quickly– bootstrap initializes at startup

• I/O Structure - controller can have multiple devices attached to it– device controller moves data between

peripheral devices and local buffer storage

Page 13: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating SystemsArchitecture Definitions

• I/O Interrupts - CPU loads registers within the device controller

• The device controller examines the register content to determine what to do: – read,– transfer data to buffer, – when complete, interrupts CPU

Page 14: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating SystemsArchitecture Definitions

• Interrupt Methods– Asynchronous - return control to the user

before I/O is complete• more efficient: while doing I/O, CPU can process or

schedule I/O

• uses device status table to keep track of I/O requests

– Synchronous - I/O started at completion• only one request at a time

• less overhead

Page 15: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Synchronous: Waiting for I/O completion

• Only one I/O request is pending– allows O/S to know exactly which I/O device

• Can be accomplished:– wait instruction - CPU is idle until the next

interrupt– Wait loop - waits in a loop until next interrupt

• generates instruction fetches

• can tie up memory

Page 16: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Asynchronous: Device Status Table

• Used when control is passed back to the user program before I/O is complete

• Still requires wait logic - done through a system call to the operating system

• Table contains status of all I/O devices

Page 17: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Process– Type a character at the keyboard– Causes an interrupt to the CPU– Wait until the process is finished– Saves address, calls service routine– Service routine saves the contents of the CPU registers– Stores characters in the buffer– Pointer, counter adjusted– Data is processed– Restore registers, interrupted instruction gains control

Page 18: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

High-Speed I/O Devices

• When you are entering a series of characters at the keyboard, each character is stored contiguously in a buffer

• Asynchronous I/O is assigned a low priority and interrupted often

• High speed I/O devices can process as quickly as memory - too many interrupts make inefficient usage of the CPU

Page 19: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

DMA- Direct Memory Access

– O/S finds an empty buffer– DMA controller takes over the I/O operation– CPU performs other tasks– DMA controller interrupts the CPU on

completion

• Little process execution time

• For high speed I/O devices

Page 20: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Memory

• Main memory - temporary, volatile– RAM/DRAM– I/O controller has registers which hold

commands/data (IBM PCs and MAC)– have memory mapped I/O - addresses

physically mapped to device registers DEVICE= [video controllers]

• Secondary Storage - magnetic disk, tape– storage area for programs, data

Page 21: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Cache

• Even faster than main memory

• More expensive

• Copy can be in main memory and then cache (after it is used)

• Cache management - keep copies in sync

Page 22: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Cache Management

• Should be designed so that 80-90% of all access is in cache

• Single Process - not an issue

• Multitasking Environment - CPU is switched between multiple processes - must ensure that each process accessing something has the correct copy

Page 23: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Cache Management

• Distributive/Multitasking - CPU is switched between processes – if multiprocessor accesses a counter, make sure

increment counter is in all caches– handled by the hardware, below the O/S

• Known as cache coherency

Page 24: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Hardware Protection

• Multi-users, tasking and processors has made this a challenge

• Sharing resources has made this harder to do - an error by one program may affect other processes

Page 25: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Hardware Protection

• Time-sharing, Auto Job sequencing - infinite loop could affect several programs/files

• DOS, Multi-programming - program can change program/data of another program

• Hardware error - trap - uses interrupt vector

Page 26: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Protection Types• Dual mode operation

– user mode– monitor mode - when there is a trap, O/S

switches to this mode; has privileged instructions– Requires a mode bit: NT and OS/2 have– DOS does not

• I/O Protection - all I/O instructions are privileged

Page 27: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Protection

• Memory Protection– user can’t touch interrupt vector or service

routines - based on base/range addressing

• CPU Protection - prevent a program from “hogging” the system– via a timer/time slice

Page 28: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Trap

• Since I/O is privileged, user program must ask monitor to do I/O– done via a system call

– usually done as a trap to a specific location in the interrupt vector

– hardware treats a trap as a software interrupt, checks if a valid request, sets mode bit to monitor mode

– resets to user mode when complete

Page 29: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

HCL

• Hardware Compatibility List– List of all hardware know to work properly

with WIN2K• can obtain on install CD, documentation with

software OR download from web:– www.microsoft.com/hwtest/hcl

• newer machines - not an issue; older adapters (8bit) are an issue

• MS will not support hardware that is not on the list

Page 30: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Windows 2000 Boot

• BIOS checks hardware and loads O/S– checks either floppy (boot sector) or hard drive

(master boot record) for instructions on location of O/S

• In WIN2K, BIOS calls boot loader (NTLDR) and it loads OS

Page 31: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Boot Sequence

• NTLDR reads the BOOT.INI file (contains WIN menu and instructions on the kernel location)

• User selects a menu item; NTDETECT.COM program loads – detects hw, tells NTLDR

• NTLDR loads NTOSKRNL (kernel) and passes it info from NTDETECT; kernel loads WIN2K files

Page 32: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Network Structure

• LAN– Ethernet, FDDI, token-ring– Multiple Oss, links, gateways

• WAN– Arpanet was the first (1960s)– Communication processors, routers/switches

and router Oss– PPP replaced by PPTP

Page 33: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Chapter 3 - OS Structures

• Examine an operating system via– System Components– Services provided– User Interfaces and System Calls

Page 34: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Components

• Process Management

• Main Memory Management

• Secondary Storage Management

• I/O System Management

• File Management

• Protection

• Networking

• Command-Interpreter

Page 35: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Process Management

• A process is a program in execution

• System calls can split a process into subprocesses

• Each program requires initialization and resources– CPU, memory– may be given at start of execution or as needed

Page 36: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Process

• Active entity– program counter keeps track of next instruction

• A unit of work in the system– system processes– user processes

• Processes execute concurrently by multiplexing the CPU

Page 37: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

O/S tasks for Process Management

• Create/delete processes

• Suspend/resume processing

• Synchronize processes

• Process communication

• Handle deadlocks

Page 38: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Main Memory Management• Main memory is an array of bytes, each has an

addressable location• Place where data and instructions are stored; I/O

and CPU access quickly• Efficient to keep many programs in memory• O/S must:

– keep track of what is in memory– decide what to load– allocate and deallocate

Page 39: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Secondary Storage Management

• Back up to main memory (not enough main memory to store everything)– compilers, editors, sorters et.

• O/S is responsible for:– managing free space– allocating storage– disk scheduling

Page 40: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

I/O System Management

• Prevent direct access to hardware devices from user programs– specifics are built into the I/O system

• Must manage:– buffer-caching– device driver interfaces– hardware device drivers

Page 41: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

File Management• Files are part of storage devices such as magnetic tape,

disk and optical disk• These devices are made up of a physical media and a

software driven device driver– files are mapped to the media via the devices

• O/S must handle:– creation, deletion of files and directories– support for manipulating files, directories– mapping files to storage– backup and recovery of files, directories

Page 42: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Protection

• The O/S must ensure that resources are accessed by the appropriate processes– a process must have proper authorization

• Examples– memory protection: process within an address

space– CPU protection via a time– I/O cannot be performed directly by a user prog

Page 43: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Networking

• Distributed systems (do not share memory, clock), communicate with each other via a communications network– routing, connection, contention and security

must be managed

Page 44: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Command-Interpreter System

• Command interpreter is a system program which provides the interface between the user and the O/S– DOS, UNIX shell commands

• Types of commands: process creation, execution...

Page 45: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating System Services

• makes programming task easier– Program Execution– I/O Operations– File-system manipulation– Communications– Error detection

• ensures system efficiency– accounting, resource allocation, protection

Page 46: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating Systems Services• Must be easy to execute programs and programs should end

• O/S must provide a way to do I/O

• Must have some type of file-system manipulation - for reading, writing, deletes

• Provide a means for process communication - either on the same computer or over a NW

• Error detection and correction

• Allocate resources

• Accounting

• Security and Protection

Page 47: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Calls• Interface between a process and the O/S

• Usually in Assembler or C

• Example: copy data from one file to another

– need two file names

• how is this handles? Prompts, control cards

– program opens I/P and creates O/P files

– error message handles

– loop: read data and write to O/P

– error handles (hw failures)

– exit loop, close files

• Each step is a series of system calls

Page 48: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Operating SystemsTypes of System Calls

• Process and Job Control

• File Manipulation

• Device Management

• Information Maintenance

• Communication

* refer to page 68, Figure 3.2

Page 49: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Programs

• In the hierarchy, between operating system and application programs

• Designed to provide an easier environment for program development

• User interface to system call programs

• More complex programs

• Most important system program is the command interpreter - gets and executes next command

Page 50: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Command Interpreter

• May contain the actual execution code

• or it may identify a file and execute (UNIX)– less maintenance: change file containing code,

don’t have to change all of your system commands

– overhead: must pass parameters to system pgm

Page 51: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Programs: Categories• File manipulation - create, delete, copy

• Status information - memory, date

• File modification - text editors• Programming-language support - comilers,

assemblers, interpreters

• Program loading and execution - linkers, loaders

• Communications - file transfers, virtual connections, email

• Application Programs - databases

Page 52: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

• System call is the program interface

• System program is the user interface

Page 53: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Structure

• The way components are interconnected and melded into a kernel

• Types of structure– Simple– Layered

Page 54: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Structure

• Simple - interfaces and level of functionality are not well separated; limited by hardware– MS-DOS - no dual mode operation– original UNIX - two parts: kernel and system

programs

Page 55: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Structure• Layered - broken down into smaller parts;

allows for greater control over each part– less efficient (overhead between layers) – modularity - break the O/S into layers on top of one

another; each module communicates with the one below it; simplifies debugging

– information hiding-system programmers can change lower levels without affecting external interface

– layer does not need to know about other layers

Page 56: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Layered Approach• Disadvantages

– less efficient - traversing multiple layers to accomplish a task

– must plan layers carefully - ensure that ALL of the needed resources are layered below

• backing store must be below memory, because memory accesses it

• should backing store be above or below CPU? Normally above, waits for I/O, but CPU could use it as auxiliary storage

Page 57: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Ideal System Structure

• Best approach: fewer layers, prohibit direct access to lower level, allow multi-tasking, dual mode

Page 58: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Virtual Machine

• Uses layered approach• Application program regards everything below it

as part of the hardware• O/S creates the illusion of multiple processes,

each executing its own processor, each with its own (virtual) memory– other operating systems can be loaded on top of the

virtual machine (SUN and DEC have a virtual INTEL machine on top of their proc)

Page 59: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Virtual Machine Structure

Application Programs - can call system pgms

System Programs - can use system calls, hw instructions; treats sys calls and hw as same level

Kernel - translates hw instructions to sys calls

HW

Page 60: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Virtual Machine

• Can create virtual card readers and line printers, disks

• Difficult to implement– virtual machine sw requires a lot of disk space– virtual machine can only run in monitor mode -

so you must create a virtual user and virtual monitor mode

– need exact duplication of configuration

Page 61: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

Virtual Machine - dual mode• Virt. Mach sw runs in monitor

• Machine runs in user mode

• Create a virtual user and monitor mode which run in user mode

• When I/O request (sys. Call) transfers from virtual user to virtual monitor

• Virt. Monitor changes register contents and pgm cntr to simulate a system call

• Privileged I/O instructions is executed

• Virt. Mach. Monitor will simulate I/O instr.

Page 62: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

IBM VM

• Has privileged instructions on virtual machine and all others directly on the hw

• Program can execute even though it is not entirely in memory

• The CPU is spread across multiple virtual machines

• Advantage: Protection. Machines are isolated; good for testing; no security probl.

Page 63: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

System Design and Generation• Design Goals - safe, fast, reliable, flexible, error-free

• Mechanisms - how to do something– timer is a mechanism

• Policies - what will be done– time splice is policy

• Implementation - which language to use– Assembly is fast; C is more portable

– Ideal: memory management and CPU scheduling in Assembly; rest in C

Page 64: CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3.

SYSGEN

• Running the O/S at multiple sites

• Can configure specifically for each site– CPU, devices, memory, CPU scheduling

algorithm– What CPU will be used? How much memory?

Which devices are available? Which O/S?