67
Chapter 6 An Introduction to System Software and Virtual Machines 國國國國國國國國 國國國國國國國 國國國 (Chuan-Yu Chang ) 國國 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: [email protected]

Chapter 6 An Introduction to System Software and Virtual Machines

Embed Size (px)

DESCRIPTION

Chapter 6 An Introduction to System Software and Virtual Machines. 國立雲林科技大學 資訊工程研究所 張傳育 (Chuan-Yu Chang ) 博士 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: [email protected]. Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 6 An Introduction to System Software and Virtual Machines

Chapter 6An Introduction to System Software and Virtual Machines

國立雲林科技大學 資訊工程研究所張傳育 (Chuan-Yu Chang ) 博士Office: ES 709TEL: 05-5342601 ext. 4337E-mail: [email protected]

Page 2: Chapter 6 An Introduction to System Software and Virtual Machines

2

Introduction

The computer model, known as Von Neumannmachine described previously is capable ofexecuting programs written in machine language.

However, it lacks “ support tools ” to make theproblem- solving task easy.

A naked machine: hardware loss of any helpful user-oriented features.

Page 3: Chapter 6 An Introduction to System Software and Virtual Machines

3

Naked Machines

Need to write the program in 0s and 1s. Need to represented data in binary

form. Need to manually store programs into

memory before executing. Need to instruct the program to start

running …

Page 4: Chapter 6 An Introduction to System Software and Virtual Machines

4

User Interface

To make a Von Neumann computer usable, we must create a user interface between user and hardware. Hide from the user the messy and unnecessary details of

the underlying hardware Present information about what is happening in a way that

does not require in-depth knowledge of the internal structure of the system

Allow easy user access to the resource available on this machine

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

Page 5: Chapter 6 An Introduction to System Software and Virtual Machines

5

System Software System Software:

A collection of computer programs that manage the resources of a computer and facilitate access to those resources.

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

The set of services and resources created by the software and seen by the user is called a virtual machine or virtual environment.

Page 6: Chapter 6 An Introduction to System Software and Virtual Machines

6

System Software (cont.) The responsibilities of system software

Hide from the user details of the internal structure of the Von Neumann architecture.

Present important information in a way that is easy to understand.

Allow the user to access hardware resources in a simple and efficient way.

Provide a secure and safe environment in which to operate.

Page 7: Chapter 6 An Introduction to System Software and Virtual Machines

7

Types of System Software

Operating system, might contain: Language translators: assemblers, compilers. Memory managers

Allocate memory space for programs and data and load programs into memory prior to execution.

File system Handle the storage and retrieval of information on

mass storage devices. Scheduler

Keeps a list of programs ready to run on the processor and selects that will execute next.

Utilities Collections of library routines that provide useful

services either to a user or to other system routines.

Page 8: Chapter 6 An Introduction to System Software and Virtual Machines

8

Type of System Software

Page 9: Chapter 6 An Introduction to System Software and Virtual Machines

9

Writing a program

Use a text editor to create a program P written in high-level language.

Use the file system to store program P on the hard disk.

Use a language translator to translate program P from a high-level language into a machine language program M.

Page 10: Chapter 6 An Introduction to System Software and Virtual Machines

10

Writing a program(cont’d)

Use a loader to allocate sufficient memory to hold program M and load its instructions into memory.

Use the scheduler to schedule and run M. Use a file system to store the output of

program M into data file D. If the program did not complete

successfully, use a debugger to help locate the error.

Page 11: Chapter 6 An Introduction to System Software and Virtual Machines

11

Machine Language

Designed from a machine’s point of view, complicated and difficult to understand: It uses binary: no English-like words, mathematical symbols. It allows only numeric memory addresses. It is difficult to change. It is difficult to create data.

Page 12: Chapter 6 An Introduction to System Software and Virtual Machines

12

Assembly Language

Designed for people as well as computers Created a more productive, user-oriented

environment One of the most important new

developments in programming Second-generation language More properly viewed as Low-level

programming languages

Page 13: Chapter 6 An Introduction to System Software and Virtual Machines

13

Assembly Language (cont’d) Contrast with languages like BASIC, C, C++, Java, which are high-level programming languages. Source program

The programs written by users. Object program

A type of machine language.

Page 14: Chapter 6 An Introduction to System Software and Virtual Machines

14

The Continuum of Programming Languages

Page 15: Chapter 6 An Introduction to System Software and Virtual Machines

15

Language Translators

The software translate source program (assembly) to object program (machine code) is called assembler( 組譯程式 ).

Translators for high-level programminglanguage are called compilers( 編譯程式 ).

Page 16: Chapter 6 An Introduction to System Software and Virtual Machines

16

The translation/Loading/Execution Process

Page 17: Chapter 6 An Introduction to System Software and Virtual Machines

17

Advantages of Assembly Language Use of symbolic operation codes rather

than numeric ones. Use of symbolic memory addresses

rather than numeric ones. Data generation, the programmer can

ask the assembler to do data conversion. Pseudo-operations that provide useful

user-oriented services such as data generation.

Page 18: Chapter 6 An Introduction to System Software and Virtual Machines

18

Assembly Language Format

Format:label: op code mnemonic address field -- comment

Comment is ignored during translation andexecution.

Op code mnemonic specifies the type ofoperation (Fig. 6.5)

Symbolic labels have two advantages over numeric addresses Program clarity Maintainability

Page 19: Chapter 6 An Introduction to System Software and Virtual Machines

19

Typical Assembly Language Instruction Set

Page 20: Chapter 6 An Introduction to System Software and Virtual Machines

20

Data Generation using pseudo-op A pseudo-op invokes a service of the

assembler. Can be used to generate data:

. DATA +5 Can be used for program construction:

. BEGIN

. END They do not generate any instructions or data.

將 +5 轉成二進位表示,並且儲存在 memory 中。

Page 21: Chapter 6 An Introduction to System Software and Virtual Machines

21

Structure of a Typical Assembly Language Program

Page 22: Chapter 6 An Introduction to System Software and Virtual Machines

22

Example of Assembly(Fig. 2.9 sequential search algorithm) 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 ONE: .DATA 1

Page 23: Chapter 6 An Introduction to System Software and Virtual Machines

23

More Examples Arithmetic expression A=B+C-7 (see

p.249) Conditional operation (see p.249) Looping (see p.250-251) Compute sum of Non-Negative numbers

(see p.253)

Page 24: Chapter 6 An Introduction to System Software and Virtual Machines

24

More Examples (Cont.) Arithmetic expression A=B+C-7

LOAD BADD CSUBTRACT SEVEN

STORE A…A: .DATA 0B: .DATA 0C: .DATA 0SEVEN: .DATA 7

Page 25: Chapter 6 An Introduction to System Software and Virtual Machines

25

More Examples (Cont.) Conditional operation Input the value of x

Input the value of yIf x>= y then

output the value of xElse

Output the value of y

IN X IN Y LOAD Y COMPARE X JUMPLT PRINTY OUT X JUMP DONEPRINTY: OUT YDONE:…X: .DATA 0Y: .DATA 0

Page 26: Chapter 6 An Introduction to System Software and Virtual Machines

26

Figure 6.7Algorithm to Compute the Sum of Numbers

Page 27: Chapter 6 An Introduction to System Software and Virtual Machines

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 Machines

28

Translation and Loading The job of an assembler is to translate a

symbolic assembly language program into machine language. (object file )

The task of a loader is to read instructions from the object file and store them into memory for execution.

Page 29: Chapter 6 An Introduction to System Software and Virtual Machines

29

Assembler

An Assembler must perform the following four tasks Convert symbolic op codes to binary Convert symbolic addresses to binary Perform the assembler services requested

by the pseudo-ops Put the translated instructions into a file for

future use.

Page 30: Chapter 6 An Introduction to System Software and Virtual Machines

30

Op Code Table The conversion of

symbolic op codes such as LOAD, ADD, and SUBTRACT to binary makes use of a structure called the op code table.

This is an alphabetized list of all legal assembly language op codes and their binary equivalents.

Use binary search to find correspondence.

Operation Binary Value

Structure of the OP code Table

Page 31: Chapter 6 An Introduction to System Software and Virtual Machines

31

Symbolic Addresses Conversion After the Op code has been converted into

binary, the assembler must perform a similar task on the address field.

Translation is a two-pass process: First pass: Build the symbol table in the first pass

(Fig. 6.10, 6.11) Looks at every instruction Keeping track of the memory address Determines the address of the label.

Second pass: translate the source program into machine language. (plus handle data generation, produce object file…).(Fig. 6.12.)

Page 32: Chapter 6 An Introduction to System Software and Virtual Machines

32

Generation of the Symbol Table假設每個指令和資料均佔 1 byte ,且位址由 0 開始。

前向參考 (forward reference)

DATA 放在 HALT 之後

Page 33: Chapter 6 An Introduction to System Software and Virtual Machines

33

Translation and loading (cont.) Binding( 繫結 )

The process of associating a symbolic name with a physical memory address is called binding.

Two primary purpose of the 1st pass To bind all symbolic names to address values To enter those bindings into the symbol table.

Location counter It is using to determine the address where each instruction

will ultimately be stored. The variable used to determine the address of a given instr

uction or piece of data is called location counter.

Page 34: Chapter 6 An Introduction to System Software and Virtual Machines

34

Outline of Pass 1 of the Assembler

Page 35: Chapter 6 An Introduction to System Software and Virtual Machines

35

Translation and loading (cont.) The responsibilities of pass 2 of the assembler

Translates the source program into machine language. Look up the op code table to translate mnemonic op

codes to binary. Look up the symbol table to translate symbolic addresses

to binary. Handle data generation pseudo-ops Produce the object file

Page 36: Chapter 6 An Introduction to System Software and Virtual Machines

36

Fig 6.12 Outline of Pass 2 of the Assembler

Page 37: Chapter 6 An Introduction to System Software and Virtual Machines

37

Fig. 6.13 Example of an Object Program

Page 38: Chapter 6 An Introduction to System Software and Virtual Machines

38

The Loader

The object program would become input to loader. The loader read instructions from the object file

and store them into memory for execution. When loading is complete, the loader places the

address of the first instruction into the program counter (PC) to initial execution.

Page 39: Chapter 6 An Introduction to System Software and Virtual Machines

39

Operating Systems What program examines commands?

System command: may be lines of text typed at a terminal. Point-and-click: menu items displayed on a screen and

selected with a mouse and a button. What piece of system software waits for requests

and activates other system program? The answer is the operating system. Functions of an OS

The user interface System security and protection Encryption Efficient allocation resource The safe use of resource

Page 40: Chapter 6 An Introduction to System Software and Virtual Machines

40

The User Interface

The operating system acts like the computer’s receptionist and dispatcher

The OS commands usually request access to hardware resources, software service, or information.

After a command is entered, OS is analyzed to see which software package needs to be loaded and put on the scheduler for execution. (see Fig. 6.15)

Page 41: Chapter 6 An Introduction to System Software and Virtual Machines

41

Some Typical Operating System Commands Translate a program Load a translated program into memory Link together separate pieces of software to build a single

program. Run a program Save information in a file Retrieve a file previously stored List all the files for this user Print a file Copy a file from one I/O device to another Establish a network connection Tell me the current time and date

Page 42: Chapter 6 An Introduction to System Software and Virtual Machines

42

Figure 6.15User InterfaceResponsibility of theOperating System

Page 43: Chapter 6 An Introduction to System Software and Virtual Machines

43

The User Interface (cont.)

Types of the User Interface Prompt character

Command language Graphical user interface, GUI

The GUI supports visual aids and point-and-click operations requiring a mouse, rather than textual commands.

The interface uses icons, pull-down menus, scrolling windows…

Page 44: Chapter 6 An Introduction to System Software and Virtual Machines

44

Example of a GUI

Page 45: Chapter 6 An Introduction to System Software and Virtual Machines

45

System security and protection OS has the responsibilities of a security guard—cont

rolling access to the computer and its resource. OS must prevent unauthorized users from accessin

g the system and prevent authorized users from doing unauthorized things.

In most OS, access control is handled by requiring a user to enter a legal user name and password before any other requests are accepted .

The password file is maintained by superuser. Encrypt the password file using an encoding algorithm. Encrypted text

Page 46: Chapter 6 An Introduction to System Software and Virtual Machines

46

System security and protection (cont.) OS must check to see who is the owner of the file The different levels of operations that various users

may be permitted to do on a file. Read only Append new information to the end of the file but not

change existing information. Changes existing information in the file Delete the entire file from the system

Ex: File GradesName Permitted OperationsSmith R (R=Read only)Jones RA (A=Append)Adams RAC (C=Change)Doe RACD (D=Delete)

Page 47: Chapter 6 An Introduction to System Software and Virtual Machines

47

Efficient Allocation of Resources To see that the resources of a computer

system are used efficiently and well Three classes of programs

Running The program currently executing on the processor

Ready Programs that are loaded in memory and ready to run

but are not yet executing. Waiting

Programs that cannot run because they are waiting for an I/O

Page 48: Chapter 6 An Introduction to System Software and Virtual Machines

48

The Safe Use of Resource

Not only must resource be used efficiently, they must also be used safely. It is the job of the OS to prevent programs or

users from attempting operations that could cause the computer system to enter a state where it is incapable of doing any further work.

Program A Program BGet the tape drive Get the laser printerGet the laser printer Get the tape drivePrint the file Print the file

Page 49: Chapter 6 An Introduction to System Software and Virtual Machines

49

The Safe Use of Resource (cont.) Deadlock

Each program will be waiting for a resource to become available that never will be free.

There is a set of programs each of which is waiting for an event to occur before it may proceed, but that event can be caused only by another waiting program in the set.

Deadlock prevention The OS uses resource allocation algorithms that prevent

deadlock from occurring in the first place. If a program cannot get all the resources that it needs, it must

give up all the resources it currently owns and issue a completely new request.

Deadlock recovery We are powerless to guarantee that deadlock conditions can

never occur. We must detect them and recover from them when they do

occur.

Page 50: Chapter 6 An Introduction to System Software and Virtual Machines

50

Summary

The major responsibilities of the OS User interface management Program scheduling and activation Control of access to system and files Efficient resource allocation Deadlock detection, error detection

Page 51: Chapter 6 An Introduction to System Software and Virtual Machines

51

Historical Overview of OS development First generation OS (1945-1955)

No OS, there was very little software support (just the assembler and loader)

All machine operation was “hands-on” Second generation OS (1955-1965)

Batch operating system Computer operator groups the programs into a “batch” After a few programs were collected, the operator would

carry this batch of cards to a small I/O computer that would put these programs on tape.

These tapes would be carried into the machine room and loaded onto the “big” computer

Writing the results to another tape.

Page 52: Chapter 6 An Introduction to System Software and Virtual Machines

52

Fig. 6.18 Operation of a Batch Computer System

Page 53: Chapter 6 An Introduction to System Software and Virtual Machines

53

Fig. 6.19 Structure of a Typical Batch JobBecause programmers no longer operated the machine, they need a way to communicate to the OS what had to be done.

Job control language

Page 54: Chapter 6 An Introduction to System Software and Virtual Machines

54

Historical Overview of OS development (cont.)

Command language Job control language Users wrote commands specifying to the OS what operations

to perform on their programs The batch OS kept only a single program in memory at any

one time. Third generation OS(1965-1985)

Multiprogramming Operating Systems There are many user programs simultaneously loaded into

memory. If the currently executing program pauses for I/O, one of the

other ready jobs is selected for execution. Protecting user programs

Page 55: Chapter 6 An Introduction to System Software and Virtual Machines

55

Historical Overview of OS development (cont.)

Operating system

Program 1

Program 2

Program 3

Program K

A (upper bound)

B (lower bound)

Multiprogramming Memory Protected

The 3G OS would keep track of the upper and lower address bounds of

each program in memory.

Page 56: Chapter 6 An Introduction to System Software and Virtual Machines

56

Historical Overview of OS development (cont.)

User operation codes That could be included in any user program.

Privileged operation codes Whose use was restricted to the operating system or oth

er system software Eg. HALT instruction

Time-sharing system (1960-1970)

Central ComputerT

T

T TT

T

Telecommunications linkTerminal

Page 57: Chapter 6 An Introduction to System Software and Virtual Machines

57

Historical Overview of OS development (cont.)

compute-bound It does mostly computation and little or no I/O A compute-bound job keeps the processor heavily utilized. To design a time-sharing system, we must make some

change to the multiprogramming OS A program can keep the processor until either of the

following events occurs: It initiates an I/O operation. It has run for a maximum length of time, called a time slice.

The basic idea in a time-sharing system is to service many users in a circular round-robin fashion. Given each user a small amount of time and then moving on

to the next.

Page 58: Chapter 6 An Introduction to System Software and Virtual Machines

58

Historical Overview of OS development (cont.)

The number of simultaneous users that can be serviced by a time-sharing system depends on: The speed of the processor The time slice given to each user The type of operation each user is doing

Single-user OS Gave one user total access to the entire system.

Distributed environment Much of the computing was done remotely in the office. Computing moved out of the computer center to where

the work was being done

Page 59: Chapter 6 An Introduction to System Software and Virtual Machines

59

Historical Overview of OS development (cont.)

The fourth-generation OS (1985-present) Supported both local computation and remote

access to other users and shared resources. Network operating system

The OS Manages not only the resources of a single computer but also the capabilities of a telecommunications system called a local area network (LAN).

LAN is a network that is located in a geographically contiguous area such a room, a building, or a campus.

LAN is composed of PCs, workstations, servers, all interconnected via a high-speed bus.

Page 60: Chapter 6 An Introduction to System Software and Virtual Machines

60

Historical Overview of OS development (cont.) There are many shared resources that can

be provided by a network and its OS: File servers

It is a large disk storage facility that is available to any user on the network.

Printer servers Compute server Mail server

Page 61: Chapter 6 An Introduction to System Software and Virtual Machines

61

A Local Area Network (LAN)

Page 62: Chapter 6 An Introduction to System Software and Virtual Machines

62

Figure 6.22The Virtual Environment Created by a Network Operating System

Page 63: Chapter 6 An Introduction to System Software and Virtual Machines

63

Historical Overview of OS development (cont.) Real time operating system

It guarantees that it can service the important requests within a fixed amount of time.

All requests to a real-time OS are prioritized. Embedded system

To place computer inside other pieces of equipment to control their operation.

Eg. Include computers placed inside automobile engines, microwave ovens…

Page 64: Chapter 6 An Introduction to System Software and Virtual Machines

64

Historical Overview of OS development (cont.) Fifth Generation OS

Multimedia user interface Parallel processing OS

That will manage systems containing hundreds or even thousands of processors.

Distributed operating system The user does not care where or how the system

satisfies a request as long as it gets done correctly.

Page 65: Chapter 6 An Introduction to System Software and Virtual Machines

65

Historical Overview of OS development (cont.) In a 4G OS, the user issues the following

types of commands Access file F on file server S and copy it to my

local system Run program P on machine M Save file F on file server T Print file F on printer server Q

Page 66: Chapter 6 An Introduction to System Software and Virtual Machines

66

Historical Overview of OS development (cont.) In a distributed OS, the user issues the

following types of commands Access file F wherever it may be Run program P on any machine currently

available Save file F wherever there is sufficient room. Print file F on any printer with 400 dpi resolution

that is not in use right now.

Page 67: Chapter 6 An Introduction to System Software and Virtual Machines

67

Figure 6.23Structure of a Distributed System