Operating Systems OPERATING SYSTEM HANDOUT SPECIFIC OBJECTIVES: At the end of the topic session the students are expected to: Cognitive: 1. Identify the differences between system software and application software 2. Enumerate the benefits of system software 3. Discuss the different types of system software such as language translators, interpreters, linkers, and loaders 4. Explain the concept of address binding and the issues involved Affective: 1. 2. Listen to others with respect Participate in class discussions actively MATERIALS/EQUIPMENT: 1. 2. Take home problem set/activities Projector TOPIC PREPARATION: o Consult the reference book for further reading. TOPIC PRESENTATION: The topic will revolve around introduction to system software and system programming. Discussions will include introduction to system programming, types of system programs, and address binding. This will be the suggested flow of discussion for Introduction to System Software and System Programming. 1. Introduce system software and system programming. 2. Explain the relationship and differences between system software and application software. 3. Discuss the types of system programs and its uses. 4. Explain the concepts of address binding and the techniques involved in the process. The questions below will help you thoroughly discuss the lesson. Guide Questions: a. Give examples of other basic operations of a computer system. b. What are the advantages of using high-level languages? OS Page 1 of 12 Operating Systems c. Introduction Differentiate the three address binding techniques. Introduction Software is defined as a program or set of instructions that tells the computer what to do. Programming languages such as C++ and Java are used to write the instructions. There are two classes of software: system software and application software. System Software These programs are used to manipulate the basic operations of a computer system. Examples of these basic operations are: System software tells the computer to accept the input from the keyboard and output the character to the monitor. Page 2 of 11 System software locates free disk space in a hard disk when a file needs to be saved. It writes the file to the hard disk and modifies the disk directory system to record the existence of the file. System software sends the document to the printer when it needs to be printed. It also tells the printer how it should be printed. System software locates a program in the hard disk, loads it in the main memory, and executes it. Note that the user does not need to know the exact details of how these tasks are performed. The system software takes care of these exact details. Some of the benefits of system software are: They hide the “ugly” details of computer operations from the user. It creates a virtual machine interface where the user does not need to know how the computer works on the hardware level. Computer programmers can write programs without knowing the details on how the computer hardware works. It makes programming easier since programmers do not need to know about how to control the hardware. They can write programs using C++ and Java and use system software (compiler) to convert it to a language that is understandable by the computer. System software such as an operating system controls the execution of programs. Several programs can be executed at the same time, thus increasing CPU productivity and efficiency. Examples of system software: operating systems, communication control programs, interpreters, compilers, debuggers, text editors, linkers, loaders. OS Page 2 of 12 Operating Systems Since system software controls the operation of computer hardware, they are obviously machine dependent. System software programmers should have a strong knowledge of the architecture of the computer hardware they are using. System software supports all application programs. For example, a user using an application program such as Microsoft Word clicks on the save icon to tell Word to save a document. In this process, Word does not communicate with the printer, but rather requests the operating system to print the document. A block diagram of this process is illustrated in the figure below. Introduction Page 3 of 11 Page 4 of 11 How System Software Supports Application Software Application Software These programs are used to accomplish specialized tasks for computer users. These tasks are related to professional and personal needs of the user such as creating documents, sending e-mail, editing photographs, playing games, browsing the Web, drawing, creating database, etc. Software that falls into the category of application programs are: Document production software – These are programs that are used to compose, edit, print, and electronically publish OS Page 3 of 12 Operating Systems documents. Examples of this are word processing software (Microsoft’s Word and OpenOffice.org’s Writer), desktop publishing software (Microsoft’s Publisher and Adobe’s PageMaker), and Web authoring software (Microsoft’s FrontPage and Macromedia’s Dreamweaver). Software that falls into the category of application programs are: Document production software – These are programs that are used to compose, edit, print, and electronically publish documents. Examples of this are word processing software (Microsoft’s Word and OpenOffice.org’s Writer), desktop publishing software (Microsoft’s Publisher and Adobe’s PageMaker), and Web authoring software (Microsoft’s FrontPage and Macromedia’s Dreamweaver). Spreadsheet software – These are programs that are used to create and manipulate spreadsheets electronically for analysis, planning, and modeling. Examples of this are Microsoft’s Excel and OpenOffice.org’s Calc. Presentation software – These are programs that are used to create and display information in the form of slide shows. Examples of this are Microsoft’s PowerPoint and OpenOffice.org’s Impress. Database management software – These are programs that are used to store, modify, and retrieve information from a database in an organized and structured manner. Examples of this are Microsoft’s Access and OpenOffice.org’s Base. Business software – These are programs that can provide users with tools for business management. Examples of this are finance software (Microsoft’s Money and Reilly’s Moneydance), accounting software (Peachtree’s Accounting), tax preparation (Quicken’s Turbo Tax), etc. Multimedia software – These are programs that can manipulate picture, sound, and video. Examples of this are image editing software (Adobe’s Photoshop and Corel’s Photo-Paint), audio editing software (Adobe’s Audition and Sony’s Sound Forge), and video editing software (Adobe’s Premiere and Autodesk’s Maya). Entertainment software – Examples of this are music players (Nullsoft’s Winamp and Media Science’s Sonique), video players (Microsoft’s Media Player and CyberLink’s PowerDVD), games (Blizzard’s WarCraft and Valve’s Counter-Strike), etc. [Introduction, Pages 1 to 4 of 11] OS Page 4 of 12 Operating Systems Introduction to System Programming Page 5 of 11 Introduction to System Programming System programming is simply the act of developing system software. As mentioned before, system programmers should have a strong knowledge of the architecture of the computer hardware they are using. System software can be written in machine language. Machine language is the natural or primitive language that the computer actually understands. It is a low-level language which consists of 0’s and 1’s and the only language a machine understands. Thus, it is very difficult to program. Programs written in machine language are very fast and efficient, which are very important characteristics for system software. However, programming in this language is very tedious and highly prone to errors. For these reasons, machine language programming is no longer done. Page 6 of 11 System software can also be written in assembly language. Assembly language uses abbreviations or mnemonics in place of binary patterns. Mnemonics are easier to remember, thus make programming easier. Before a computer can execute an assembly language program, it should be first converted to machine language program. A system software called assembler is a special translator program that translates assembly language mnemonics into machine language instructions. Assembly language programming is very popular in system software development because of its acceptable level of efficiency. Lastly, system software can be written in high-level programming language. High-level programming languages are easy to use because it uses English-like commands. Examples of this software are C++, Java, and Visual Basic. Before a computer can execute high-level programming language instructions, it should be first converted to machine language program. A system software called compiler is a special translator program that converts high-level language instructions into machine language. Advantages of high-level languages over assembly language: High-level programming languages are easier to learn and use. Most high-level programming languages have pre-defined functions and subroutines, thus make programming easier. For example, C++ has built-in mathematical functions. High-level programming languages in general, are not machine-dependent. For example, the instruction set of Java can be used for both Intel-based and Motorolabased computers, with little or without modifications. OS Page 5 of 12 Operating Systems Advantages of assembly language over high-level languages: The assembly language program executable code is compact. A compact or short code would mean that the program can execute faster. Most compilers of high-level programming languages are not optimized to create a compact code. Assembly language is not constrained with certain programming conventions nor rigid coding restrictions. Assembly language has instructions that allow programmers more direct control over memory access. Some system software programmers use assembly languagebased subroutines to supplement the high-level programming language capabilities. [Introduction to System Programming, Pages 5 to 6 of 11] Types of System Programs Types of System Programs Language Translators Page 7 of 11 These system programs convert a high-level language program or assembly language program into machine language. The two types of language translators are: 1. Assemblers – language translator that convert a program written in assembly language into an executable file containing machine language instructions 2. Compilers – language translator that convert a program written in high-level language into an executable file containing machine language instructions Page 8 of 11 Some compilers first produce files that contain instructions in an intermediate language, which can then be recompiled to machine language instructions. Interpreters These system programs convert a high-level language program into machine language. Unlike compilers, interpreters read one instruction from the source code, convert it to machine language, and then execute it before proceeding to the next instruction. It also does not generate an executable file. Each instruction must be translated each time they are read. As a result, interpreted programs run much slower than compilers. Examples of interpreted programming languages are BASIC, Perl, and JavaScript embedded in HTML pages. OS Page 6 of 12 Operating Systems Types of System Programs Page 9 of 11 Linkers and Loaders As mentioned earlier, high-level programming languages have pre-defined functions and subroutines. A collection of these functions and subroutines can be found in the library. Programmers can use these libraries to enhance the functionality of their programs. This means that a program is composed of the main program and the subprograms or routines. This program may be a part of a much bigger system, wherein modular programming is practically implemented. In modular programming, a large program is divided into several modules which is created, compiled, and tested separately. After the process, these modules and the routines of the library must be combined. Some compiler does not generate the final executable file immediately. Each program is first converted to an object file or object module (which contains machine language instructions) and then combined with other programs using a linker. The linker (link editor or linkage editor) is a system software that combines or links the modules together with the libraries which then form a single executable program called the load module. Below is a diagram of this process. The Linking Process OS Page 7 of 12 Operating Systems Another system software called loader is the one responsible for bringing the load module to the main memory for execution. Its main function is to perform address binding. Address Binding [Types of System Programs, Pages 7 to 9 of 11] Page 10 of 11 Address Binding Symbolic variables are used to represent data in a program. Any name can be used but it is recommended to use a variable name that represents the data it will store. Examples of variable names are gross_sales, interest, age, first_name, etc. Variables are assigned specific locations in the main memory when the program is compiled and loaded into the main memory for execution. Each main memory location has a unique numeric address. For example, the variable cost may be assigned to a memory location whose address is 1045. Any reference or changes to the value of gross_sales in the program will refer or reflect in the contents of memory location 1045. The figure below illustrates this process. memory addresses 1043 1044 1045 1000 1046 gross_sales = 1000; . . . . . . . . . . gross_sales = 2000; . . 1047 1048 1049 Main Memory 1043 1044 1045 2000 1046 1047 1048 1049 Program Since the program initialized the value of gross_sales to 1000, the contents of memory location 1045 will be equal to1000 Main Memory At this point in the program, the value of gross_sales was changed to 2000. Therefore, the contents of memory location 1045 will be changed to 2000 Assignment of Variables to Memory Locations The memory locations to be assigned for symbolic variables depend on the available free memory space when the program is loaded. The process of assigning or mapping symbolic references to actual memory locations is referred to as address binding. The actual main memory location is OS Page 8 of 12 Operating Systems Address Binding called physical address or absolute address. Page 11 of 11 Calls for subroutines and functions can also be given symbolic variables, hence, address binding can also be done. Example: A program contains a subroutine compute_grade which is loaded in main memory 3000. Assume that the command to invoke this subroutine is call compute_grade. When the main program is loaded into the main memory, the call compute_grade command will change to jump 3000 command. The call compute_grade command becomes a reference to memory location 3000 which is the start of compute_grade subroutine. The loader may use three techniques in placing the load module in main memory. These are: absolute loading, relocatable loading, and dynamic run-time loading. Absolute Loading In absolute loading, the load module has actual memory addresses assigned instead of symbolic variables. The actual addresses may have been determined before or during compile time. The load module is placed into main memory without performing address binding. This method may not be a problem in a computer system with only one program running at any given time. Problems might occur in a multiprogrammed system where two or more programs may be running at the same time and sharing the same main memory space. Delays may arise if for example, a program needs to be loaded, but the assigned memory space is occupied by another program. In this case, the programmer should assign a new memory space then recompile it to generate a new load module. Relocatable Loading In relocatable loading, address binding is performed right before the load module is loaded and the address assignment is based on the available main memory location at that time. The address that will be generated is referred to as relative address. The relative address is based on a reference point or base address. For example, a relative address is 200 memory locations from the start of the program. If the program is loaded at memory location 500, then the absolute address is 500 + 200 = 700. If the start of the program is relocated to memory location 800, a new absolute address will be computed by the loader. The new absolute address is 800 + 200 = 1000. In general, absolute address = r + x wherein r is the memory location from the reference point and x is the reference point. The relative or relocatable addresses must be generated during compile or assembly time of the load module. All the OS Page 9 of 12 Operating Systems relative addresses and information on the reference point is contained in a relocation dictionary of the load module. Since the relative addresses become absolute addresses when loaded, the program cannot be moved to a different memory once it starts executing. This becomes a problem in some situation wherein programs need to be relocated to maximize the use of CPU and main memory. It can only be moved by terminating the program and reloading it so that new absolute addresses can be generated. Dynamic Run-Time Loading This technique is used in most modern operating systems. In dynamic run-time loading, the absolute address is not generated when loaded, but only when it is needed by the CPU. It places the load module in main memory but does not convert the relative addresses to absolute addresses. Relocating a program becomes possible even though it is executing. Since the absolute address is computed during run-time, the problem is execution time will definitely slow down. This can be avoided using special hardware to speed-up the conversion process which will be discussed in the succeeding lessons. [Address Binding, Pages 10 to 11 of 11] OS Page 10 of 12