770 likes | 1.06k Views
Chapter 6 An Introduction to System Software and Virtual Machines. 1. Objectives. In this chapter, you will learn about: System software Assemblers and assembly language Operating systems . Objectives. After studying this chapter, students will be able to:
E N D
Chapter 6 • An Introduction to System Software and Virtual Machines 1
Objectives In this chapter, you will learn about: • System software • Assemblers and assembly language • Operating systems Invitation to Computer Science, 6th Edition
Objectives After studying this chapter, students will be able to: • Describe the main categories of system tasks • Compare the virtual machine created for the user by system software with the naked machine • Explain the benefits of writing system software in assembly language, rather than machine language • Read and write short assembly language programs • Describe how an assembler translates assembly language programs into machine instructions Invitation to Computer Science, 6th Edition
Objectives (continued) After studying this chapter, students will be able to: • List five key tasks of an operating system, and explain what each is and why it is critical to modern systems • Describe the different generations of operating systems, what the features of each generation were, and how each generation solved a drawback of the previous generation Invitation to Computer Science, 6th Edition
Introduction • A bare or naked machine has no tools or programs to help the user • Write instructions in binary • Write data in binary • Load instructions into memory one cell at a time • Initiate program run • Too difficult for humans to do • We must build an interface to hide the details and make the computer easier to build Invitation to Computer Science, 6th Edition
Interface • 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 and people oriented ( like “dashboard” on a car ) Invitation to Computer Science, 6th Edition
Interface • 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 • Allow easy user access to the available resources • Prevent accidental or intentional damage to hardware, programs, and data Invitation to Computer Science, 6th Edition
Software • Application software • programs primarily for users ( word processors, spreadsheets, databases, presentation graphics, etc.) • System software • primarily used to run the computer (operating system, device drivers, assemblers, compilers ) Invitation to Computer Science, 6th Edition
System Software • System software is the intermediary between the users and hardware • Hides complex internal structure of the Von Neumann architecture • Virtual Machine/Virtual Environment • The set of services and resources created by the software and seen by the user Invitation to Computer Science, 6th Edition
System Software • System software is a collection of programs to • manage resources of the computer • serve as intermediary between user and hardware • System software creates a virtual machine(or virtual environment) that user sees Invitation to Computer Science, 6th Edition
System Software (continued) • Operating system: central system software • Communicates with users • Starts up other system software and applications as needed • Graphical user interface (GUI), often pronounced “gooey” • visual interface to operating system (or other system software/applications) • I/O systems: communicate with various devices Invitation to Computer Science, 6th Edition
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 Invitation to Computer Science, 6th Edition
Types of System Software • 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 Invitation to Computer Science, 6th Edition
Types of System Software • 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 Invitation to Computer Science, 6th Edition
Types of System Software • 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 Invitation to Computer Science, 6th Edition
System Software (continued) • Language services: support high level languages • Memory managers: allocate memory to programs • Information managers: organize mass storage • Scheduler: manage programs waiting to run • Utilities: tools, including program libraries Invitation to Computer Science, 6th Edition
System Software (continued) Naked machine: • Write program in binary • Load instructions one-by-one into memory • Insert start into memory address 0 and push “go” button • Read results from memory one-by-one, in binary Virtual machine: • Write program using text editor in high-level language • Save program to folder • Use translator to convert to binary • Use scheduler to load and run • Use I/O system to print results Invitation to Computer Science, 6th Edition
What’s the Problem with Machine Language? • Written from machine’s view • Complicated, difficult to understand • Program is written, loaded, debugged in binary - no English-like words • Allows only numeric memory addresses • Difficult to read and change • Difficult to create data Invitation to Computer Science, 6th Edition
Assembly Language • Assembly language • 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 Invitation to Computer Science, 6th Edition
Assembly Language • Second-generation language • Uses mnemonics to represent machine language opcodes • Uses symbolic memory addresses • Provides data generation operations • Format: label: opcode address --comment Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language • Assembly language • Instructions map one-to-one to machine language • Symbolic op codes (not binary) • Symbolic addresses for instructions and data • Pseudo-ops for data generation and more (data in human-friendly terms) • Assembly = a low-level programming language • Java, C, C++, VB, Python = high-level programming languages Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language • Source program • An assembly language program • Object program • A machine language program • Assembler • Translates source program into an object program Assembly language process: • Source program, in assembly language • Translated by the assembler to • Object program, in machine language • Loader places in memory • Hardware runs Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language (continued) Example Assembly language: NEXTSTEP: LOAD X -- Put X into reg. R label: opcode address field -- comment • Label is optional name for this instruction’s location • Op code mnemonic and address field translate to machine language • Comments are ignored by assembler, just for human use Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language (continued) Advantages over machine code: • Clarity, readability, and maintainability • Can be placed at different locations in memory • Pseudo-op: commands in the program directed to the assembler, not converted to machine instructions • .BEGIN and .END to mark where instructions are • .DATA to mark memory location as holding data: COUNTER: .DATA 0 X: .DATA 12 Invitation to Computer Science, 6th Edition
Examples of Assembly Language Instructions • Assembly language translation LOAD ONE --Put a 1 into register R. STORE X --Store the constant 1 into X : INCREMENT X --Add 1 to Value in memory location X : I: .DATA 0 --The index value. Initially it is 0 ONE: .DATA 1 --The constant 1. Invitation to Computer Science, 6th Edition
Examples of Assembly Language Instructions • Assigns name to address where data is stored • Converts data value to proper binary representation • Example: FIVE: .DATA +5 NEGSEVEN: .DATA -7 LOAD FIVE ADD NEGSEVEN • Arithmetic expression A = B + C – 7 (Assume that B and C have already been assigned values) Invitation to Computer Science, 6th Edition
Examples of Assembly Language Instructions • Assembly language translation .BEGIN LOAD B --Put the value B into register R. ADD C --R now holds the sum (B + C). SUBTRACT SEVEN --R now holds the expression (B + C - 7). STORE A --Store the result into A. : -- Data should be placed after the HALT A: .DATA 0 B: .DATA 0 C: .DATA 0 SEVEN: .DATA 7 --The constant 7 .END Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language Simple examples: x = y + 3 input a and b while a > b do print a a = a – 2 LOAD Y ADD THREE STORE X … -- Data comes after .END X: .DATA 0 -- X is initially 0 Y: .DATA 5 – Y is initially 5 THREE: .DATA 3 –The constant 3 IN A IN B LOOP1: LOAD A A: .DATA 0 COMPARE B B: .DATA 0 JUMPLT LOOP1END TWO: .DATA 2 JUMPEQ LOOP1END OUT A LOAD A SUBTRACT TWO STORE A JUMP LOOP1 LOOP1END: … Invitation to Computer Science, 6th Edition
Example – Summing Numbers • 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 Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language Translation and loading: • Assembler translates to machine language • Convert symbolic op codes to binary equivalents • Convert symbolic labels to memory addresses • Perform pseudo-op actions • Write object file containing machine instructions • Loader gets program ready to run • Places instructions in memory • Triggers the hardware to run the program Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language Converting symbolic op codes to binary ones • Assembler maintains a table • Assembler looks up symbolic op codes in the table and substitutes the binary analogue • Use binary search to optimize table lookups
Assemblers and Assembly Language Converting symbolic labels to memory addresses • Assembler needs two passes • looks over assembly code two times • First pass: • Keep a count of how many instructions from the start • Collect symbolic labels and add to symbol tablealong with location counter Invitation to Computer Science, 6th Edition
Assemblers and Assembly Language (continued) • Second pass: • Look up and replace op codes • Substitute label references with location from symbol table • Set up .DATA pseudo-ops with location and binary value • Write instructions to object file Invitation to Computer Science, 6th Edition
Translation and Loading • The object program becomes the input to another piece of software – the loader • The loader reads instructions from the object file and stores them in memory for execution • To do this it reads and address and stores the machine instruction into the specified memory address. • After the instructions are loaded into memory, the loader places the address of the first instruction (0 in our example) into the program counter (PC) . • The computer fetches, decodes and executes the program starting with the instruction, whose address is in the PC. Invitation to Computer Science, 6th Edition
Operating Systems • What is an operating system? • A library of programs that make a computer • Easier to user for the user • Use resources more efficiently • It can also be viewed as: • A Government – making policy and rules • An Environment – in which users write and run programs • A Resource allocator • A Security guard • A Traffic cop • A Wizard – providing “illusions” Invitation to Computer Science, 6th Edition
Purpose of an Operating System • The primary purposes of an Operating System are: • Ease of use for the user • Efficient use of the system resources • Operating system • Waits for requests and activates other system programs to service these requests • System commands • Used to translate, load, and run programs Invitation to Computer Science, 6th Edition
Operating Systems • System commands: - user instructions about what the computer should do Invitation to Computer Science, 6th Edition
Operating Systems (continued) • User interface: user communicates with operating system • Operating system as receptionist and dispatcher • User command system software scheduled and runrepeat • Text-based: • System commands typed at a prompt in a terminal • Command language must be learned • GUI-based: • System commands by visual/mouse interface Invitation to Computer Science, 6th Edition
GUIs Example of a Graphical User Interface Invitation to Computer Science, 6th Edition