chapter 6: an introduction to system software and virtual ... · system software acts as an...

61
Chapter 6: An Introduction to System Software and Virtual Machines Invitation to Computer Science, C++ Version, Fourth Edition

Upload: others

Post on 19-Apr-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Chapter 6:

An Introduction to System

Software and Virtual Machines

Invitation to Computer Science,

C++ Version, Fourth Edition

Page 2: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 2

Objectives

In this chapter, you will learn about

System software

Assemblers and assembly language

Operating systems

Page 3: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 3

Introduction

Von Neumann computer

“Naked machine”

Hardware without any helpful user-oriented features

Extremely difficult for a human to work with

An interface between the user and the hardware is needed to make a Von Neumann computer usable

Page 4: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 4

Introduction (con't)

Tasks of the interface

Hide details of the underlying hardware from the user

Present information in a way that does not require in-depth knowledge of the internal structure of the system (Abstraction )

Allow easy user access to the available resources

Prevent accidental or intentional damage to hardware, programs, and data

Page 5: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 5

System Software: The Virtual Machine

System software

Acts as an intermediary between users and hardware

Creates a virtual environment for the user that hides the actual computer architecture

Virtual machine (or virtual environment)

Set of services and resources created by the system software and seen by the user

Page 6: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 6

Figure 6.1 The Role of System Software

Page 7: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 7

Types of System Software

System software is a collection of many different programs

Operating system

Controls the overall operation of the computer

Communicates with the user

Determines what the user wants

Activates system programs, applications packages, or user programs to carry out user requests

Page 8: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 8

Figure 6.2 Types of System Software

Page 9: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Static View of System Components

Program Interface

Humans

User Programs

O.S. Interface

O.S.

Hardware Interface/

Privileged Instructions

Disk/Tape/Memory 9

Page 10: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

OPERATING SYSTEM

OVERVIEW Hardware

Support

These are the devices that make

up a typical system.

Any of these devices can cause an

electrical interrupt that grabs the

attention of the CPU.

10

Page 11: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 11

Types of System Software (con't)

User interface

Graphical user interface (GUI) provides graphical control of the capabilities and services of the computer

Language services

Assemblers, compilers, and interpreters

Allow you to write programs in a high-level, user-oriented language, and then execute them

Page 12: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 12

Types of System Software (con't)

Memory managers

Allocate and retrieve memory space

Information managers

Handle the organization, storage, and retrieval of information on mass storage devices

I/O systems

Allow the use of different types of input and output devices

Page 13: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 13

Types of System Software (con't)

Scheduler

Keeps a list of programs ready to run and selects the one that will execute next

Utilities

Collections of library routines that provide services either to user or other system routines

Page 14: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 14

Assembly Language

Machine language

Uses binary

Allows only numeric memory addresses

Difficult to change

Difficult to create data

Page 15: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 15

Assembly Language (con't)

Assembly languages

Designed to overcome shortcomings of machine languages

Create a more productive, user-oriented environment

Earlier termed second-generation languages

Now viewed as low-level programming languages

Page 16: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 16

Figure 6.3 The Continuum of Programming Languages

assembler

machine code

compiler

Page 17: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 17

Assembly Language (con't)

Source program

An assembly language program

Object program

A machine language program

Assembler

Translates a source program into a corresponding object program

Page 18: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 18

Figure 6.4 The Translation/Loading/Execution Process

Page 19: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 19

Assembly Language (con't)

Advantages of writing in assembly language rather than machine language

Use of symbolic operation codes rather than numeric (binary) ones

Use of symbolic memory addresses rather than numeric (binary) ones

Pseudo-operations that provide useful user-oriented services such as data generation

Page 20: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 20

Figure 6.6 Structure of a Typical Assembly Language Program

Page 21: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 21

Examples of Assembly Language

Code

Algorithmic operations

Set the value of i to 1 (line 2).

:

Add 1 to the value of i (line 7).

Page 22: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 22

Examples of Assembly Language

Code (con't)

Assembly language translation .BEGINE

LOAD ONE --Put a 1 into register R.

STORE I --Store the constant 1 into i.

INCREMENT I --Add 1 to memory location i.

I: .DATA 0 --The index value. Initially it is 0.

ONE: .DATA 1 --The constant 1.

.END

data section

pseudo code

symbolic label

symbolic op code

Page 23: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 23

Examples of Assembly Language

Code (con't)

Arithmetic expression

A = B + C – 7

(Assume that B and C have already been assigned values)

Page 24: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 24

Examples of Assembly Language

Code (con't)

Assembly language translation .

LOAD B --Put the value B into register R.

ADD C --R now holds the sum (B + C).

SUBTRACT SEVEN --R now holds the expression (B + C - 7).

STORE A --Store the result into A.

… --These data should be placed after the HALT.

A: .DATA 0

B: .DATA 0

C: .DATA 0

SEVEN: .DATA 7 --The constant 7.

Page 25: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 25

Examples of Assembly Language

Code (con't)

Problem

Read in a sequence of non-negative numbers, one number at a time, and compute a running sum

When you encounter a negative number, print out the sum of the non-negative values and stop

Page 26: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 26

Figure 6.7 Algorithm to Compute the Sum of Numbers

Page 27: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 27

Figure 6.8 Assembly Language Program to Compute

the Sum of Nonnegative Numbers

Page 28: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

28

Try It

Create Assembly Code for the following algorithm:

Get a number X

Get a number Y

If Y > X then

print out Y

Else

print out X

Stop

Page 29: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 29

Translation and Loading

Before a source program can be run, an assembler and a loader must be invoked

Assembler

Translates a symbolic assembly language program into machine language

Loader

Reads instructions from the object file and stores them into memory for execution

.asm .obj

.obj

Page 30: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 30

Translation and Loading (con't)

Assembler tasks

Convert symbolic op codes to binary

Convert symbolic addresses to binary

Perform assembler services requested by the pseudo-ops

Put translated instructions into a file for future use

Page 31: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 31

Translation and Loading (con't)

symbolic op codes

symbolic addresses

(label field)

pseudo-ops

Page 32: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Figure 6.11 Pass 1 of the Assembler 32

Task 1: keep track of the memory

address of every instruction

Task 2: keep track of the memory

address of every symbol in label

field

=> After pass 1, the memory space

required for the program is known.

Page 33: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Generation of Symbol Table

Invitation to Computer Science, C++ Version, Fourth Edition 33

Binding: Associating a symbolic name

with a physical memory address

Page 34: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

34 Figure 6.12 Pass 2 of the Assembler

Task 1: look up the op code table

and replace the binary value in the

op code field.

Task 2: look up the symbol table

and replace the binary address

value in the address field.

Page 35: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Generation of Symbol Table

Invitation to Computer Science, C++ Version, Fourth Edition 35

OP Code Table

Page 36: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Pseudo-OPs

A pseudo-op is an instruction to the assembler that does not generate any machine code.

In general, pseudo-ops give the assembler information about, and.

Handling data generation

Ex: data alignment, block and segment definition

Producing the object file needed by the loader

Ex: base register assignment

Invitation to Computer Science, C++ Version, Fourth Edition 36

.BEGIN

.DATA

.END

Page 37: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 37

Operating Systems

System commands

Carry out services such as translate a program, load a program, run a program

Types of system commands

Lines of text typed at a terminal

Menu items displayed on a screen and selected with a mouse and a button: Point-and-click

Examined by the operating system

Page 38: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 38

Functions of an Operating System

Five most important responsibilities of the operating system

User interface management

Program scheduling and activation

Control of access to system and files

Efficient resource allocation

Deadlock detection and error detection

Page 39: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Booting an Operating System

Invitation to Computer Science, C++ Version, Fourth Edition 39

Page 40: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

40

How computer startup?

Booting is a bootstrapping process that starts operating systems when the user turns on a computer system

A boot sequence is the set of operations the computer performs when it is switched on that load an operating system

1. Tern on 2. CPU jump to address of BIOS (0xFFFF0) 3. BIOS runs POST (Power-On Self Test) 4. Find bootable devices 5. Loads and execute boot sector form MBR 6. Load OS

Beep Error Message 1 short POST OK! 1 long Memory problem 1 long, 2 short Video card error 1 long, 3 short No video card or bad video RAM Repeating beeps Memory error High Frequency beeps Overheating CPU

Page 41: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

41

How Linux boot?

Page 42: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

42

BIOS (Basic Input/Output System)

BIOS refers to the software code run by a computer when first powered on

The primary function of BIOS is code program embedded on a chip that recognises and controls various devices that make up the computer.

BIOS on board BIOS on screen

Page 43: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

43

MBR (Master Boot Record)

OS is booted from a hard disk, where the Master Boot Record (MBR) contains the primary boot loader

The MBR is a 512-byte sector

The first sector on the disk

(sector 1 of cylinder 0, head 0)

After the MBR is loaded into

RAM, the BIOS yields control

to it.

0x55AA

Page 44: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

44

MBR (Master Boot Record)

The first 446 bytes are the primary boot loader, which contains both executable code and error message text

The next sixty-four bytes are the partition table, which contains a record for each of four partitions

The MBR ends with two bytes that are defined as the magic number (0xAA55). The magic number serves as a validation check of the MBR

Page 45: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

45

Boot loader

Boot loader could be more aptly called the kernel loader. The task at this stage is to load the Linux kernel

Optional, initial RAM disk

GRUB and LILO are the most popular Linux boot loader.

http://people.cs.nctu.edu.tw/~huangmc/works/web/Boot_x86/Boot_x86.html

Page 46: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 46

The User Interface

Operating system

Waits for a user command

If command is legal, activates and schedules the appropriate software package

User interfaces

Text-oriented

prompt character

Graphical

Page 47: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 47

Figure 6.15

User Interface

Responsibility of the

Operating System

Page 48: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 48

System Security And Protection

The operating system must prevent

Non-authorized people from using the computer

User names and passwords

Legitimate users from accessing data or programs they are not authorized to access

Authorization lists

Page 49: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 49

Efficient Allocation Of Resources

The operating system ensures that

Multiple tasks of the computer can be underway at one time

Processor is constantly busy

Keeps a queue of programs that are ready to run

Whenever processor is idle, picks a job from the queue and assigns it to the processor

Page 50: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 50

The Safe Use Of Resources

Deadlock

Two processes are each holding a resource the other needs

Neither process will ever progress

The operating system must handle deadlocks

Deadlock prevention

Deadlock recovery

Page 51: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 51

Historical Overview of Operating

Systems Development

First generation of system software (roughly 1945-1955)

No operating systems

Assemblers and loaders were almost the only system software provided

Page 52: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 52

Historical Overview of Operating

Systems Development (con't)

Second generation of system software (1955-1965)

Batch operating systems

Ran collections of input programs one after the other

Included a command language

Page 53: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 53

Figure 6.18

Operation of a Batch Computer System

Page 54: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 54

Third-generation operating systems (1965-1985)

Multi-programmed operating systems

Permitted multiple user programs to run at once

Time sharing system

Historical Overview of Operating

Systems Development (con't)

Page 55: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 55

Fourth-generation operating systems (1985-present)

Network operating systems

Virtual environment treats resources physically residing on the computer in the same way as resources available through the computer’s network

Historical Overview of Operating

Systems Development (con't)

Page 56: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 56

Figure 6.22

The Virtual Environment Created by a Network Operating System

Page 57: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 57

The Future

Operating systems will continue to evolve

Possible characteristics of fifth-generation systems

Multimedia user interfaces

Parallel processing systems

Completely distributed computing environments

Page 58: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 58

Figure 6.23

Structure of a Distributed System

Page 59: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 59

Figure 6.24 Some of the Major Advances in Operating Systems Development

Page 60: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 60

Summary

System software acts as an intermediary between the users and the hardware

Assembly language creates a more productive, user-oriented environment than machine language

An assembler translates an assembly language program into a machine language program

Page 61: Chapter 6: An Introduction to System Software and Virtual ... · System software Acts as an intermediary between users and hardware ... Invitation to Computer Science, C++ Version,

Invitation to Computer Science, C++ Version, Fourth Edition 61

Summary (con't)

Responsibilities of the operating system

User interface management

Program scheduling and activation

Control of access to system and files

Efficient resource allocation

Deadlock detection and error detection