Chapter 6: An Introduction to System Software and Virtual Machines PowerPoint PPT Presentation

presentation player overlay
1 / 68
About This Presentation
Transcript and Presenter's Notes

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


1
Chapter 6 An Introduction to System Software and
Virtual Machines
  • Invitation to Computer Science,
  • C Version, Third Edition

2
Objectives
  • In this chapter, you will learn about
  • System software
  • Assemblers and assembly language
  • Operating systems

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

4
Introduction (continued)
  • 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

5
Introduction (continued)
  • Tasks of the interface (continued)
  • Allow easy user access to the available resources
  • Prevent accidental or intentional damage to
    hardware, programs, and data

6
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

7
  • Figure 6.1
  • The Role of System Software

8
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

9
  • Figure 6.2
  • Types of System Software

10
Types of System Software (continued)
  • 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

11
Types of System Software (continued)
  • 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

12
Types of System Software (continued)
  • 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

13
Programming Languages
  • Figure 6.3
  • The Continuum of Programming Languages
  • System software provides compilers or
    interpreters for high level languages.
  • Also provides assemblers as a low-level language
    service

14
Assembly Language
  • 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

15
Assemblers and Assembly LanguageMachine
Language vs Assembly Language
  • Machine language
  • Uses binary
  • Allows only numeric memory addresses
  • Difficult to change
  • Difficult to create data

16
Assemblers and Assembly LanguageMachine
Language vs Assembly Language
  • Assembly Language
  • Uses symbolic operation codes rather than numeric
    (binary) ones
  • Uses symbolic memory addresses rather than
    numeric (binary) ones
  • Has pseudo-operations that provide useful
    user-oriented services such as data generation

17
Using Assembly Language to Develop Software
  • Source program
  • An assembly language program
  • Object program
  • A machine language program
  • Assembler
  • Translates a source program into a corresponding
    object program

18
  • Figure 6.4
  • The Translation/Loading/Execution Process

19
Examples of Assembly Language Code
  • Arithmetic expression A B C 7
  • (Assume that B and C have already been assigned
    values)

20
Label OpCode Address Comment
.BEGIN
LOAD B --Put CON(B) into register R
ADD C --R now holds the sum (BC)
SUBTRACT SEVEN --R now holds value (B C 7)
STORE A --Store CON(R) into A
HALT
A .DATA 0 -- intialize data item A to 0
B .DATA 0 -- initialize data item B to 0
C .DATA 0 -- initialize data item C to 0
SEVEN .DATA 7 -- initialize data item SEVEN to 7
.END
21
Assembly Language Example 2
.BEGIN -- start of the program
IN X -- Input X IN Y
-- Input Y LOAD Y -- Load Y
into register R COMPARE X -- Compare
X to Y JUMPGT PRINTX -- Jump if X gt Y
OUT Y -- Didn't jump so print Y
JUMP DONE -- and go to end PRINTX
OUT X -- X gt Y so print X DONE HALT
- Stop X .DATA 0 Y .DATA
0.END -- end of the program
Get the value of xGet the value of yIf x gt y
then Print the value of xElse Print the
value of y
22
Assembly Language Example 3
  • 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

23
  • Figure 6.7
  • Algorithm to Compute the Sum of Numbers
  • Assembly language has no while statement
  • Need to rewrite before converting to assembly
    language

24
Assembly Language Example 3 contd.
  • Set the value of Sum to 0
  • Get the value of N
  • If ( n lt 0) GoTo Step 7
  • Set the value of Sum to Sum N
  • Get the value of N
  • GoTo Step 3
  • Print the value of Sum
  • Stop

25
Figure 6.8 Assembly Language Program to Compute
the Sum of Nonnegative Numbers
26
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

27
Translation and Loading (continued)
  • 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

28
Pass 1 of Assembler Builds a Symbol Table
.BEGIN -- start of the
program0 IN X -- Input X1
IN Y -- Input Y2 LOAD Y
-- Load Y into register R3 COMPARE X
-- Compare X to Y4 JUMPGT PRINTX --
Jump if X gt Y5 OUT Y -- Didn't
jump so print Y6 JUMP DONE -- and go
to end7 PRINTX OUTX -- X gt Y so
print X8 DONE HALT - Stop9
X .DATA 010 Y .DATA 0 .END
-- end of the program
Symbol Table
Symbol Address
PRINTX ..0111 (7)
DONE ..1000 (8)
X ..1001 (9)
Y ..1010 (10)
29
Pass 2 of Assembler Builds an Object File
more_lines T While (more_lines) do Read
the next instruction, instr If (instr
.END) more_lines F Else
If (instr .DATA) process it
Else look up opcode in table
look up address in symbol table build
instruction append instruction to object
file Endif Endwhile Write file to disk Stop
.BEGIN IN X IN Y LOAD
Y COMPARE X JUMPGT PRINTX
OUT Y JUMP DONEPRINTX OUTX DONE
HALT X .DATA 0 Y .DATA 0.END
Symbol Address
PRINTX 0000 0000 0111 (7)
DONE 0000 0000 1000 (8)
X 0000 0000 1001 (9)
Y 0000 0000 1010 (10)
IN X ? 1101 0000 0000 1001IN Y ? 1101 0000 0000
1010JUMP DONE ? 1000 0000 0000 1000
30
Assembler Performance Considerations
  • Pass 2 Tasks for each line of source code
  • Convert symbolic opcode to numeric opcode -
    Table lookup
  • Convert symbolic address to numeric opcode -
    Table lookup
  • Concatenate numeric address with numeric opcode
  • What if 100s of opcodes and 100,000 lines of code?

Store symbol table in binary search tree
31
Binary Search Tree for Opcodes
To make pass 1 of the assembler more efficient,
alphabetizethe symbolic opcodes, so they can be
located using binarysearch. See binary search
tree below.
32
(No Transcript)
33
Pass 2 of assembler
34
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

35
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

36
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
  • Graphical

37
Figure 6.15 User Interface Responsibility of
the Operating System
38
Text Oriented Interface (CLI)
durand_at_neptune grep 'cout' array2.cpp
sort cout ltlt arri ltlt '\n' cout ltlt arri ltlt
'\n' cout ltlt "\n" cout ltlt "\nArray
contents\n" cout ltlt "\nArray contents\n" using
stdcout durand_at_neptune
39
Graphical User Interface (GUI)
40
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

41
UNIX User IDs Passwords
  • Every person who uses a UNIX computer should have
    an account.
  • An account is identified by a username.
  • Traditionally, each account also has a secret
    password associated with it to prevent
    unauthorized use.
  • You need to know both your username and your
    password to log into a UNIX system.
  • The username is an identifier it tells the
    computer who you are.
  • The password is an authenticator you use it to
    prove to the operating system that you are who
    you claim to be.

42
UNIX User IDs Passwords Contd.
  • Standard UNIX usernames may be between one and
    eight characters long.
  • Within a given UNIX machine, usernames are
    unique. No two users can have the same one
  • A single person can have more than one UNIX
    account on the same computer.
  • UNIX passwords are between one and eight
    characters long.
  • More than one user can theoretically have the
    same password.

43
UNIX User IDs Passwords Contd.
  • UNIX uses the /etc/passwd file to keep track of
    every user on the system.
  • It contains the username, real name,
    identification information, and basic account
    information for each userrootfi3sED95ibqR601
    System Operator//bin/ksh daemon11/tmpuuc
    pOORoMN9FyZfNE44/var/spool/uucppublic/usr/li
    b/uucp/uucicoracheleH5/.mj7NB3dx181100Rachel
    Cohen/u/rachel/bin/ksharlinf8fk3j1OIf34.1821
    00Arlin Steinberg/u/arlin/bin/csh
  • rachel The usernameeH5/.mj7NB3dx The user's
    "encrypted password181 The user's user
    identification number (UID100 The user's group
    identification number (GIDRachel Cohen The
    user's full name/u/rachel The user's home
    directory/bin/ksh The user's shell

44
UNIX Encrypted Password System
  • When UNIX requests your password, it needs some
    way of determining that the password you type is
    the correct one.
  • In the /etc/passwd file UNIX stores a value that
    is generated by using the password to encrypt a
    block of zero bits with a one-way function called
    crypt( ) .
  • When you try to log in, the program / bin/login
    takes the password that you typed, uses it to
    transform another block of zeros
  • It then compares the newly transformed block with
    the block stored in the /etc/passwd file.
  • If the two encrypted results match, the system
    lets you in.

45
UNIX File Permission System
  • The UNIX filesystem controls the way that
    information in files and directories is stored on
    disk and other forms of secondary storage.
  • It controls which users can access what items and
    how. ls -lF total 161 -rw-r--r-- 1 sian user
    505 Feb 9 1319 instructions -rw-r--r-- 1 sian
    user 3159 Feb 9 1314 invoice -rw-r--r-- 1 sian
    user 6318 Feb 9 1314 letter -rw------- 1 sian
    user 15897 Feb 9 1320 more-stuff -rw-r----- 1
    sian biochem 4320 Feb 9 1320 notes -rwxr-xr-x 1
    sian user 122880 Feb 9 1326 stats
  • Here are two examples of file permissions-rw----
    ---
  • drwxr-xr-x

46
UNIX File Permission System
  • Starting with the second character, nine
    characters taken in groups of three indicate who
    on your computer can do what with the file.
  • There are three kinds of permissions
  • r Permission to read
  • w Permission to write
  • x Permission to execute
  • Similarly, there are three classes of
    permissions
  • owner The file's owner
  • group Users who are in the file's group
  • other Everybody else on the system (except the
    superuser)

47
UNIX File Permission System
  • Consider this listing-rw-r--r-- 1 sian user 505
    Feb 9 1319 instructions Field
    Contents Meaning- The file's
    typerw-r--r-- The file's permissions1 The
    number of "hard" links to the filesian The
    name of the file's owneruser The name of the
    file's group505 The file's size, in bytesFeb
    9 1319 The file's modification
    timeinstructions The file's name
  • rw- user permissions
  • r-- group permissions
  • r-- other permissions

48
Efficient Allocation Of Resources
  • The operating system ensures that
  • Multiple tasks of the computer may 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

49
Efficient Allocation Of Resources
  • The typical I/O operation might require several
    milliseconds to execute so the OS tries to keep
    the processor busy performing other useful
    tasks.
  • It maintains three classes of programs
  • The Running class contains the program currently
    executing in the processor.
  • The Ready class contains any other programs that
    are loaded into memory and ready to run.
  • The Waiting class contains those programs that
    cannot run yet because they are waiting for some
    I/O operation to complete.

50
State Diagram for Process Management
  • If the program in the Running class initiates an
    I/O operation, the OS moves it to the Waiting
    class and moves some other program from the Ready
    class to the Running class.
  • A program in the Waiting class is moved to the
    Ready class whenever its I/O operation completes.

51
Process Management Queues
A
B
Running
B C D
Ready
C D
?
Waiting
E
E A
Process A issues an i/o request and is moved to
the end of the Waiting queue. Process B is moved
to Running statusProcesses C D move up in the
Ready queue
52
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

53
Traffic Deadlock
54
Resource Deadlock Example
  • Imagine a system with one laser printer, one data
    file D, and two programs, A and B.
  • Each program makes the following requests to the
    OS
  • Program A Program BGet data file D Get the
    laser printerGet the laser printer Get data file
    DPrint the file Print the file
  • If the OS grants each programs initial request
    we have a deadlock.

55
Communication Deadlock Example
  • Imagine a telecommunication system. Program A
    sends messages to program B, which acknowledges
    receipt.
  • A cannot send another message to B, until B
    acknowledges correct receipt of the first
    message.
  • Program A Program BMessage ? ?
    AcknowledgeMessage ? ? AcknowledgeMessage
    ?
  • Say B sends and Ack, but it gets lost.
  • Deadlock. A and B are both stopped waiting on the
    other.

56
Solutions to Resource Deadlock
  • Deadlock Prevention OS uses resource allocation
    algorithms that prevent deadlock from occurring.
  • If a program cannot get all the resources it
    needs, it must give up all the resources it
    currently owns and issue a completely new
    request
  • Program A Program B1.Get data file D 2.Get
    the laser printer3.Get the laser printer 4.Get
    data file D5.Print the file 6.Print the file
  • At point 3, program A cannot get the printer and
    must relinquish the data file. Program B gets the
    file and prints.

57
Solutions to Communication Deadlock
  • Program A Program BMessage01 ? ?
    Acknowledge01Message02 ? ?
    Acknowledge02Message03 ?
    ? ? Acknowledge03
  • New protocol
  • Break message into parts and number the parts
    consecutively
  • A sends Message-N . If Ack-N is not received in a
    set time interval, A resends Message-N
  • B receives Message-N. It sends Ack-N and discards
    any previous copies of Message-N

58
Historical Overview of Operating Systems
Development
  • First generation of system software (roughly
    19451955)
  • No operating systems
  • Assemblers and loaders were almost the only
    system software provided

59
Historical Overview of Operating Systems
Development (continued)
  • Second generation of system software (19551965)
  • Batch operating systems
  • Ran collections of input programs one after the
    other
  • Included a command language

60
  • Figure 6.18
  • Operation of a Batch Computer System

61
Historical Overview of Operating Systems
Development (continued)
  • Third-generation operating systems (19651985)
  • Multiprogrammed operating systems
  • Permitted multiple user programs to run at once

62
Historical Overview of Operating Systems
Development (continued)
  • Fourth-generation operating systems
    (1985present)
  • Network operating systems
  • Virtual environment treats resources physically
    residing on the computer in the same way as
    resources available through the computers network

63
  • Figure 6.22
  • The Virtual Environment Created by a Network
    Operating System

64
The Future
  • Operating systems will continue to evolve
  • Possible characteristics of fifth-generation
    systems
  • Multimedia user interfaces
  • Parallel processing systems
  • Completely distributed computing environments

65
  • Figure 6.23
  • Structure of a Distributed System

66
Figure 6.24 Some of the Major Advances in
Operating Systems Development
67
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

68
Summary
  • 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
Write a Comment
User Comments (0)
About PowerShow.com