Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6: An Introduction to System Software and Virtual Machines Invitation to Computer Science, C++ Version, Third Edition.

Similar presentations


Presentation on theme: "Chapter 6: An Introduction to System Software and Virtual Machines Invitation to Computer Science, C++ Version, Third Edition."— Presentation transcript:

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

2 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 7 Figure 6.1 The Role of System Software

8 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 9 Figure 6.2 Types of System Software

10 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 13 Figure 6.3 The Continuum of Programming Languages Programming Languages System software provides compilers or interpreters for high level languages. Also provides assemblers as a low-level language service

14 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 15 Assemblers and Assembly Language: Machine Language vs Assembly Language Machine language  Uses binary  Allows only numeric memory addresses  Difficult to change  Difficult to create data

16 Invitation to Computer Science, C++ Version, Third Edition 16 Assemblers and Assembly Language: Machine 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 18 Figure 6.4 The Translation/Loading/Execution Process

19 Invitation to Computer Science, C++ Version, Third Edition 19 Examples of Assembly Language Code Arithmetic expression: A = B + C – 7 ( Assume that B and C have already been assigned values ) Load BAdd CSub 7Store A

20 Invitation to Computer Science, C++ Version, Third Edition 20 LabelOpCodeAddressComment.BEGIN LOADB--Put CON(B) into register R ADDC--R now holds the sum (B+C) SUBTRACTSEVEN--R now holds value (B + C – 7) STOREA--Store CON(R) into A HALT A:.DATA0-- intialize data item A to 0 B:.DATA0-- initialize data item B to 0 C:.DATA0-- initialize data item C to 0 SEVEN:.DATA7-- initialize data item SEVEN to 7.END

21 Invitation to Computer Science, C++ Version, Third Edition 21 Assembly Language Example #2 Get the value of x Get the value of y If x > y then Print the value of x Else Print the value of y.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 > Y OUT Y -- Didn't jump so print Y JUMP DONE -- and go to end PRINTX: OUT X -- X > Y so print X DONE: HALT -– Stop X:.DATA 0 Y:.DATA 0.END -- end of the program

22 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 24 Assembly Language Example 3 cont’d. 1. Set the value of Sum to 0 2. Get the value of N 3. If ( n < 0) GoTo Step 7 4. Set the value of Sum to Sum + N 5. Get the value of N 6. GoTo Step 3 7. Print the value of Sum 8. Stop

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

26 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 28.BEGIN -- start of the program 0 IN X -- Input X 1 IN Y -- Input Y 2 LOAD Y -- Load Y into register R 3 COMPARE X -- Compare X to Y 4 JUMPGT PRINTX -- Jump if X > Y 5 OUT Y -- Didn't jump so print Y 6 JUMP DONE -- and go to end 7 PRINTX: OUTX -- X > Y so print X 8 DONE: HALT -– Stop 9 X:.DATA 0 10 Y:.DATA 0.END -- end of the program SymbolAddress PRINTX..0111 (7) DONE..1000 (8) X..1001 (9) Y..1010 (10) Pass 1 of Assembler Builds a Symbol Table Symbol Table

29 Invitation to Computer Science, C++ Version, Third Edition 29 Pass 2 of Assembler Builds an Object File.BEGIN IN X IN Y LOAD Y COMPARE X JUMPGT PRINTX OUT Y JUMP DONE PRINTX: OUTX DONE: HALT X:.DATA 0 Y:.DATA 0.END 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 SymbolAddress PRINTX0000 0000 0111 (7) DONE0000 0000 1000 (8) X0000 0000 1001 (9) Y0000 0000 1010 (10) IN X  1101 0000 0000 1001 IN Y  1101 0000 0000 1010 … JUMP DONE  1000 0000 0000 1000

30 Invitation to Computer Science, C++ Version, Third Edition 30 Assembler: Performance Considerations Pass 2 – Tasks for each line of source code 1. Convert symbolic opcode to numeric opcode - Table lookup 2. Convert symbolic address to numeric opcode - Table lookup 3. 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 Invitation to Computer Science, C++ Version, Third Edition 31 Binary Search Tree for Opcodes To make pass 1 of the assembler more efficient, alphabetize the symbolic opcodes, so they can be located using binary search. See binary search tree below.

32 Invitation to Computer Science, C++ Version, Third Edition 32

33 Pass 2 of assembler

34 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 37 Figure 6.15 User Interface Responsibility of the Operating System

38 Invitation to Computer Science, C++ Version, Third Edition 38 [durand@neptune ~]$ grep 'cout' array2.cpp | sort cout << arr[i] << '\n'; cout << "\n"; cout << "\nArray contents:\n"; using std::cout; [durand@neptune ~]$ Text Oriented Interface (CLI)

39 Invitation to Computer Science, C++ Version, Third Edition 39 Graphical User Interface (GUI)

40 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 42 UNIX – User IDs & Passwords Cont’d. 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 Invitation to Computer Science, C++ Version, Third Edition 43 UNIX – User IDs & Passwords Cont’d. 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 user root:fi3sED95ibqR6:0:1:System Operator:/:/bin/ksh daemon:*:1:1::/tmp: uucp:OORoMN9FyZfNE:4:4::/var/spool/uucppublic:/usr/lib/uucp/uucico rachel:eH5/.mj7NB3dx:181:100:Rachel Cohen:/u/rachel:/bin/ksh arlin:f8fk3j1OIf34.:182:100:Arlin Steinberg:/u/arlin:/bin/csh rachelThe usernamee H5/.mj7NB3dxThe user's "encrypted password“ 181The user's user identification number (UID 100The user's group identification number (GID Rachel CohenThe user's full name /u/rachelThe user's home directory /bin/kshThe user's shell

44 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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 13:19 instructions -rw-r--r-- 1 sian user 3159 Feb 9 13:14 invoice -rw-r--r-- 1 sian user 6318 Feb 9 13:14 letter -rw------- 1 sian user 15897 Feb 9 13:20 more-stuff -rw-r----- 1 sian biochem 4320 Feb 9 13:20 notes -rwxr-xr-x 1 sian user 122880 Feb 9 13:26 stats* % Here are two examples of file permissions -rw------- drwxr-xr-x

46 Invitation to Computer Science, C++ Version, Third Edition 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 wPermission to write xPermission to execute Similarly, there are three classes of permissions: ownerThe file's owner groupUsers who are in the file's group otherEverybody else on the system (except the superuser)

47 Invitation to Computer Science, C++ Version, Third Edition 47 UNIX – File Permission System Consider this listing -rw-r--r-- 1 sian user 505 Feb 9 13:19 instructions Field ContentsMeaning -The file's type rw-r--r--The file's permissions 1The number of "hard" links to the file sianThe name of the file's owner userThe name of the file's group 505The file's size, in bytes Feb 9 13:19The file's modification time instructionsThe file's name rw-user permissions r--group permissions r--other permissions

48 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 49 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. Efficient Allocation Of Resources

50 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 51 Process Management Queues A BCD E Running Ready Waiting B CD EA → Process A issues an i/o request and is moved to the end of the Waiting queue. Process B is moved to Running status Processes C & D move up in the Ready queue

52 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 53 Traffic Deadlock

54 Invitation to Computer Science, C++ Version, Third Edition 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 AProgram B Get data file DGet the laser printer Get the laser printerGet data file D Print the filePrint the file If the OS grants each program’s initial request we have a deadlock.

55 Invitation to Computer Science, C++ Version, Third Edition 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 AProgram B Message   Acknowledge Message   Acknowledge Message  Say B sends and Ack, but it gets lost. Deadlock. A and B are both stopped waiting on the other.

56 Invitation to Computer Science, C++ Version, Third Edition 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 AProgram B 1.Get data file D2.Get the laser printer 3.Get the laser printer4.Get data file D 5.Print the file6.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 Invitation to Computer Science, C++ Version, Third Edition 57 Solutions to Communication Deadlock Program AProgram B Message01   Acknowledge01 Message02   Acknowledge02 Message03    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 Invitation to Computer Science, C++ Version, Third Edition 58 Historical Overview of Operating Systems Development First generation of system software (roughly 1945–1955)  No operating systems  Assemblers and loaders were almost the only system software provided

59 Invitation to Computer Science, C++ Version, Third Edition 59 Historical Overview of Operating Systems Development (continued) Second generation of system software (1955– 1965)  Batch operating systems  Ran collections of input programs one after the other  Included a command language

60 Invitation to Computer Science, C++ Version, Third Edition 60 Figure 6.18 Operation of a Batch Computer System

61 Invitation to Computer Science, C++ Version, Third Edition 61 Third-generation operating systems (1965– 1985)  Multiprogrammed operating systems  Permitted multiple user programs to run at once Historical Overview of Operating Systems Development (continued)

62 Invitation to Computer Science, C++ Version, Third Edition 62 Fourth-generation operating systems (1985– present)  Network operating systems  Virtual environment treats resources physically residing on the computer in the same way as resources available through the computer’s network Historical Overview of Operating Systems Development (continued)

63 Invitation to Computer Science, C++ Version, Third Edition 63 Figure 6.22 The Virtual Environment Created by a Network Operating System

64 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 65 Figure 6.23 Structure of a Distributed System

66 Invitation to Computer Science, C++ Version, Third Edition 66 Figure 6.24 Some of the Major Advances in Operating Systems Development

67 Invitation to Computer Science, C++ Version, Third Edition 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 Invitation to Computer Science, C++ Version, Third Edition 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


Download ppt "Chapter 6: An Introduction to System Software and Virtual Machines Invitation to Computer Science, C++ Version, Third Edition."

Similar presentations


Ads by Google