Download Chapter 6 An Introduction to System Software

Document related concepts

Process management (computing) wikipedia , lookup

Acorn MOS wikipedia , lookup

MTS system architecture wikipedia , lookup

Library (computing) wikipedia , lookup

Spring (operating system) wikipedia , lookup

RSTS/E wikipedia , lookup

OS 2200 wikipedia , lookup

Burroughs MCP wikipedia , lookup

Unix security wikipedia , lookup

CP/M wikipedia , lookup

VS/9 wikipedia , lookup

Transcript
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



The computer model, known as Von Neumann
machine described previously is capable of
executing programs written in machine language.
However, it lacks “ support tools ” to make the
problem- solving task easy.
A naked machine: hardware loss of any helpful
user-oriented features.
2
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 …
3
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
4
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.
5
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.
6
Types of System Software

Operating system, might contain:


Language translators: assemblers, compilers.
Memory managers


File system


Handle the storage and retrieval of information on mass
storage devices.
Scheduler


Allocate memory space for programs and data and load
programs into memory prior to execution.
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.
7
Type of System Software
8
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.
9
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.
10
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.
11
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
12
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.
13
The Continuum of Programming Languages
14
Language Translators


The software translate source program
(assembly) to object program (machine code) is
called assembler.
Translators for high-level programming
language are called compilers.
15
The translation/Loading/Execution Process
16
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 useroriented services such as data generation.
17
Assembly Language Format

Format:
label: op code mnemonic



address field -- comment
Comment is ignored during translation and
execution.
Op code mnemonic specifies the type of
operation (Fig. 6.5)
Symbolic labels have two advantages over
numeric addresses


Program clarity
Maintainability
18
Typical Assembly Language Instruction Set
19
Data Generation using pseudo-op



A pseudo-op invokes a service of the assembler.
Can be used to generate data:
將+5轉成二進位表示,並
. DATA +5
且儲存在memory中。
Can be used for program construction:
. BEGIN
. END

They do not generate any instructions or data.
20
Structure of a Typical Assembly Language Program
21
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
22
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)
23
More Examples (Cont.)

Arithmetic expression A=B+C-7

LOAD B
ADD C
SUBTRACT SEVEN
STORE
A
…
A:
.DATA
B:
.DATA
C:
.DATA
SEVEN: .DATA
0
0
0
7
24
More Examples (Cont.)


Conditional operation
Input the value of x
Input the value of y
If x>= y then
output the value of x
Else
Output the value of y

IN
X
IN
Y
LOAD Y
COMPARE X
JUMPLT PRINTY
OUT X
JUMP DONE
OUT Y
PRINTY:
DONE:
…
X: .DATA 0
Y: .DATA 0
25
Figure 6.7
Algorithm to Compute the Sum of Numbers
26
Figure 6.8 Assembly Language Program to
Compute the Sum of Nonnegative Numbers
27
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.
28
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.
29
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.
Structure of the OP
code Table
Operation
Binary Value
30
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.)
31
Generation of the Symbol Table
假設每個指令和資料均佔1 byte,且位址由0開始。
前向參考(forward
reference)
DATA放在HALT之後
32
Translation and loading (cont.)

Binding


Two primary purpose of the 1st pass



The process of associating a symbolic name with a
physical memory address is called binding.
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
instruction or piece of data is called location counter.
33
Outline of Pass 1 of the Assembler
34
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
35
Fig 6.12 Outline of Pass 2 of the Assembler
36
Fig. 6.13 Example of an Object Program
37
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.
38
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
39
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)
40

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
41
Figure 6.15
User Interface
Responsibility of the
Operating System
42
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…
43
Example of a GUI
44
System security and protection




OS has the responsibilities of a security guard—
controlling access to the computer and its resource.
OS must prevent unauthorized users from accessing
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
45
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 Grades
Name
Smith
Jones
Adams
Doe
Permitted Operations
R
(R=Read only)
RA
(A=Append)
RAC
(C=Change)
RACD (D=Delete)
46
Efficient Allocation of Resources


To see that the resources of a computer
system are used efficiently and well
Three classes of programs

Running


Ready


The program currently executing on the processor
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
47
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 B
Get the tape drive
Get the laser printer
Get the laser printer
Get the tape drive
Print the file
Print the file
48
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.
49
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
50
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.
51
Fig. 6.18 Operation of a Batch Computer System
52
Fig. 6.19 Structure of a Typical Batch Job
Because programmers no longer operated the machine, they need a way
to communicate to the OS what had to be done.
Job control
language
53
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
54
Historical Overview of OS development (cont.)
Multiprogramming
Memory Protected
Operating system
Program 1
Program 2
A (upper bound)
Program K
B (lower bound)
Program 3
The 3G OS would keep track of the
upper and lower address bounds of
each program in memory.
55
Historical Overview of OS development (cont.)

User operation codes


Privileged operation codes



That could be included in any user program.
Whose use was restricted to the operating system or
other system software
Eg. HALT instruction
Time-sharing system (1960-1970)
T
T
Central Computer
T
T
T
Terminal
T
Telecommunications link
56
Historical Overview of OS development (cont.)

compute-bound




A program can keep the processor until either of the
following events occurs:



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
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.
57
Historical Overview of OS development (cont.)

The number of simultaneous users that can be
serviced by a time-sharing system depends on:




Single-user OS


The speed of the processor
The time slice given to each user
The type of operation each user is doing
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
58
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.
59
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
60
A Local Area Network (LAN)
61
Figure 6.22
The Virtual Environment Created by a Network Operating System
62
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…
63
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.
64
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
65
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.
66
Figure 6.23
Structure of a Distributed System
67