1 / 67

Chapter 6 An Introduction to System Software and Virtual Machines

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

Download Presentation

Chapter 6 An Introduction to System Software and Virtual Machines

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6An Introduction to System Software and Virtual Machines 國立雲林科技大學 資訊工程研究所 張傳育(Chuan-Yu Chang ) 博士 Office: ES 709 TEL: 05-5342601 ext. 4337 E-mail: chuanyu@yuntech.edu.tw

  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.

  3. Naked Machines • Need to write the program in 0s and 1s. • Need to represented data in binary form. • Need to manually store programs intomemory before executing. • Need to instruct the program to startrunning …

  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

  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.

  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.

  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.

  8. Type of System Software

  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.

  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.

  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.

  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

  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.

  14. The Continuum of Programming Languages

  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(編譯程式).

  16. The translation/Loading/Execution Process

  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.

  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

  19. Typical Assembly Language Instruction Set

  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中。

  21. Structure of a Typical Assembly Language Program

  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

  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)

  24. More Examples (Cont.) • Arithmetic expression A=B+C-7 • LOAD B ADD C SUBTRACT SEVEN STORE A…A: .DATA 0B: .DATA 0C: .DATA 0SEVEN: .DATA 7

  25. Conditional operation Input the value of xInput 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 More Examples (Cont.)

  26. Figure 6.7 Algorithm to Compute the Sum of Numbers

  27. Figure 6.8 Assembly Language Program to Compute the Sum of Nonnegative Numbers

  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.

  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.

  30. Op Code Table Structure of the 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

  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.)

  32. Generation of the Symbol Table 假設每個指令和資料均佔1 byte,且位址由0開始。 前向參考(forward reference) DATA放在HALT之後

  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 instruction or piece of data is called location counter.

  34. Outline of Pass 1 of the Assembler

  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

  36. Fig 6.12 Outline of Pass 2 of the Assembler

  37. Fig. 6.13 Example of an Object Program

  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.

  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

  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)

  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

  42. Figure 6.15 User Interface Responsibility of the Operating System

  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…

  44. Example of a GUI

  45. System security and protection • OS has the responsibilities of a securityguard—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

  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 Operations Smith R (R=Read only) Jones RA (A=Append) Adams RAC (C=Change) Doe RACD (D=Delete)

  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

  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

  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.

  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

More Related