Computer Science Engineering : Operating system, THE GATE ACADEMY
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Computer Science Engineering : Operating system, THE GATE ACADEMY

on

  • 350 views

THE GATE ACADEMY's GATE Correspondence Materials consist of complete GATE syllabus in the form of booklets with theory, solved examples, model tests, formulae and questions in various levels of ...

THE GATE ACADEMY's GATE Correspondence Materials consist of complete GATE syllabus in the form of booklets with theory, solved examples, model tests, formulae and questions in various levels of difficulty in all the topics of the syllabus. The material is designed in such a way that it has proven to be an ideal material in-terms of an accurate and efficient preparation for GATE.

Quick Refresher Guide : is especially developed for the students, for their quick revision of concepts preparing for GATE examination. Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions

GATE QUESTION BANK : is a topic-wise and subject wise collection of previous year GATE questions ( 2001 – 2013). Also get 1 All India Mock Tests with results including Rank,Percentile,detailed performance analysis and with video solutions

Bangalore Head Office:
THE GATE ACADEMY
# 74, Keshava Krupa(Third floor), 30th Cross,
10th Main, Jayanagar 4th block, Bangalore- 560011
E-Mail: info@thegateacademy.com
Ph: 080-61766222

Statistics

Views

Total Views
350
Views on SlideShare
350
Embed Views
0

Actions

Likes
0
Downloads
38
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Computer Science Engineering : Operating system, THE GATE ACADEMY Document Transcript

  • 1. OOppeerraattiinngg SSyysstteemm FFoorr CCoommppuutteerr SScciieennccee && IInnffoorrmmaattiioonn TTeecchhnnoollooggyy By www.thegateacademy.com
  • 2. Syllabus Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Syllabus for Operating System Processes, Threads, Inter-process communication, Concurrency, Synchronization, Deadlock, CPU scheduling, Memory management and virtual memory, File systems, I/O systems, Protection and security. Analysis of GATE Papers (Operating System) Year Percentage of marks Overall Percentage 2013 12.00 8.12% 2012 9.33 2011 5.00 2010 7.00 2009 8.00 2008 9.33 2007 9.33 2006 11.33 2005 2.67 2004 7.33 2003 8.00
  • 3. Contents Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page i CC OO NN TT EE NN TT SS Chapters Page No. #1. Introduction to Operating System 1 – 10  Introduction 1  Evolution of Operating System 2 – 3  Major Achievements 3 – 5  Operating System Operations 5 – 6  Micro Kernel Architecture 6 – 8  Assignment 9  Answer Keys 10  Explanations 10 #2. Process Management 11 – 45  Process 11  Process vs Program 11  Process State 11  Process Creation 12 – 13  Process Termination 13 – 14  Process Scheduling 14  Interprocess Communication, Concurrency and Synchronization 14 – 17  The Critical Section Problem 17 – 19  Bakery Algorithm 19 – 20  Semaphores 20 – 23  The Readers and Writers Problem 23 – 26  Monitors 26 – 29  Solved Examples 30 – 33  Assignment 1 34 – 38  Assignment 2 38 – 41  Answer Keys 42  Explanations 42 – 45 #3. Threads 46 -52  Thread 46  Life Cycle Of Threads 46 – 47  Multithreading 47  Process Vs Thread 48  User Level and Kernel Level Threads 48 – 50  Assignment 50 – 51  Answer Keys 52  Explanations 52
  • 4. Contents Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page ii #4. CPU Scheduling 53 – 77  Basic Concept 53  Schedulers 53 – 54  Scheduling Methodology 54  CPU Scheduling Algorithm 54 – 62  Solved Examples 63 – 67  Assignment 1 68 – 72  Assignment 2 72 – 73  Answer Keys 74  Explanations 74 – 77 #5. Deadlocks 78 -92  Definition 78  Resource Allocation Graph 78  Condition for Deadlock 78 – 79  Deadlock Prevention 79  Deadlock Avoidance 79 – 82  Deadlock Detection 82 – 83  Recovery From Deadlock 84  Assignment 1 85 – 88  Assignment 2 88 – 89  Answer Keys 90  Explanations 90 – 92 #6. Memory Management 93-134  Introduction 93  Logical and Physical Address Space 93 – 94  Memory Management Requirements 94 – 96  Memory Allocation Method 96 – 102  Paging 102 – 106  Segmentation 106 – 109  Page Replacement Algorithm 110 – 112  Thrashing 112 – 113  Solved Examples 114 – 125  Assignment 1 126 – 128  Assignment 2 128 – 129  Answer Keys 130  Explanations 130 – 134 #7. File System 135 – 153  Introdution 135  File Concept 135 – 137  Access Methods 137 – 138
  • 5. Contents Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page iii  Directory Structure 138 – 140  Protection 140 – 144  Free Space Management 144 – 145  Solved Examples 146 – 147  Assignment 1 148 – 149  Assignment 2 150 – 151  Answer Keys 152  Explanation 152 – 153 #8. I/O System 154 - 172  Kernel I/O Subsystem 154  Disk Structure 154 – 155  Disk Scheduling 155 – 157  Disk Management 157 – 158  RAID 158 – 159  Solved Examples 160 – 163  Assignment 1 164 – 167  Assignment 2 167 – 168  Answer Keys 169  Explanations 169 – 172 #9. Protection and Security 173 – 185  Domain of Protection 173  Access Matrix 173 – 176  The Security Problem 176 – 178  Solved Examples 179 – 180  Assignment 1 181 – 182  Assignment 2 182 – 183  Answer Keys 184  Explanations 184 – 185 Module Test 186 –199  Test Questions 186 – 194  Answer Keys 195  Explanations 195 – 199 Reference Books 200
  • 6. Chapter 1 Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page 1 CHAPTER 1 Introduction to Operating System What is an Operating System? An operating system is a collection of programs and utilities. It act as the interface between user and computer. It creates a user friendly environment. The Operating System act as a Resource Manager. (A Computer system has many resources (Hardware and Software) which may require for completing a task). The computer uses resources like input/output device, memory, file, storage space, CPU time and so on. The operating system acts as a manager of these resources and allocates them to specific program and users as necessary for their tasks. Therefore we can say an operating system act as a resource manager. Generally resource sharing in two ways ‘in time’ and ‘in space’. For example a CPU is a time sharing resource and the main memory is a space sharing resource. The main difference between in time sharing and in space sharing resource is ‘in time’ resource is not divided into units, where as in space resources is divided into units. Structure of Operating System The structure of operating system consists of 4 layers; these are hardware, software, system program and application program. The hardware part consists of CPU, main memory, I/O device, Secondary storage etc. The software includes process management routines, memory management routines, I/O control routines, file management routines. The system program layer consist of complier, assembler etc. Last one is the application program that depends on users. Components of a Computer System
  • 7. Chapter 1 Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page 2 Evolution of Operating System i. Serial Processing: Before 1950 the programmer directly interacts with hardware. There was no operating system at that time, if the programmer wish to execute a program on these days, the following steps are necessary.  Type the program on punch card  Convert punched card to card reader  Submit to the computing machine, is there any error, the condition was indicated by lights.  The programmer examines the registers and main memory to identify the cause of error.  Take the output of error.  Take the output on the printers.  Then the programmer ready for the next program This type of processing takes much time and next program should wait for the completion of previous one. The programs are submitted to the machine one after one. Therefore this machine is said to be serial processing. ii. Batch Processing: In older days (before 1960), it was difficult to execute a program using computer. Because the computer located in three rooms. One room for card reader second room for executing the program third room for printing the result. The user or machine operator needs to run between these three rooms to complete a job. We can solve this problem using Batch processing. In batch processing same type of task are grouped together and execute at a time. The carrier carries the group of job at a time from one room to another. Therefore the programmer need not to run between these 3 rooms several times. iii. Multiprogramming: Multiprogramming is a technique to execute number of programs simultaneously by a single processor. In multiprogramming more than one process can reside in main memory at a time. The operating system picks and begins execute one of the jobs in the main memory. In non multiprogramming system, the CPU can execute only one program at a time. If the running program is waiting for any I/O device, the CPU becomes idle, so it will effect the performance of the CPU. But in multiprocessing environment, any I/O wait happened in a process and then the CPU switches from the job to another job in the job pool. So the CPU is not idle at any time. iv. Time Sharing System: Time sharing or multitasking is a logical extension of multiprocessing. In time sharing system the CPU selects a job from the ready queue and switches the CPU to that job. When the time slot is expired the CPU switches from this job to another, in this method CPU is shared by different process, so it is said to be “Time Sharing System.” The main advantage of time sharing system over the batch processing system is the user can interact with the job when it is executing but it is not possible in batch system. Another advantage of time sharing system is efficient CPU utilization. v. Parallel System: If a system has more than one processor in close communication, sharing the computer bus, the clock, memory and peripheral devices, this system is referred as “tightly coupled” system. A system consisting of more than one processor and if it is a tightly coupled and then the system is called parallel system. One advantage of
  • 8. Chapter 1 Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page 3 parallel system is increased “Throughput”. The performance of CPU is measured in terms of Throughput. The number of jobs completed by a CPU with in a time period is said to be “Throughput”. Multiprocessor can also save money compared to multiple single system because the processor can share peripherals, cabinet and power supply. Another advantages of multiprocessor system is that they increase reliability. vi. Distributed System: In distributed system, the processor can’t share memory or clock, each processor has its own local memory. The processor communicate one another though various communication lines. These system are usually called loosely coupled system. The advantage of distributed system are: 1. Resource sharing 2. Computation speed up 3. Reliability vii. Real Time System  Used when there are rigid time requirements on the operating of a processor or the flow of data.  Systems that control scientific experiments, medical imaging systems, industrial control systems and some display system are real time systems.  Two types of real time systems are:  A hard real time system: guarantees that critical tasks completed on time.  Soft real time system: A less restrictive type of real time system is a soft real time system. Given their date of deadline support they are risky to use for industrial control and robotics Spooling The expansion of spooling is simultaneous peripheral operations on line. Simultaneous means for example if two or more user issue print command and the printer accept the request even the printer is printing some other jobs. The printer printing one job at the same time the spool disk can load some other jobs. Operating System Functions 1. Program creation 2. Programs execution 3. Input output operation 4. Error detection 5. Resource allocation 6. Accounting 7. Protection Major Achievements The major achievement of operating system are Process Management A process is a program in execution: (A program is passive in nature while a process is active) A process has resources (CPU time, files) and attribute that must be managed.
  • 9. Chapter 1 Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page 4 Management of Processes Includes:  Process scheduling (priority, time management,…)  Creation/termination  Block/Unblock (suspension/resumption)  Synchronization  Communication  Deadlock handling  Debugging Main Memory Management  Allocation/de-allocation for processes, files, I/O  Maintenance of several processes at a time  Keep track of who’s using what memory  Movement of process memory to/from secondary storage. File Management A file is a collection of related information defined by its creator, commonly files represent program (both source and object forms) and data. The operating system is responsible for the following activities in connections with file management:  File creation and deletion  Directory creation and deletion  Support of primitives for manipulating files and directories  Mapping files onto secondary storage  File backup on stable (non volatile) storage media I/O Management  Buffer caching system  Generic device driver code  Drivers for each device- translate requests into position commands Secondary Storage Management  Disk, tapes, optical  Free space management ( paging/swapping)  Storage allocation (what data goes where on disk)  Disk scheduling Networking  Communication system between distributed processors.  Getting information about files/processes/etc. on remote machine.
  • 10. Chapter 1 Operating System THE GATE ACADEMY PVT.LTD. H.O.: #74, Keshava Krupa (third Floor), 30th Cross, 10th Main, Jayanagar 4th Block, Bangalore-11 : 080-65700750,  info@thegateacademy.com © Copyright reserved. Web: www.thegateacademy.com Page 5  Can use either a message passing or a shared memory model. Protection  Of files, memory, CPU, etc.  Means controlling of access  Depends on the attributes of the file and user System Program  Command Interpreters – Program that accepts control statements (shell, GUI interface, etc.)  Compilers/linkers  Communication (ftp, telnet, etc.) System Tailoring Modifying the operating System program for a particular machine. The goal is to include all the necessary pieces but not too many extra ones.  Typically a System can support many possible devices but any one installation has only a few of these possibilities.  Plug and play allows for detection of device and automatic inclusion of the code (driver) necessary to drive these devices.  A system is usually a link of many OS routines/modules in order to produce an executable code to run the drivers. Operating System Operations Modern operating systems are interrupt driven. If there are no processes to execute, no I/O devices to service and no users to respond, an operating system will quietly waiting for something to happen. Events are almost always signaled by the occurrence of an interrupt or a trap. Traps and interrupts are events that disrupt the normal sequence of instruction executed by the CPU. A trap is an abnormal condition detected by the CPU, that usually is an indicative of an error. Trap condition can occur in following ways (a) Dividing by zero (b) Trying to access a memory location that does not exists or for which the program does not have access (c) Executing an instruction with an undefined opcode, (d) Trying to access a nonexistent I/O device. An interrupt is a signal sent to the CPU by an external device, typically an I/O device. It is the CPU’s equivalent of a pager, a signal requesting the CPU to interrupt its current activities to attend to the interrupting device needs. A CPU will check interrupts only after it has completed the processing of one instruction and before it fetches a subsequent one. The CPU responds to traps and interrupts by saving the current value of the program counter and resetting the program counter to a new address. This allows the CPU to return to the executing point where the trap or interrupt occurred, after it has executed a procedure for handling the trap or interrupt.