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

1 / 30
About This Presentation
Title:

Chapter 6 An Introduction to System Software and Virtual Machines'

Description:

When you encounter a negative number, print out the sum of the non negative values and stop. ... give up all what it owns and issue a completely new request ... – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 31
Provided by: bonita4
Category:

less

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.
2
  • Von Neumann has the capability of executing
    programs in machine language
  • No support tools to make problem solving easier
  • This is prone to errors. We call this the naked
    machine since there is only hardware support and
    no software.
  • To use the machine we must
  • Write programs in binary machine instructions,
    data should be in binary
  • Put the program and data in memory
  • Put the start address into PC and start the
    Fetch/Decode/Execute cycle.
  • But doing this makes changing a program difficult
  • Eg. if there is a jump to address 500 instruction
    and an instruction is inserted before address 500
    in the machine. Then the previous jumpto address
    will not be correct anymore. It has to be
    updated as well.
  • We need an interface between user and hardware.
  • Users view of computer is those operations the
    system software makes available.

3
  • System software is a collection of programs that
    manage the resources of a computer and facilitate
    access to those resources.
  • Includes the user interface
  • Acts as an intermediary between users and the
    hardware.
  • There is no black box around software
  • Software is a sequence of instructions programs
    that solve a problem.
  • The set of services and resources created by the
    software and seen by the user is called a virtual
    machine or virtual environment.
  • Figure 6.1

4
  • Functions of the System software
  • Hide from user details of internal structure of
    Von Neumann
  • 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
  • Eg. to add, using abc is easier than loading
    registers, activating ALU, selecting output of
    circuit and sending result to a.
  • Program should be loaded into RAM without the
    programmer specifying where to place it.

5
  • There are two main types of user interfaces
  • Command line interface
  • User types commands and command interpreter
    executes it.
  • Graphical User interface(GUI)
  • A mouse or pointing device is used to click icons
    which the user interface detects.
  • The various types of system software in the
    Operating system are
  • Operating System (OS) eg. Win 2000, Win XP,
    Linux, UNIX.
  • Language translators
  • Assemblers
  • Compilers
  • Memory Managers
  • Loaders
  • Linkers
  • Information managers
  • File systems
  • Database systems
  • Scheduler
  • Utilities
  • Text editors

6
Assemblers and assembly language
  • Machine language is complicated (binary, numeric
    memory addresses, difficult to change,
    difficult/tedious to create data in binary).
  • We use assembly language. And an assembler
    associated with it. The assembler falls under the
    system software. We also call them second
    generation languages/low level programming
    languages.
  • Figure 6.3, Programming languages.
  • Advantages of using assembly language instead of
    machine language
  • Uses symbolic operation codes instead of numeric
  • Uses symbolic memory addresses instead of numeric
  • Pseudo operations that provide user oriented
    services such as data generation.
  • Assembly language - a programming language that
    provides symbolic representation of machine
    instructions and memory locations.
  • Assembler - a program that inputs an assembly
    language program produces the machine language
    for the instructions.
  • Source program - a program written by a user. It
    is in ASCII text.
  • Object program - a machine language program. It
    is binary numbers.
  • Assembly language instructions consist of 4
    fields, not all fields are used by every
    instruction.label opcode_mnemonic address(es)
    --comment

Load (0000) Add (0011) Store (0001)
7
  • Figure 6.4 The translation, loading and execution
    process.
  • Figure 6.5 Typical Assembly language instruction
    set.
  • We can use symbolic addresses now so the JUMP 500
    instruction no longer needs to be changed.
  • Solution Attach a symbolic label.
  • Example
  • Begin Load X
  • Jump Begin
  • This leads to program clarity.

Begin is equivalent to the address of the memory
cell that holds instruction load X
8
  • Symbolic labels have two advantages
  • Program clarity and meaningful (Ex. Begin, Loop,
    Count, Error, etc.)
  • Maintainability
  • (refers to an instruction via its label and not
    its address)
  • Example
  • JUMP LOOP
  • LOOP LOAD X

You can add a new instruction here now without
problems That we had before.
9
Data generation
  • Final advantage of assembly language
  • We saw an algorithm used to represent unsigned
    numbers, singed integers, floating point values
    and characters.
  • These conversions need not be done by the
    programmer in assembly.
  • To make this request we use pseudo-ops ( special
    type of assembly language op code) (mentioned
    before)
  • Pseudo-ops
  • Always precedes by .
  • Does not generate machine language instructions
    like other op codes.
  • Invokes the service of the assembler to generate
    data in the proper binary form.
  • Examples
  • FIVE .DATA 5
  • In this case, DATA builds a signed integer
  • Generates binary representation of 5
  • Puts it in memory
  • Makes label FIVE equivalent to address of that
    cell in memory.
  • Draw figure.
  • NEGSEVEN .DATA -7 (what would this look
    like?)
  • Count .DATA 0
  • One .data 1
  • LOAD FIVE would be equivalent to LOAD 53 in our
    example that we drew.

10
  • Example
  • ADD NEGSEVEN
  • Adds -7 to current contents of register R.
  • When generating data values we should be careful
    not to place them in memory locations where they
    could be misinterpreted as instructions.
  • The way a computer can tell if a binary value is
    a number or character is in its context.
  • The same thing goes for instructions and data.

11
  • We could write the following Incorrect sequence
    of instructions.
  • LOAD X
  • .DATA 1
  • After loading X, the processor will fetch decode
    and execute the instruction 1.
  • 1 would look like 0000 000000000001
  • The leftmost 4 bits would be the opcode and since
    it is 0 in our machine this is considered to be a
    LOAD. See figure 6.5
  • So in effect the data value 1 has accidentally
    been turned into the instruction LOAD 1

12
  • Structure of a Typical Assembly Language Program
  • .BEGIN --This must be the first line of the
    program
  • -- Here are assembly language
    instructions
  • -- of the type shown in Figure 6.5
  • HALT
  • -- Data generation pseudo-ops such as
  • -- .DATA are placed here after the HALT
  • .END -- This must be the last line of the
    program

13
  • Pseudocode
  • Set the value of I to 1
  • Add 1 to value of I
  • Assembly language
  • LOAD ONE --put 1 into R
  • STORE I --store constant 1 into I
  • INCREMENT I --add 1 to memory location I
  • I .DATA 0 --Index value initially 0
  • ONE .DATA 1 --Constant 1

14
  • Pseudocode
  • Set value of A to BC-7
  • Assembly language instructions
  • LOAD B --Put value B into register R
  • ADD C --R holds (BC)
  • SUBTRACT SEVEN --R holds (BC-7)
  • STORE A
  • A .DATA 0
  • B .DATA 0
  • C .DATA 0
  • SEVEN .DATA 7

15
Example of testing and comparing
  • Pseudocode
  • Input value of X
  • Input value of Y
  • If XgtY then
  • Output value of X
  • Else
  • Output value of Y
  • Assembly language
  • IN X
  • IN Y
  • LOAD Y
  • COMPARE X -- compare X to Y and set CC
  • JUMPLT PRINTY
  • OUT X
  • JUMP DONE
  • PRINTY OUT Y
  • DONE -- program continued
  • -- the following data go after the HALT

16
Example of Looping
  • Pseudocode
  • Set I to 0
  • While value of I lt 10000 do
  • Add 1 to value of I
  • End of loop
  • Stop
  • Assembly language
  • LOAD ZERO
  • STORE I
  • LOOP LOAD MAXVALUE
  • COMPARE I
  • JUMPEQ DONE
  • INCREMENT I
  • JUMP LOOP
  • DONE HALT
  • ZERO .DATA 0

17
Another example
  • 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.
  • First write pseudocode
  • Set value of sum to 0
  • Input the first number N
  • While N is not negative, execute lines 45
  • Add value of N to Sum
  • Input next data value N
  • End of loop
  • Print out Sum
  • Stop

18
Figure 6.8
  • .BEGIN
  • CLEAR SUM
  • IN N
  • AGAIN LOAD ZERO
  • COMPARE N
  • JUMPLT NEG
  • LOAD SUM
  • ADD N
  • STORE SUM
  • IN N
  • JUMP AGAIN
  • NEG OUT SUM
  • HALT
  • SUM .DATA 0
  • ZERO .DATA 0
  • N .DATA 0
  • .END

19
Translation and Loading
  • What must be done to programs to be executed on a
    processor?
  • Transparency Figure 6.4
  • Assembler Translate symbolic assembly code to
    machine language.
  • The four tasks of the Assembler
  • Convert symbolic opcodes to binary (Opcode table)
    Figure 6.9.
  • Convert symbolic addresses to binary (symbol
    table)
  • Perform assembler services requested by pseudo
    ops.
  • Put the translated into a file for future use.

20
  • What if the op code is not found? i.e. the
    programmer wrote an illegal opcode.
  • Think about the algorithm to use to find the op
    code.
  • Maybe sequential search (avg n/2 comparisons)
  • or binary search. (lg n)
  • This is why algorithm analysis is so important.
  • Do similar thing for addresses
  • eg, X or LOOP to binary address
  • More difficult than converting op code.
  • Assembler must determine correct numeric value of
    all symbols used in label field
  • No built in system like an address conversion
    table.

21
  • Symbol Recall this is what appears in the label
    field or data pseudo-op so the symbol has value
    of address of instruction to which it is
    attached.
  • Binding process of associating a symbolic name
    with a physical memory address. (First pass)
  • Location counter variable used to determine
    address of instruction.

22
First pass of the Assembler
  • The Assembler makes two passes over your assembly
    language code.
  • First pass
  • Goals
  • Bind symbolic names to address values
  • Keeps track of memory address where instruction
    will be stored when translated (knows begin and
    end and number of cells.
  • Binding is a process of associating a symbolic
    name with a physical memory address.
  • Location counter is a variable used to determine
    address of instruction.
  • Enter bindings in symbol table.
  • Determines if there is a symbol in label field of
    instruction. If yes, then enter symbol and
    address into special table called symbol table.
  • Figure 6.11 for an algorithm for Pass One.

23
Second Pass of the Assembler
  • The goal of the second pass is to produce the
    object file.
  • It translates source program into machine
    language.
  • There are two table lookups.
  • Opcode table ? Binary value
  • Mnemonic
  • Symbol Table ? Binary value
  • Symbolic Address
  • GOALS
  • Handle data generation pseudo-ops
  • Produce the object file needed by loader
  • Figure 6.12 Algorithm for Pass 2.
  • Object file contains the translated machine
    language object program.

24
  • Eg. if our instruction format is 4-bit op code
    followed by 12-bit address then SUBTRACT X
  • The assembler will
  • Look up SUBTRACT in opcode table and place 4-bit
    value in op code field.(0101)
  • Loop up symbol X in symbol table of Figure
    6.10(B)and place the binary address 0000 0000
    1001 in address field.
  • So the instruction will be 0101 0000 0000 1001
  • Figure 6.13, Example of an object program

25
The Loader
  • It reads the object file and stores it in memory
    for execution
  • It does this by reading the address and
    instruction for each of your assembly language
    instructions
  • When done putting in memory, the loader places
    address of the first instruction into the program
    counter(PC) to initiate execution.
  • The hardware then begins the Fetch/Decode/Execute
    cycle.

26
OS
  • What is an operating system?
  • It is a set of programs that control and make
    available to users the hardware resources.
    Maintenance and support software is also
    included.
  • Responsibilities of OS
  • Loading and running programs
  • Multitasking
  • Managing memory providing memory to programs
    and reclaiming memory
  • Maintaining the file system
  • System security
  • Authorize users, passwords etc
  • Efficient resource allocation
  • High priority to more important programs
  • Managing the processor by keeping it busy.
  • Switching between users
  • Deadlock detection
  • Deadlock prevention
  • Error detection

27
Responsibilities of OS contd..
  • Deadlock detection a set of processes (running
    programs) are deadlocked if each is waiting for a
    resource held by another.
  • Safe use of resources Prevent users from
    attempting operations that could cause system to
    enter a state where it cannot do any work.
  • Eg.
  • Prog A requests tape drive then laser printer and
    then wants to print file
  • Prog B requests laser printer and then tape drive
    and then wants to print its file.
  • In this case the first request of each program is
    satisfied but then we have deadlock. WHY??
  • OS should prevent deadlock from occurring.
  • One way to do it is for a program to get all its
    resources in advance and if it cannot get ALL of
    its resources then it must give up all what it
    owns and issue a completely new request all over
    again.
  • An analogy would be you calling your friend and
    your friend calling you on the phone at exactly
    the same time!

28
User interfaces
  • The OS can use either one or both of these
    interfaces to communicate with the user.
  • GUI Graphical User Interface
  • Command line interface
  • Figure 6.15 for a flowchart of the way the OS
    deals with the user interface.

29
Review
  • System Software
  • Types of system software
  • The virtual machine
  • Assemblers and Assembly language
  • Examples of Assembly language code
  • What is the Operating System (OS)?
  • Functions of the OS

30
  • THE END OF CHAPTER 6
Write a Comment
User Comments (0)
About PowerShow.com