Module 1. Introduction:

Similar documents
Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Course: Operating Systems Instructor: M Umair. M Umair

Operating Systems Overview. Chapter 2

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

OPERATING SYSTEMS UNIT - 1

Chapter 3: Operating-System Structures

Module 3: Operating-System Structures

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

Process Description and Control. Chapter 3

Operating-System Structures

Process Description and Control. Chapter 3

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

UNIT:2. Process Management

Operating-System Structures

Unit 2 : Computer and Operating System Structure

CSc33200: Operating Systems, CS-CCNY, Fall 2003 Jinzhong Niu December 10, Review

Module 3: Operating-System Structures. Common System Components

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

3.1 Introduction. Computers perform operations concurrently

Concurrency: Deadlock and Starvation. Chapter 6

UNIT 2. OPERATING SYSTEM STRUCTURES

Announcement. Exercise #2 will be out today. Due date is next Monday

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

2. The system of... generally ran one job at a time. These were called single stream batch processing.

CS370 Operating Systems

Operating System Services

Chapter 3: Operating-System Structures

Threads Chapter 5 1 Chapter 5

Chapter 1: Introduction

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015

Solved MCQs on Operating System Principles. Set-1

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

Chapter 1: Introduction. Chapter 1: Introduction

Major Requirements of an OS

7/20/2008. What Operating Systems Do Computer-System Organization

IT 540 Operating Systems ECE519 Advanced Operating Systems

Chapter 3: Operating-System Structures

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

CSC 453 Operating Systems

Chapter 1: Introduction

Operating Systems Overview. Chapter 2

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

(MCQZ-CS604 Operating Systems)

Concurrency: Deadlock and Starvation

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

ECE519 Advanced Operating Systems

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

Chapter 6 Concurrency: Deadlock and Starvation

OPERATING SYSTEM. Functions of Operating System:

Process Description and Control. Major Requirements of an Operating System

Major Requirements of an Operating System Process Description and Control

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Introduction. CS3026 Operating Systems Lecture 01

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.)

CS 450 Fall xxxx Final exam solutions. 2) a. Multiprogramming is allowing the computer to run several programs simultaneously.

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Operating System. Operating System Overview. Layers of Computer System. Operating System Objectives. Services Provided by the Operating System

Operating System Overview. Operating System

Concurrency: Deadlock and Starvation. Chapter 6

Deadlock and Starvation

ELEC 377 Operating Systems. Week 1 Class 2

Main Points of the Computer Organization and System Software Module

Real-Time Programming

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Operating- System Structures

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Chapter 1: Introduction

Operating System Support

Lecture 3: Concurrency & Tasking

OPERATING SYSTEMS. P. PRAVEEN Asst.Prof, CSE

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Operating System Review

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

QUESTION BANK UNIT I

Introduction to Computer Science. Polly Huang NTU EE

Process Description and Control

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Sistemi in Tempo Reale

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

CS370 Operating Systems

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively.

Chapter 6 Concurrency: Deadlock and Starvation

Chapter 1: Introduction. Operating System Concepts 8 th Edition,

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru Department of Electronics and Communication Engineering

آنستیتیوت تکنالوجی معلوماتی و مخابراتی ICTI

Operating System Control Structures

Chapter 3 Process Description and Control

Introduction to Operating Systems (Part II)

Operating Systems. Lecture 3- Process Description and Control. Masood Niazi Torshiz

Lecture 1 Introduction (Chapter 1 of Textbook)

1. Background. 2. Demand Paging

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

SAZ4B/SAE5A Operating System Unit : I - V

Transcription:

Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system. It also provides an easy to use interface to the users. The major function of an operating system is to hide the inner complexity of the hardware and give the programmer a friendly and convenient set of instructions to work with. The operating system provides the support for all other system programs such as compilers and editors and application programs like accounting software and games. Operating system runs in kernel mode or supervisor mode and is protected from users by the hardware Roles of an Operating System: Without an operating system, a computer is little more than a bundle of plastic, metal, and a few bits of expensive silicon. Most of the software runs on a computer, but the operating system is the software that runs the computer. The operating system performs basically two unrelated tasks such as extending the machine and managing resources. The computers consist of processors, memories, timers, disks, network interfaces, printers etc. Hence the job of the operating system is the controlled allocation of the various resources for the different programs requested for them. Operating systems are designed to provide uniform abstraction across multiple applications. As an Interface: The architecture of most computers at the machine language level is primitive and difficult to program, especially for input/output. The program that hides the truth about the hardware from the programmer and presents a nice, simple view of named files that can be read and written is, the operating system. Just as the operating system shields the programmer from the disk hardware and presents a simple file-oriented interface, it also conceals a lot of unpleasant things concerning interrupts, timers, memory management, and other low-level features. In each case, the abstraction offered by the operating system is simpler and easier to use than that offered by the underlying hardware. In this view, the function of the operating system is to present the user with the equivalent of an extended machine or virtual machine that is easier to program than the underlying hardware.

As a Resource Manager: An operating system is a set of programs that is used to manage various resources and overall operations of a computer system. Resource management includes sharing resources in two ways, viz. time and space. When a resource is time shared, different programs or users may use them in different turns. For example, if there is only one CPU and multiple programs want to run, the operating system first allocates the CPU to one program and after a certain period of time, it will allocate CPU to the next program and then to the next and so on. The other type of sharing is space sharing. Instead of taking turns, the customer gets parts of the resource. For example, main memory is divided among several running programs so that each one cane in the main memory at the same time. Module 2 Basic Functionalities of an Operating System: Operating systems provide a number of services. At the lowest level, system calls allow a running program to make requests from the operating system directly. Since an operating system is large, modularity is important. Process Management : It deals with the assignment of processor to different tasks being performed by the computer system. The functions for process management are keep track of the active process (the part of the program that is processed by the CPU) by means of some data structure that depict the state of the system. The operating system contains a scheduler that selects which process to run next when running process is switched off. When allocating the CPU to a new process the kernel saves the state of the departing process and restores the state of the incoming process which is known as Context Switch. The operating system is responsible for the following activities in connection with process management. i. The creation and deletion of both user and system processes. ii. The supervision and resumption of processes. iii. The provision of mechanism for process synchronization. iv. The provision of mechanism for process communication. v. The provision of mechanism for deadlock handling.

The program that keeps track of the processors and status of processes is called the Traffic Controller. The Process Scheduler is the program that decides which process gets the processor when and how much. Allocating the processor to a process by setting up necessary hardware registers is the job of the Dispatcher. So the system calls or services associated with these functions include 1. Create a process 2. Destroy a process 3. Suspend a process 4. Resume a process 5. Change the priority of a process 6. Block a process 7. Wake up a process 8. Dispatch a process Memory Management : Memory is a large array of words or bytes having a unique address. The main purpose of a computer system is program execution. These programs are in main memory during execution with the data they access. Main memory is generally the only storage device that the CPU is able to address directly. But main memory is too small to accommodate all the data and programs. So computer system provides secondary storage to back up main memory. The memory management functions include memory protection mechanisms, memory swapping mechanisms and virtual memory mechanisms such as page fault handling and page replacement. Hence the OS performs the following activities for memory management. 1. Keep track of which parts of memory are currently being used and by whom. 2. Decide which process is to be loaded into memory when memory space becomes available and how much. 3. Allocate and reclaim memory space as needed. functions. For the secondary storage or disk management, the operating system performs the following

1. Free-space management 2. Storage allocation 3. Disk scheduling The operating system keeps a list of free memory. Before loading a program into memory from disk, the required memory area is allocated to it and the operating system updates the list of free memory. Services of the operating system in this regards are 1. Allocate a chunk of memory to process 2. Free a chunk of memory from a process Device Management : One of the roles of an operating system is to hide the complexities of specific hardware devices from the user. Only the device driver knows the features of specific device to which it is assigned. The different components for this are 1. A buffer caching system 2. A general device driver interface 3. Drivers for specific hardware devices A program, as it is running may need additional resources to proceed such as more memory, tape drives, access to files etc. If the resources are available, they can be granted and control can be returned to the user program. Most operating systems treat all devices such as disks, tapes, terminals and printers in the same general manner, with special management for the processor and memory. Device management refers to the way these generic devices are handled. So the tasks of operating system to accomplish device management is 1. Keep track of the I/O devices, channels and control link. This module of the operating system is called the I/O Traffic Controller. 2. Decide what is an efficient way to allocate the I/O devices. This is the job of the I/O Scheduler. 3. Allocate the I/O devices and initiate I/O operation.

Information Management : Many system calls exist for transferring information between the user program and the operating system. The operating system keeps information about all its processes and there are system calls to access this information. Sometimes there will be call to reset the process information. Files are abstract resources of storage devices. Information stored in the main memory will be overwritten as soon as the memory is deallocated from a process. Information to be saved must be copied to a storage device and information management refers to a set of services used for storing, retrieving, modifying or removing information on various devices. As a part of information management, the operating system performs the following actions. 1. Keep track of the information, its location, use, status etc. these collective facilities are called File system. 2. Enforce protection requirements and provides access routines. 3. Allocate the information eg, open a file 4. Deallocate the information eg, close a file Services of the operating system in this regard are 1. Create a file 2. Create a directory 3. Open and close a file 4. Read data from file to buffer 5. Write data from buffer to file 6. Create a link 7. Change working directory etc.

Module 3 Processes : A process is a program in execution, represented by the tuple (Process id, code, data, register values, PC values). The process is the smallest unit of work individually scheduled by an OS. An OS creates a process in response to a request form the user to activate an executable program. Once created a process becomes active and eligible to compete for system resources such as processor and I/O devices. The concept of program and process are different. Process is a dynamic concept undergoing frequent state and attributes changes while an executable program or job is a static process template that may give rise to one or more processes. Implementation of a Process: To implement the process model, operating system maintains a table called process table, with one entry per process. This entry contains information about the process state, its program counter, stack pointer, memory allocation, the status of its open files, its accounting and scheduling information etc. although the exact fields contained in the process table vary from system to system, there will be some fields for process management, some for memory management, and some other for file management etc. When a process is created, the operating system performs the following actions. 1. Creates a Process Control Block for the process. 2. Assigns Process Id and Priority. 3. Allocates memory and other resources to the process. 4. Set up process environment. 5. Initialize resource accounting information for the process. Process Control Blocks: To keep track of all information concerning a process, the operating system groups all the information that it needs about a particular process into a data structure called Process Descriptor or Process Control Block (PCB). Whenever a process is created, the operating system creates a corresponding PCB to serve its run-time description during the life time of the process.

When the process terminates, its PCB is removed. The PCB of a process contains information concerning the following. 1. Process scheduling information. 2. Information concerning memory and resources allocated. 3. Pointers to the next PCB in the process scheduling list. The process scheduling information consists of id, priority, state and description of execution status. This information is collectively called Process Status Vector. The structure of a PCB is given in the following figure. Process States: Figure. PCB A process can go through a series of discrete process states. The four general categories of process states are: 7. Dormant ( Hold ) 8. Ready 9. Running 10. Blocked (Suspended) The dormant state denotes processes that are not known to and therefore not tracked by the operating system.

Inter Process Communication : Processes frequently need to communicate with other processes. The communication between processes needs to be in a well structures way not using interrupts. The cooperating processes can communicate in a shared memory environment. Another way to achieve the same is by the Inter Process Communication (IPC) facility provided by the operating system. IPC provides a mechanism to allow process to communicate and to synchronize their actions. IPC is best provided by a message system. The function of a message system is to allow processes to communicate with each other without the need to resort to shared variables. Another is the indirect method in which messages are sent and received using mail boxes. There are also some issues related to the Inter Process Communication (IPC). They are briefly discussed below.

Module 4 Race Condition : Processes working together often share some common storage that each one can read and write. When two or more processes are reading or writing some shared data and the final result depends on who runs precisely when is called race condition. For example, In file systems, two or more programs may "collide" in their attempts to modify or access a file, which could result in data corruption. File locking provides a commonly-used solution. Critical Sections : Race condition and many other troubles of IPC is due to the use of shared memory and shared files. So to avoid these problems, there should be some mechanisms to prohibit more than one process from reading and writing the shared data at the same time. The part of the program where the shared memory is accessed is called the Critical Section. If we could have any mechanism to prevent any two processes from entering into their critical sections at the same time, race condition cane be avoided. The solution to the problem of race condition needs to have the following four conditions. 1. No two processes may be simultaneously inside their Critical Sections. 2. No assumptions may be made about speed or the number CPU cycles. 3. No process running outside its Critical Section may block other processes. 4. No process should have to wait forever to enter its Critical Section.

Module 5 Handling Competition among Process An important task of an operating system is the allocation of the machine s resources to the processes in the system. Resources include the machine s peripheral devices as well as features within the machine. The resource allocation is a complex task which causes malfunctions in the system, severe of them is the deadlock. So there are many techniques used to handle the competition among processes for resources. Semaphore Consider a time sharing operating system, controlling the activities of a computer with a single printer. To control access to the printer by multiple processes at the same time operating system must keep track of whether the printer has been allocated. One approach is to use a flag, whose states are often referred to as set and clear. A clear flag (value 0) indicates that the printer is available and asset flag (value 1) indicates that the printer is currently allocated. But this simple flag system has a problem. The task of testing and possibly setting the flag may require several machine instructions. It is therefore possible for a task to be interrupted after a clear flag has been detected, but before the flag has been set. When this process is interrupted, another process will get the time slice and it may also request for the printer. After some time when the original process resumes it will start from where it has stopped. So is had read the value of flag which is 0 and request for the printer and set the flag. This process will be given access to the printer. Now the situation is two processes are using the same printer, which is of no use. The solution to this is, to insist that the task of testing and setting the flag be completed without interruption. One approach is to use the interrupt disable and interrupt enable instruction. But this is not optimal because it may block future interrupt. A properly implemented flag called Semaphore is used in software systems in much the same way as they are in railway systems. Corresponding to the section of track that can contain only one train at a time is the Critical Section that can be executed by only one process at a time. That is mutual exclusion to a critical region is obtained by using Semaphores. To enter the critical section, process must find the semaphore clear and then set semaphore before entering the entering the critical region; then upon exiting, the process must clear the semaphore. If the semaphore is found to be in its set state, the process trying to enter the critical region must wait until the semaphore has been cleared.

Deadlock Another problem that can arise during resource allocation is deadlock, the condition in which two or more processes are blocked from progressing because each is waiting for a resource that is allocated to another. But deadlock can occur only if all four of the following conditions are satisfied. 1. Mutual Exclusion: The resources are acquired and used in a mutually exclusive manner. 2. Hold and Wait: Each process continues to hold resources already allocated to it while waiting for other resources. 3. No preemption: Resources allocated to one process can be retrieved from it only by the voluntary action of that process. 4. Circular Wait: Deadlocked processes are involved in a circular chain. The deadlock problem can be removed by attacking any one of these conditions. The occurrence of deadlock is considered so remote that no effort is made to avoid the problem. Instead, the approach is to detect it and then correct it by forcibly retrieving some of the allocated resources.