Operating System IT201T Lecture Notes PDF

Document Details

AmazedCrocus5543

Uploaded by AmazedCrocus5543

Princess Nora bint Abdulrahman University

Tags

operating systems system software memory management process management

Summary

These lecture notes cover the Principles of Information & Technology Systems, specifically focusing on Operating Systems. Topics discussed include memory and process management, user interfaces (CLI and GUI), along with multiprogramming techniques like partitioning and paging. The document originates from the Faculty of Computer and Information Sciences at Princess Nora Bint Abdul Rahman University.

Full Transcript

1 Faculty of Computer and Information Sciences Information Technology Department Principles of Information & Technology Systems IT 201T Lecture 4: Operating Systems Outline Define the operating system Identify the components o...

1 Faculty of Computer and Information Sciences Information Technology Department Principles of Information & Technology Systems IT 201T Lecture 4: Operating Systems Outline Define the operating system Identify the components of an operating system Memory manager Process manager Device manager File manager Computer System A computer is a system composed of 2 major components: hardware and software. Computer hardware: is the physical equipment. Software is the collection of programs that allows the hardware to do its job. Computer System Computer software is divided into 2 broad categories: The operating system and application programs Application programs: use the computer hardware to solve users’ problems. The operating system: controls the access to hardware by users. Operating System Introduction Operating System An operating system: is an interface between the hardware of a computer and the user (programs or humans) that facilitates the execution of other programs and the access to hardware and software resources. Operating System Components A modern operating system has at least four duties: memory manager, process manager, device manager and file manager. OS Components- User interface Each operating system has a : user interface: a program that accepts requests from users (processes) and interprets them for the rest of the operating system. A user interface in some operating systems, such as UNIX and Linux, is called a shell. In others, it is called a window to denote that it is menu driven and has a GUI (graphical user interface) component. User Operating System Interface - CLI Command Line Interface (CLI) or command interpreter allows direct command entry Which is an operating system shell that uses alphanumeric characters typed on a keyboard to provide instructions and data to the operating system, interactively. User Operating System Interface - GUI User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder) Linux Operating System Linux Operating System Important features of Linux OS Architecture of Linux Linux System Architecture consisted of the following layers Architecture of Linux OS Components- Memory manager Although the memory size of computers has increased tremendously in recent years, so has the size of the programs and data to be processed. Memory allocation must be managed to prevent applications from running out of memory. Operating systems can be divided into two Monoprogramming In monoprogramming, most of the memory capacity is dedicated to a single program. only a small part is needed to hold the operating system. In this configuration, the whole program is in memory for execution. When the program finishes running, the program area is occupied by another program. Monoprogramming Figure shows memory in Monoprogramming a environment Monoprogramming (Cont.) There are several problems with this technique: If the size of memory is less than the size of the program, can the program run? the program cannot be run Inefficient use of memory and CPU time Multiprogramming In multiprogramming: more than one program is in memory at the same time, and they are executed concurrently with the CPU switching rapidly between the programs Multiprogramming Figure shows memory in a multiprogramming environment Categories of multiprogramming Multiprogramming (Cont.) Multiprogramming (Cont.) Nonswapping category: This means that the program remains in memory for the duration of execution Two techniques belong to the this category: Partitioning paging Multiprogramming (Cont.) Swapping category: This means that, during execution, the program can be swapped between memory and disk one or more times. Two techniques belong to the this category: Demand paging Demand segmentation Partitioning The first technique used in multiprogramming. Memory is divided into variable length sections Each section or partition holds one program The CPU switches between programs With this technique, each program is entirely in memory and occupying contiguous Partitioning- how its work ?! 1. The CPU starts with one program, executing some instructions until it either encounters an input/output operation or the time allocated for that program has expired 2. Then, it saves the address of the memory location where the last instruction was executed and moves to the next program. 3. The same procedure is repeated with the second program 4. After all the programs have been served, the CPU moves back to the first program Partitioning- how its work ?! (Cont.) Figure shows memory with partitioning technique Partitioning issues The size of the partitions has to be determined beforehand by the memory manager what will happen if partition sizes are small or large?! The memory manager can compact the partitions to remove the holes and creates new partitions, but this creates extra overhead on the system Paging Paging improves the efficiency of partitioning Memory is divided into equally sized sections called frames Programs are also divided, into equally sized sections called pages The size of a page and frame is usually the same and equal to the size of the block used by the system to retrieve information from a storage device Paging - how its work!! A page is loaded into a frame in memory The program does not have to be contiguous in memory There is no need for the new program to wait until set of contiguous frames are free before being loaded into memory Paging - how its work!! Figure shows memory with paging technique Paging issues The whole program still needs to be in memory before being executed Ex: A program has six pages, cannot be loaded into memory if there are only four unoccupied frames Demand paging In this technique the program is divided into pages but the pages can be loaded into memory one by one, executed, and replaced by another page. In addition, a page can be loaded into any free frame Demand paging (Cont.) An example of demand paging is shown in figure below. Two pages from program A, one page from program B, and one page from program C are in the memory Demand segmentation A technique similar to paging is segmentation A programmer thinks in terms of modules A program is usually made up of a main program and subprograms In demand segmentation, the program is divided into segments that match the programmer’s view These are loaded into memory, executed, and replaced by another module from the same or a different program since segments in memory are of equal size, part of a segment may remain empty Demand segmentation An example of demand segmentation is shown in figure Demand paging and segmentation Demand paging and segmentation can be combined to further improve the efficiency of the system A segment may be too large to fit any available free space in memory Memory can be divided into frames, and module can be divided into pages The pages of a module can then be loaded into memory one by one and executed OS Components- Process manager A second function of an operating system is process management, but before discussing this concept, we need to define some terms. A program is a non-active set of instructions stored on disk. It may or may not become a job A program becomes a job from the moment it is selected for execution until it has finished running and becomes a program again. A process is a program in execution. It is a program that has started but has not finished. State diagrams The relationship between a program, a job and a process becomes clearer if we consider how a program becomes a job and how a job becomes a process. This can be illustrated with a state diagram that shows the different states of each of these entities. State diagrams (Cont.) Figure shows a State diagram with boundaries between program, job and process State diagrams (Cont.) A program becomes a job when selected by the operating system and brought to the hold state It remains in this state until it can be loaded into memory When there is memory space available to load the program totally or partially, the job moves to the ready state. It now becomes a process It remains in memory and in this state until the CPU can execute it, moving it to the running state at this time When in the running state, one of three things can happen: The process executes until it needs I/O resources, it goes into the waiting state The process exhausts its allocated time slot, it goes into the ready state The process terminates, it goes into the terminated state Process synchronization The whole idea behind process management is to synchronize different processes with different resources. Whenever resources can be used by more than one user (or process, in this case), we can have two problematic situations: deadlock and starvation. Example Two processes A and B. Process A is holding File 1 and cannot release it until it acquires another file, File 2. Process B is holding File 2 and cannot release it until it acquires another file, File 1. Files in most systems are not sharable when in use by one process, a file cannot be used by another process. To force a process to release a file, deadlock is created. Figure 1 Deadlock Deadlock occurs when the operating system does not put resource restrictions on processes. Four necessary conditions for deadlock : Mutual exclusion. Only one process can hold a ressource. Ressource holding. A process holds a resource even thought it cannot use it until other resource are available. No preemption. The operating system cannot temporarilly reallocate a resource. Circular waiting. All processes and resources involved form a loop. Figure 1 Deadlock Starvation is the opposite of deadlock. It can happen when the operating system puts too many resource restrictions on a process. For example, an operating system that specifies a process must have possession of its required resources before it can be run. Starvation is the opposite of deadlock. It can happen when the operating system puts too many resource restrictions on a process. Figure 2 Starvation Schedulers To move a job or process from one state to another, The process manager uses two schedulers The job scheduler The process scheduler Schedulers (Cont.) Job scheduler: Moves a job from the hold state to the ready state or from the running state to the terminated state (Figure shows job scheduler) Schedulers (Cont.) Process scheduler: Moves a process between the running, waiting, and ready states many times before it goes to the terminated state and is no longer a process As shown in the figure below OS Components- Device manager The device manager, or input/output manager, is responsible for access to input/output devices. There are limitations on the number and speed of input/output devices in a computer system. The device manager is responsible for the efficient use of input/output devices Device manager responsibilities The device manager monitors every input/output device constantly to ensure that the device is functioning properly. The device manager maintains a queue for each input/output device or one or more queues for similar input/output devices. The device manager controls the different policies for accessing input/output devices. i.e. it may use FIFO for one device and shortest OS Components- File manager Operating systems today use a file manager to control access to files. The responsibilities of a file manager: Controls access to files. The type of access can vary (read, write, execute) Supervises the creation, deletion, and modification of files. Controls the naming of files. Supervises the storage of files. (how they Any Ques tions ? References Behrouz Forouzan and Firouz Mosharraf, “Foundations of computer science”, Second edition, chapter7, pp. 187- 212 THANK YOU