0% found this document useful (0 votes)
161 views100 pages

OS Decode Unit-01 06

Uploaded by

gangobye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
161 views100 pages

OS Decode Unit-01 06

Uploaded by

gangobye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
‘A Guide For Engineering Students OPERATING SYSTEMS SUBJECT CODE : 217521 S.E. (Artificial Intelligence & Data Science) Semester - Ill © Copyright with Technica! Publications Al publishing rights [printed ond ebook version) reserved with Technical Publications. No port ofthis book should be reproduced in any form, Electronic, Mechanical, Photocopy or any information storage ond retrieval system without prior permission in writing, from Tachnical Publications, Pune Published by . Ait Residency, fie Net, 412, Shoivar Pah 2A TECHNICAL) or. srios6,ns now. sstavs 2eseee7 |S PUBLICATIONS | mot wiocrechicabubicatons in sam" shina omen Website : www-technicalpublications.in Printer : Yesinj Pinters 8 Bindes, StNo. 10/1A,Ghule Indusial Estate, Nended Village Rosd, Tl. - Havel, Dis, - Pune - 411041. ISBN 978-93-5585-227-4 UE a @ PU eee (@ Scanned with OKEN Scanner SYLLABUS Operating Systems - (217521) Credit Examination Scheme : 03 Mid_Semester (TH) : 30 Marks End_Semester (TH) : 70 Marks UnitI Fundamental Concepts of Operating system Operating system functions and characteristics, historical evolution of operating systems, issues in operating system design, User's view of the OS, Types of OS : Batch, time sharing, multiprogramming, distributed, network and real-time systems, Operating-System Services, Types of System Calls, System Programs. BASH Shell scripting : Basic shel commands, shell as a scripting language. (Chapter - 1) Unit I Process Management Process concept, Process Control Block(PCB), Process Operations, Process Scheduling : Types of process schedulers, Types of scheduling : Preemptive, Non preemptive. Scheduling algorithms : FCFS, SJF, RR, Priority, Inter process Communication(IPC). Threads : multithreaded model, implicit threads, threading issues. (Chapter - 2) Unit II Process Coordination . Synchronization : Principles of Concurrency, Requirements for Mutual Exclusion, ‘Mutual Exclusion : Hardware Support, Operating System Support (Semaphores and Mutex), Programming Language Support (Monitors). Classical synchronization problems : Readers/Writers Problem, Producer and Consumer problem, Inter-process communication (Pipes, shared memory : system V) Deadlock : Deadlock Characterization, Methods for Handling Deadlocks, Deadlock Prevention, Deadlock Avoidance, Deadlock Detection, Recovery from Deadlock. (Chapter - 3) (i) (@ Scanned with OKEN Scanner Unit IV Memory Management’ Memory Management : Memory Management Requirements, Memory Partitioning : Fixed Partitioning, Dynamic Partitioning, Buddy System, Relocation, - Paging, Segmentation. Virtual Memory : Hardware and Control Structures, Operating System Software. (Chapter - 4) Unit V I/O and File Management VO Management : /O Devices, Organization of 1/O function, /O Buffering, Disk SchedulingDisk Scheduling policies like FIFO, LIFO, STTF, SCAN, C-SCAN. File Management : Concept, Access methods, Directory Structure, Protection, File System implementation, . Directory Implementation, Allocation methods, Free Space management, (Chapter - 8) Unit VI Linux History Of Unix and Linux , Overview Of Linux - Linux Goals, Interfaces to Linux, The Shell, Linux Utility Programs, Kemel structure, Processes in Linux - Process ‘management system calls in Linux, Implementation of process and threads in Linux, Process scheduling Linux, Booting. (Chapter - 6) (iv) it (@ Scanned with OKEN Scanner TABLE OF CONTENTS Chapter - 1 Fundamental Concepts of Operating System (1 - 1) to (1 - 24) 1.1 Operating System Functions and Characteristics .. 1-1 1.2 Historical Evolution of Operating Systems.. 1.3. Types of OS.. 1.4 Operating-System Services 1.5. Types of System Calls..... 1.6 System Programs..... 1.7. BASH Shell Scripting, 1-19 Unit II Chapter-2 Process Management (2- 1) to (2 - 32) 2.1 Process Concep' 2.2 Process Operations. 2.3 Process Scheduling... 2.4. Types of Scheduling 2.5 Scheduling Algorithms... 2.6 IPC... 2.7 Threads .. wv) (@ Scanned with OKEN Scanner 2.8 Multithreading Model Rosivia oo a Chapter - 3 Process Coordination (3 - 1) to (3 - 35) 2.8 Threading Issue... 3.1. Synchronization : Principles of Concurrericy .. 3.2. Mutual Exclusion : Hardware Support. 3.3 Operating System Support : Semaphores and Mutex... 3.4 Programming Language Support : Monitors... x in Classical Synchronization Problems. 3.6 Inter-Process Communication 3.7 Deadlock ... 3.8 Deadlock Prevention.. 3.9 Deadlock Avoidance... 3.10 Deadlock Detection and Recovery from Deadlock Chapter-4 Memory Management (4 - 1) to (4-31) 4.1 Memory Management Requirements... 4-1 4.2: Memory Partitionin, : Fixed Partitioning and Dynamic Partitioning. 4.3, Buddy System. 4.4 Paging. (wi) (@ Scanned with OKEN Scanner 4.5. Segmentation... 4.6 Virtual Memory : Hardware and Control Structures .. 4.7 Operating System Software. Chapter-5 . WOand File Management (5 - 1) to (5- 39) 5.1 1/0 Devices, Organization of I/O Function... 5-1 5.2. 1/0 Buffering... 5.3 Disk Scheduling... 5.4. File Management Concept... 5.5 Access Methods... 5.6 Directory Structure... 5.7 Protection ... 5.8. File System Implementation ... 5.8 Directory Implementatioi 5.10 Allocation Methods... 5.11 Free Space Management Chapter - 6 Linux (6-1) to (6 - 18) 6.1 History of Unix and Linux. a 6-2 62 Shell, 6-3 6.3 Linux Utility Programs and Kernel Structure 6-4 a See (@ Scanned with OKEN Scanner 6.4. Processes in LINUX « 6.5. Bootini ‘Solved Model Question Pay pers t (vii) (@ Scanned with OKEN Scanner Fundamental Concepts of Operating System 1,1 : Operating System Functions and Characteristics _ Q.1. What is operating system ? State and explain the basic functions of operating system. Ans. : © OS definiti the execution of application programs. It is an interface between : Operating System is a program that controls applications and, hardware. © OS provides different types of view. For user, it is abstract view because it provides features which are important for users. OS is intermediary between user and the computer system. e The major design goals/ functions of an operating system are : 1. Efficient use of a computer system. 2. User convenience 3. Ability to evolve © An operating system is software’ that manages the computer hardware. The hardware must provide appropriate mechanisms to ensure the correct operation of the computer system and to prevent user Proemams from interfering with the proper operation of the system. Efficient use © For efficient use of resources, it must be monitored by operating system. Proper scheduling of resources is also required. ‘© Computer contains different type's resources like CPU, memory and /O device ete. Proper monitoring is required on these resources to avoid the overhead. As per the resource, scheduling is required. (@ Scanned with OKEN Scanner pandamental Concepts of Operating s, } ce fr CPU 84 EME: 1 Memon | pa “aew program into the MEMery. They oul User convenient by computing eXVFORMEN! Of the com wring envionment is comprised of Computer gy. and nature of computations perfor : change the computing environment of, sitecre and use change the : é + Comps owing factors axe considered while considering a syste a 4, Evolution ‘5, User friendly OS. Ability to evolve: 1 An OS should te consincted in such @ Way a8 f0 perm the effing deveopneny, testing and introduction of new system functions wit atthe same time interfering with service. ‘a2 Describe in detail the functions of OS as a resource manager, ‘Ans. # A computer is a set of resources, These resource provides sariows finetions to the user. Functions like data movement, storing of aa and program, operation on data are control by an operating system, + Fig. Q2.1 shows OS a8 a resource manager, «The operating system is responsible for managing the all resources, & prion of te OS is in main memory, This portion of the OS is called em + User program and data is also stored in remaining parts of the memory, ‘ulosaion of mein memory is controlled by operating system with the help of memory management hardware. | * TO devise is comvolled by OS and it decides when an UO device eax te wed by program in exteuion, Processor is one type of resource and 5 contol the exesution of user program on the processor. i Operating Systems 1-3 WO coototar | pf oF] Keytar [os kernal UO controler? bp} Printer User 10 controler Fp} rouse wee 0 controler « Dissiay program and data UO contralar § Disk C4 storage Main memary Processor] [Processor] [Processor #4 2 |...[ en Computer system Fig. 0.2.4 OS as a resource managor © Modem OS allows multiple programs to run at the same time. If multiple users aze using computer then there is need of managing and protecting the memory, V/O devices and other resources. ‘Resource management includes sharing resources in different ways. Time and spece are the two concept for resource sharing. 1, Time : Time slot is allocated to each program first one gets to use the resource then another and so on. 2. Space : Consider the example of main memory. Main memory is normally divided up among several running programs, so each one can be Tesident at the same time. .3 What are the benefits of resource abstraction ? ‘Ans, : # Resource abstraction is the process of “hiding the details of how ‘the hardware operates, thereby making computer hardware relatively easy for an application programmer to use" + provide a single abstract disk interface which will be the same for both the hard disk and floppy disk. ‘Saves the programmer from needing to leam the details of both hardware interfaces. ‘A Guide for Engineering Suds “ ae | “A Guide for Engineering Seen @ scanned with OKEN Scanner Operating Systeme 2d Bendannenat Concerts of OP ating Spat © While making the fantware cose 0 UAE TEWOUTTE ABHACtion ag limite the apace Bevel of cee ver the hartware Hy Bidng som functionality behind the sbstraction. i j Since most appation programmers de not need such 8 bi oer, the abstraction provided Ey WHE OPETBENG AYHEM is genera | very tefl n of Operating Systems | j 1.2: Historical Evolutiot 24 Discuss evolution of operating systems fam: Opering systems have been evolving OUGh the yea, Fottowing table shows the history of OS. Cceneraton Year Electronic devices Types of OS and sed devices Fon MESS Second 1985968 Tem ce 10661860 ‘negated ieuit IC) Muliprogramming | oath Since 1980 Large scale itegation PC Fe Foncaaeaber 1 13 Types of 0S 25 Describe in brief the evolution of operating system. ‘Aug. : « The evolution of operating systems is directly dependent to the development of computer systems and how users use them. OS created to process jobs in batches. Later Multitasking and Time-Sharing created to ‘un multiple jobs and allow user interaction to improve efficiency. Mulitesking brought challenges to manage UO operations required by ‘multiple jobs in which computer vendors resolved with interrupts. 4, Batch system : ‘Batch system process s collection of jobs, called a batch, Batch is a sequence of usr jobs. A Gale for Enginerng Suen opening Stems E-Partners Sto, conemande,prngemms en dana that art a fob in 4 predefined requence combined in jb in the batch i independent of ther jhe on the Batch caaeucting. + te with 2 + Boch 5 wer dan define 2 job coetrol specification by sequence of commands ilar needs were batched together 1 speed ap processing res are the input device in batch opsteme ine printers fo Jobs with si Card readers and tape dt ‘Output devices are tape drives, cand punches and ‘sprimary fimction of the batch system isto service she jobs 9 Sach ‘one after another without requiring the operators sntervention to need for humaniser interaction with the job when comm sacs the information required to complete job is kept 6 cone thing at a time. They bat 2 camed out one after the 1 Some computer systems only did instrctions to cary out and these woul! be other, This is called a serial system. The mechanics of deve nd preparation of programs in such environments are giite sow st rumerous manual operations involved in the process «Batch monitor is used to implement butch processing sexs, Gatch monitor is also called kernel, Kemet resides in one pat of be ‘computer main memory 2, Mulliprogramming OS : ther CPL ot LO ‘= CPU remains idle in batch system. At any time device was idle in batch system. To keep CPU busy. more than one programijoh must be loaded for exseution. increases he CPU utlizations, So muliprograruming increases the CPU unlization. # Resource management is the main aim of eultiprogramming operating system, File system, command processor, UO contol system and transient area ate the esseuta! cumponenis of a single wer operating system. + Multiprogramming operating system divides the wansient area to store the multiple programs and provides resource management to the ‘operating system. exsot “A Guide for Engineering Students tall © Scanned with OKEN Scanner utamentat ‘Operating system kernal Fig. 4 Mutprogan {08 momory layout"? Sora | ‘on Progam t Progam? (elootng sat) Progen temcuing by CPU) Performing VO operation wathg tr cL progam Uralosied space Fig. 5.2 Working of muitiprogramming OS ‘+n mubiprogamming operating system, programs are competing fa resoures, A function ofthe multiprogramming operating system is CP) scheduling, memory management and 1/0 management. ——— ‘Aull for Engvecring Soe —_—_ eens of Opting Sy, Fundamental Concepts of Operating System ‘operating Synterts exe are four programs for execution, All four programs ae ‘he memory. CPU select frst program for execution s contain instruction for CPU and 1/0 operation, ‘Also explain advantages and « Suppose th toaded into ‘Normally Program qs Explain time sharing system. aaisadvantages. ‘Ans. 2 0 an interact repute from terminals connected t0 the computer precesor's te which Is shared among maple users simultaneously is termed as time-sharing. «Time sharing is logical extension of multiprogramming OS. Fig. Q6.1 shows time sharing system. | [Host ceomputee sive system, many users directly interact with the Terminal "Terminal Fig, Q.6.1 Time sharing |e time sharing is a method that allows multiple users to share resources at the same time, Multiple users in various locations cen use specific computer system at atime ‘s Time sharing is essentially @ rapid time division multiplexing of the | processor time among, several provesses. The processor switching is so frequent that it almost seems each process has its own dedicated processor. ime sharing OS is designed to provide 2 quick response 10 sub-requests made by users. 1s The processor time is shared between multiple users at @ time. The processor allows each user program to execute for a small time ‘quantum, Moreover, time sharing systems use multiprogramming and multitasking. “A Gide for Engineering Students alii © scanned with OKEN Scanner 26 _ Fear! Cones of Operating, —— ee of Ove TT ting Systems 1-9 sedamental Concepts of Operating System The operting ton provides immediate feedback 10 hp Operating Svs srone tne ca be i second, dEPEMNE On the mabey of Mey wots Hm a Beet rt a eet et users. for output. ose by a time-sharing heme j event two users from aerating pristing lines 2 The scheduling technique wed by is cat sts main use is t0 ps se their output completely mixed the line printer on the same pag together. it also helps in reducing idle time and overlapped LO and ing ot CPU. “a ‘e It refers to putting jobs in a buffer, a special area in memory or on a disk where a device can acess them when i is ready robin scheduling with time si if the time slize lapses before the process completes seri sebvregust the keel preempts the Process, MOVES it tothe scheduling queue and schedules another process. The main diffrence between Mult-proprammed Batch Syren Time Staring Systems is that in case of Multi-programmeg systems, the obyetve is to maximize processor use, whereas iq Sharing Sestems. te objective is to minimize response tine. « Spooling is useful because device access data at different rates. The buffer provides a waiting station where data can rest while the slower device catches up. # Computer can perform VO in parallel with computation, it becomes «Features of time sharing system Feature of ie sherig possible to have the computer read a deck of cards to a tape, drum or 1, Use interaction with program is possile disk and to write out to a tape printer while it was computing. This 2. Tine shnng system uses medium tem scheduling such ay jgay process i called spootng okie Foes neg. © The most common spooling application is print spooling. Spooling 3. Each user is given a time slice for executing job in round nay) batch system were the first and are the simplest of the fashion ‘mulliprogramming systems. © Advantages of time sharing operating systems : ‘sin spooling, VO of one job is overlapped with the computation of 1. Provides the advantage of quick response, another job, For example, a spooler ata time may read input of one job 2. Avoids duplication of software. and at the same time, it may also print the output of another job. 3. Reduces CPU idle time. + Spooling can also process data at the remote site. The spooler only has to notify when a process gets completed at the remote sits so that spooler can spool next process tothe remote side device. + Spooling increases the performance of the system by increasing the working rate of the devices. It naturally leads to muliprogramming. Advantages of spooling 7 What do you mean spooling ? ae a mee spooling ? Explain in detail, + The spooling operation uses a disk as a very large buffer. + © When s job completes exceut . ‘ up forthe job et coed ag ution its memory is released ade] 4 spocing is however capable of overlapping VO operation fer ene job * Spool ‘erie ite an ouput pool far Iter printing with processor operctions for another job. Stet <2 fazeym for sintancous peripheral operation on Kit _Teoling wes the dik os « large buler for outputting data 10 primes ee + Disadvantages of time sharing operating systems : 1. Problem of reliability. 2. Question of security and integrity of user programs and data. 3, Problem of data communication, TA Gade or Evginering Students las @ scanned with OKEN Scanner A Gul for Engncering Sabo 1-10 Fundamental Concepts of Operating g, ‘Operating Systems ‘as Give se features of real dime operating $8f6m and time shy, ® operating system. ‘Aus, : Features of Real Time ‘Operating System : eal sme ystem fis it doesnot give result within the time 2 Realtime tsk cannot keep wating for longer time without at rel. ag 45, Real time operating system uses priority scheduling algorithm Features of Tne Sharing Operating System = 1. User interaction with program is possible in time sharing per system. nag 2, Time sharing system uses medium term scheduling’ such ag robin for the foreground. ung 4. In time shoring system, each user is given a time slice for ister job in round robin fashion oe 29 Explain distributed OS with neat sketch and give its pros ang ‘Ans. : © Diswibuted operating systems depend on networking for the operation, Distributed OS runs on and controls the resources of anulip saachines, It provides resource shaving across the boundaries of a single computer system, It Jooks to users lke a single machine OS, Distributn (8 owns the whole nenvork and makes it look like a virtual niprocesee or may be a virual multiprocessor. + Definition : A dissibuted operating system is one that looks 10 its uses like an ordiaary operating system but rans on multiple, independent cru. © Fig. Q9.1 shows the distributed system. Lie Fig. 0.9.1 Distributed system ee ‘A Guide for Engincering Students operating Systems 1-11_ Fundamental Concepts of Operating Sytem ‘Advantages of distributed OS : 1. Resource sharing : Sharing of software resources such as software Iiraries, database and hardware resources such as hard disks, printers god CDROM can also be done in a very effective way among all the ‘computers and the Users. 2, Higher reliability : Reliab iy refers to the degree of tolerance agsinst wees and component failaes. Availability is one of the important pect of reliability. Avaiabiliy refers 10 the faction of time for ator system is available for use. Availablity of a hard disk ean be Jhereased by baving multiple hard disks located at diferent sites, If aie hard disk fails or is unavailable, the program can use some other tard disk 4. Better price performance ratio: microprocessor and increasing computing power rice-performance ratio. 4, Shorter responses times and higher throughput &. Incremental growth : To extend power and functionality of a system ty simply adding additional resources to the system. «+ Examples of distributed operating system are amoeba, chrous, mach end vvsystem, Difficulties in distributed OS ar 1. There are no current commercially successful examples. 2, Frotocol overhead can dominate computation costs. 3, Hard to build well, 4, Probably impossible to build at the scale of the internet. 2.40 Explain the following : Multitasking, ‘Ans: + Time sharing is also called multitasking operating system. It is Jogical extension of the multiprogramming operating systems. User interaction with ‘program is possible in time sharing operating system. During execution of the program, user interacts directly with the program, supplying information to the program. © Mult-tasking means that the computer can work with more than one program at a time. For example, user could be working with information from one database on the screen analyzing data, while the computer is sorting information from another database, while a excel sheet is performing calculations on a separate worksheet —— ees Gone “A Guide for Engineering Sudets Reduction in the price of gives good @ scanned with OKEN Scanner Hef Ort ag , Repsters pus stating addresses of blocks of parameters . Parameters can be plied or pushed onto the stack bj 32d ont by the program and popped off the stack by the OS. . 46 Discuss types of system cals ‘Aus: Syste ell is divided into following types: 1. File management 2, Process management 3. Imerprocess communication 4. UO device management 5; Information processing and maintenance => Engineering Suds opening Systema __ 1-17 _ Fundamental Cony of Operating Sete 4. File management «File management system calls are create fil, ‘te, read file, write fle, get aid set file atribute te a file using create ) system call. File name with and deleting a file through system reforms various operations on the delete file, open file, close 1 User cam creat aitsibutes are required for creating ‘all. After creating a file, user can Pe file med on the file. File is ‘¢ Read, write, reposition are the operation perfor loved afer finished using, Same type of operation is pérformed gn directory. attributes, File attributes includes name of file, (ype «Every file has file Gf fle, secounting information etc. To perform any operation on the file, set file atribute and get fle atribute executed 10 check the atuibuts. 2. Procass' management ‘system eas for process management. are create, teminate, Toad, necute, abort, set and get process attributes. Other system call for rocess management is wait for time, wait even, allocate and fee memory. en some situation user want to terminate the currently running process tinormally then system call used, Other reasons for abnormal process termivation ae error message generated, memory dump, error tap. + Operating system provides debugging facility to determine the problem of dump. Dump is written to secondary storage disk. Debugger is a one type of system program. It provides facility for finding and correcting bug. 3. Interprocess communication ‘Pipe, socket, message passing and shared memory are used for iterprocess communication. Send message, receive message, create and delete connection, atach remote device are the system calls used in interprocess communication © scanned with OKEN Scanner ‘Operating Systems 1-18 Fundamental Concerts of Operating System, Stared memory : A process wes memory for communication. One process will create a memory portion which other processes can access, Te ete mule ines by te se proc Soa ree ae tom of RC ters it ot 20 ee web copled ewes pons r rr eameion dev hat cn D wet 1A salt ee con on eae machine oF wi fro nasing ca oer mah cee too pases comma wih eh or by Messrs mains: Nico pone del ding asae mee ometin 8 alox for sng ss argent es 4. V0 device management ; 1 system sls for devise managesent are request () devie, release ( device, get and set device tributes, read, write ct. «Process needs several resources in its life time, When process request for resources, request is granted if it is free otherwise request is rejected. Once request is granted, control i trmsfér to the process. 5. Information processing and maintenance « System calls for this category is set time and date, get time and date, get tem data, get system data, get and set process, file and device, 4 Most ofthe opening system provides system call for set and get the time and de. 4 This ype of sytem cal is wed for ansering information from wer to operating system and vice vers, System Programs 2.16 Write short note on system programs. ‘Ans. : + Modem operating system consists of a collection of system Programs. System program that provides an application programming. ‘environment on top of the hardware, Some of them are simply user iterfaces to system calls. They can be divided into these categories : — _____ ‘A Gnide for Engincring Students Operating Systems 1-19 Fundamental Concepts of Operating Syitere 1, File management 2. Status information 3, File modification 4, Programming language support 5, Program loading and execution 6, Communications. «File management programs are used to create, delete, copy, rename, list dump on files and directory. Stas information system programs covers the date, time, disk space, available memory and users. All this information is formatted and displayed on output device or printed. «Text editors are used for file modification. In this, new file is created and content of file is modified. Programming language support includes the compilers, assemblers, interpreters for common programming lmguage like C, CH, Java, Visual Basic. ‘For program loading and execution, it is loaded into memory then program is executed by processor. Operating system provides different types loaders and linkers to complete execution operation. « Debugging fueilty is provided by the operating system withthe help of application program, It is used for checking errors. ‘» Communication between two devices are performed by creating temporary connection. Communication is in between process, users and ther VO devices. File transfer, remote login, electronic mail, browsing ‘web, downloading multimedia data are the example-of communication. —— 1.7 : BASH Shell Scripting Q.47 What is Linux BASH shell ? ‘Ans. © The Linux Bash is also known as ‘Boure-again Shell’ It is ‘command language interpreter for the Linu based system. It is & replacement of Bourne shell (sh), ©The Limo/Unix shell allows us to interact with the Linux system through the commands, It let us invoke an executable file to create a running process. exons “Gd for Engineering Suter © scanned with OKEN Scanner operating yates 1-20 __ Fundamental COneps of Oper Syston the Linw file system, It is designed i uch vay tha we can pnfrm al he Lim operations troogh Bash, «The Bath is command language interpreter as well a8 & proBrammning les, functions, and flow contr Smee ei cae an a Bile, which i ale bell ert ait the folowing shell commands wit example. Tt also allows ns to interact with a Fa ee Soe 11) Ghmod : Access permissions associated with @ file or ditectory Aw cat Ne cman Feb se ey own le ‘with the following permissions : 1:20 prime.c sere omen + Here, ‘w= indieates File Owner, ‘4! = indicates thatthe persion is to be given, | ad pemission and primeic isthe filename, 1) Grap : tt stands for “Get Regular Expression and Print”. The erep command allows user to search one file or multiple files for lines that contain a pattern. The syntax i ‘tp [options] pattem {files} "f= indicates the Operating Systems 1-21 Fundamental Concepts of Operating System ti) Cat ‘©The eat command will also display file contents to a screen file ‘contents to'a sereen Syntax : cat filename ‘Also, use cat for quickly creating @ short fle, by entering the following Scat > floname ‘After pressing the retum Key, type in the text. To save and exit the file, press CTRL-D. ‘An additional feature of eat is that it allows you to concatenate two files together by entering the following + ‘cat Sle 1 >> Blo2 ‘This command appends file 1 to end of fle 2 Wy) Sort = ‘The sort utility sorts the lines in a file. By default, it sorts the fle in [ASCII order, with numbers preceding alphabetic characters. Syntax : sort flenamé You can also use the sort command in combination with other commands using pipes. To sort the output from a who command, enter $ who | sor, 19 Explain the significance of following shell commands 4) ini) we iif) umask iv) ent v) grep ‘Ans. :1) in: # The in command is used to create links. Links are kin of shortcuts to other files. The general form of command is: S In TARGET LINK_NAME # There are two types of links, soft links and herd links. By default, hard links are created. If you want to create soft link use -5 option, In this example, both types of links are created forthe file ustlisting. 5 In ustisting hard tink S In-sustisting sof fink Sis total 12 A Guide for Engineering Stade 1 Gale for Enghcering Suen, excones © scanned with OKEN Scanner | i anamett Comers oF OPEEE Spon | Opting Sytems 1-28 Furdamntel Concepts of Operating Sees yerating Systems 1-2 or 9 70124706 1620 fel columns fiom a line by specifying @ deter or you can select a tot raghut - on of text by specif ‘the range or characters. Fer Se ns 420 8 «say tou cme ses he od nace he rect 2g gh 49] 20147-06143 Pai § cut [of flename] * 07-09 14:00 soft link ust yates charac 1 1 rag rag 10 2012 - -f field no ‘ 1 491 2012-07-06 16:02 usreopy 1 rag ag 4 flo separator 1 2012-07-06 1423 ustlisting apwerere 2 raghu raghu. 491 $ cut -c2-5 sample a orm 2 to 5 from fle sample. 1) we was a cus characters fom 2 to wwe: Coating the numberof eros wy grep : Refer QA syntax: we Ff] #8 (0.20 Explain the folowing shel commands with example : Options : 4) echo ii) grep iii) touch Iv) Is. cw : Gives the word court int 1: Couns the umber of lines 4) echo : coho is a built-in command in the bash and C shells that writes “ Comt the ber of characters. its argumens to standard ouput. The syntaxfor echo is -* ‘echo [option(s)] [string(s)) aranetes the command displays all the Hegre rent —— ae «A string is any nite sequence of characters (ie, leters, ‘numerals, symbols and punctuation marks) i) grep : Refer Q18. j)touch : The touch command allows us to update the timestamps on courts, fi) umask : unber which defies the default permissions which are not nis i ¢ 8 wre even on fle, A umask of 022 means not to give the wrt emission to the group(02) and oters(022) by default essing les and rete ws well seeing non, empty fe IF 1¢ file permissiox ‘user are a Terminal - savvy person, user can quickly create a new file ‘eThe umask command automatically sets the file permissions upon] — Ft Sr nand line through the following command : : creation ofthe file. Vaan The command changes inital Permission of newly crested fle. Woe lie ts coma of a clicky an tg cesxy ts ghre, The wae ofthe argument can be ealcuated by subtracting the mode | then the contents ofthe curent working directory are displayed. So, if ‘you want as defini fom the curent default mode. the current working directory is / + Assume the curent default mode is 0666 and you want it as 0644 then siceiaie 666 - 644 ~ 022 wil be the parameter which we have to pass with| * Actually, Is doesnt show you all the emis in a directory - Files umask command, and directories that begin witha dot () are hidden. The reason for Sumask 0» sets default mode which is 0666 this is that files that begin with a. usually contsin important a configuration information and should not be changed under normal circumstances. Cut command in unix (or linus) is used to select sections of text from ach line of files. You can use the cut command to select fields or SS “A Gul for Engincering Students A Gul for Engineering Suda © scanned with OKEN Scanner pmting stn _ 1-04 _ Feat Cover of Oper Spin Open utes SF ‘21 State command Ine argument in Shell with example vase Arguments or varios may be passed 10 sell xp. Sinply fase pone te command ne Whee sg @ bell ser, fy ee ater, $0 ite ame of command an (otal the ne og wre oe eve fie; SI iste ist argument, S2 isthe second argumen, 3 is the thd argument whe variable $4 coins te number of command TiDe arguments thy Tee pnd andthe varable S* coma all th argUMERS a ony, we ple $# repos the munber of command Hine SIUMERS pase to he sell erpt prog crane a eel sei (0 pint all argument with script name Banu» Come 6 Sel 2 fect i ie cere ‘sing following coatet # vim comilina sh #ifointoaeh echo Sxipt Name: "$0" ‘echo Total Number of Argument Passed: '$#" Process Management 2.1: Process Concept we between a process and 2 program. ‘ans: « Process is an active entity that requires a set of respwoss, Ant fing pocessor, program counter, registers to perform its function Mulple processes may be associated with one program « Process means a program in execution. Process execution in sequential order, pifferenco betwoen Process and Program : Qt Define process. Different must progress Process echo Arguments List ~ ocho 1 $1 sai is wave cuty. Eppa is pans ely one proces is ave eny. | Rogam 1 posi ea | eas ‘Process ise sequerce of | Progra contins he | comes oni nent eeu, incon. i “Process exists ina A progta ei a single | Timited span of tine, pln a contimies «| END... 7 ist | Process is a dynamic Program isa static ently. Ee ein. eas) 2 How PCR helps in process state management ? Explain the structure of PCB. Ans, : Process control block + Operating system keeps an intemal data structure to describe each process it manages, When OS creates process, it ereates this process “at fo Bagg Se a © scanned with OKEN Scanner Process Mona Operating Spree 222 Nt script. tn some operstig [os entation system, it_ calle Process Contr! Boece, Fg 021 00 | peaynme process contro Block « Process control block will change | Program counter }-—__——____ acconting to the operating system. PCB is also called task control | Memory allocation Dlock. js ©The PCB is identified by an | yO status information integer Process ID (PID). When a ig, }—_________] process is ruming, its hardware [7 | seat is inside the CPU. When the | st ofoPen Hes OS stops runing «process it | omtomaion | saves the registers values in the PCB When a process is created by ‘operating. system, it allocates a PCB for it. OS initializes PCB and puts PCB on the correct queue Following information is stored in Fig. Q.24 Process’ control block process control block, 1. Process Identifiation : Each process. is uniquely identified by ty ‘ser’ identification and a pointer connecting it to its descriptor. Priority number : Operating system allocates the priority mamber each process. According to the priority mumber it allocates ty | Program counter : The PC indicates the address of the net instruction to be executed for this eurent process, Memory allocation : It contains the value of the base register, limit register and the page tables depending on the memory systea used by the operating system. {VO status information + It maintains information sbout the ope files, list of VO devices allocated to the process ete. —— So A Gale for Engineering Srudets Number of registers Process state 2 rs Process Management cpeting Ste Te tin of " of files for operation. ust of open es + Proce wer mamber of 6 et erscngmem keeps of a opened ile by this Pose a Pracsy sate: Pres may e in anyone of te tae TREY rosin at ana mint cas Draw and explain proces state diagram. stich indicates what process each process hasan exciton sate which indicate i ‘The process descriptor is the basic data structure used i shows 8 process Ans. is curently doing. fo represent the specific state foreach proces. Fi. state diagram. CControted by Biren Job scheduler ~.___CPU scheduler Fig. Q.3.1 Process state diagram ‘© The process states are as follows 11. New : Operating system creates new process by using fork{ ) system call, These process are newly created process and resources are not allocated. Ready : The process is competing for the CPU. Process reaches to the head of the list (queue). . Running : The process that is currently being executed. Operating system allocates all the hardware and software resources 10 the process for execution. 1 Guide or Engincring Stdents @ scanned with OKEN Scanner Process Manager Blocked / Waiting : + sch a8 the completion of aa input-output operation process | 5. Exit / End : A process is completes is operations and releases 1 | 22: Process Operati process. Q4 Explain process creat creates the process in following situations Ans. « Operating system 1. Starting of new bateh job, 2, User request for creating new process. 3. To provide new services by OS. 4 System call from currently running prove | pening este cress anew process withthe specified or dei arertee nd identifier. A process may creat several ew sb-proces, «Parent process is renting process and the new processes are called thy children ofthe process. When operating system creates proces, it build the data structure for managing process and allocates address space ig primary main memory. | « Operating system creates foreground and background process. Process a identified by nique proces idetifer (PID) in UNIX and window operating system PID value isan integer number. ] All processes in UNIX are crested using the Zork( system call The) feng recess is called the parent process. The new process is calle the cil process + Boh the parent and child process have their own and private memory, Open ies at shared between paret and child If te parent changes the value of is variable, the modification wll only afet the variable in the parent process's address space, Othe address spaces cated by for) call will not be affeted eventhough they fave denice variable names. =—______} Gilford re ring util some evert gy), peeing Sotens 2s Process Management 1s Whon a process is created, OS assigns some atibutes. These are priority, privilege level, requirement of memory, access right, memory protection, PID ete. To perform operation, process needs software and hardware resources. It includes CPU time, files, memory, 10 device. « Relation between parent process and child process is as follows : 1. Parent process continues to execute concurrently with its child process. Parent process waits until some or all of its children have terminated, void main ) ‘ print{(Operating Systom\n'); fork) print(("Tochnical Publications\n'); roturn 0; } «# In above program Operating System is printed only once and Technical Publications is printed two times 5 List the four events that cause processes to be created, Explain cench in bri ‘Ans, There are four events that cause processes to be created they are 1, System initialization (Process creation at boot time), 2, Execution of a process ereation system call by a running process, 3. A user request to create a new process, 4, Initiation of a batch job. «Several processes are created when the computer is booted. ‘Process Creation System Call : A running process issue system calls to create one or more new processes to help it do its job. When the work can be divided between several related, but otherwise independent imeracting processes. For example, a process fetches data from the internet and stores it in a shared buffer, another process, processes this date, “A Gue for Empincelng Staens @ scanned with OKEN Scanner _ 26 Process Manegemey, sof process terminstion. al execution then that ‘Ans. : © When process Snishes is nom Process i, a a delete tha process using exit () system terminate, Operating OT ony space becomes fee a ‘After deleting process, memory anos pases the ids et st fo he pat oes a eh ia the process, At the sare ine dealer all the resources held thi press. «Felling are he varios esos for povess termi 1. Normal completion of operation 2. Memary iso valle 3. Tine sce exited 4. Psat terion 5. Failure of 10 66, Request from parent process 7, Misuse of acces its | [23 :Process Scheduling | 27 befine the folowing | a) Scheduling queue b) Device queue) Ready queue | sree) Seedulng queue: Sealing qt GHEE of PDE ‘rapa dvs When he wer poss exes at the ay, thy, saree job que. ob quee canis fall resis ofthe stem, | b) Deviee queue : Device queue is @ queue for which mull proveses ae ving fr a purcuar UO device, Tach device hy) maintained its own device queue | ¢) Ready queue : The processes which are ready and waiting ty execute are kept in the ready queue, Ready queue is stored in main (0.6 Explain various Feast! Operating Stems 27 Process Menagenert | Qe Explain diferent types of schedulers in operating system. ‘Ans. + Schedulers are used to handles process scheduling, It is one type of system software and selects the jobs fom the system and decide which process t rin. Schedulers are of thee types - 1. Long term scheduler 2, Short tem scheduler 4. Medium ter scheduler «Fig. Q8.1 shows queueing diagram for process scheduling Long em eeedng Vw pocnann | Racine =| 4} Jelefefe;-seetem | cies, |e ene Sy] en cana fy Teo i me ara _| evr ria | Ss— ve 75, competed Request fr i) os Guta jon Eins tem | SaaS SSS © scanned with OKEN Scanner i ; Process Mergen, ‘ peat Sytoms ES = operating Systems 9 Long term scheduler , Long term scheduler is also called job scheduler. I determines whick| qq Explain concept of context switehing with the help of neat process are admited tothe system for processing. res are selected) giagram- from the queue and loads into the main ‘memory for execution. | Fig. Q.9.1 shows context switching, the degree of multprogramming jy ‘mimoed mix of jobs, ch as 10| ‘Long term scheduling contols mulltasking systems. It provides @ bound and CPU bound. i ‘ running fJ Process preemetion Ready jn seal time operating system. Time 1110 operation ‘Long tenn scheduling i wsed | rm scheduler. | ———<—— ‘Save the process image for Pt T ‘sharing operating system has 0 Tong (1 Medium torm scheduler swapping finetion. Sometimes i «Medium teem scheduler is pat of swapping L — removes the process fom memory. It aso reduces the degree ofp caayor Tad the procass image for P2 sualprogamming. tack is in memory then opera ‘eIf process makes an 1/0 request and it as * ting. ‘Save the process image for P2 ey mig 10s lt oe Fees = ~ es suspended tenant make any progress towards completion ~~ i = process is removed from memory and makes fee) Running [oad the process image for P7 in this sination, the space for ober process The suspended process is sored inthe secondary storage device ix turd disk. This process is called swapping. +A context switch is the switching of the CPU fiom one process or ‘oe tore cnt thread to another, A context is the contents of a CPUS registers and ‘s Short tem scheduler is also called CPU scheduler. Tt selects the process | program counter a eny point in ‘time. from que whch are ready 10 eneoue and allcue the CPU far| Switching the CPU to another process requires perfoming 2 site v= of the current process and a state restore of a different process. This task is known as a context switch, ‘exceution, «Shore ten scheduler is faster that long term scheduler. This scheduler ‘© A context switch can mean a register context switch, a task context | switch, a thread context switch or a process context switch. rakes scheduling decisions much more frequently than the long-term or mid-term schedulers, | A scheduling decision will at a minimum have to be made after every | time slice, and these are very short. Iris also known es dispatcher. | ig. 0.9.1 Context switching © A register is a small amount of very fast memory inside of a CPU that js used to speed the execution of computer programs by providing quick access to commonly used values. A program counter is a specialized register that indicates the position of 2 the CPU in its instruction sequence and which holds either the address eecoees “A Guide for Engineering Studenss (a7 “A Gn for Engineorng Students © scanned with OKEN Scanner periting Stes 2.10 Proce Menage og exeoted or he ales of the MEX inst, the specific system. scribed in more deta as the Kem tes wih regard 10 PROCESSES (luting of the instruction bein to be executed, depending on t + Context switehing om bed performing the following #2 threads) on the CPU : - Jon of one process and storing the Cpl, 1, Suspending the prowess are, the cone fr tat proess somber in memory, process from memory ang 2, Retrieving the context of the next restoring it inthe CPUS registers and 4 Retrning to the loetion indicated by the program counter i ord to resume the process «context swthes can over only in Kemel mode (sytem mode), Keng, trode is pivieged mode of te CPU in which only the Kemel mang tan which provides acess (0 all memory locations and all other system resources, ‘10 Explain diference between Tang fern, short term ancl medium term scheduler. ) ‘Sr.No, Long term Short term = Medium term 1. Wisjo sited, RTs GPU scheduler, Tis swapping | % sation tan Syed ey Sad een ‘Bort tm shel boa. | 5. treo the degree Lee contol over Reduce the degree | of muliprogmmning. — deget of ey | rulipogrniing, —multprogmmming. 4. Aint oc min! in Minin ote Time saving system] i shrng system, sharing tom, use medium term scheduler, Tantirapmenr ah i certo Process Managesnent Systeme TE eswlect processes It elet ftom among, Process can be | from pool and load he processes that reintroduced Into) | them into memory for are ready to execute, memory and its | execution. execution can be | continued, 6 Process tates Process state is - (Sow 19 Ready), (Ready vo Resing) Selecta new process Te Selecta good process, nix of 70 bound and for a CPU quite (CPU bound. frequently. itt What should be scheduling ertera for scheduling gorithm ? Scheduling criteria fhe system, CPU scheduling criteria will change. L Throughput : CPU scheduling should attempt to service the maximum number of processes per unit time, The higher is the ‘number, the more work is done by the system. ‘2. Waiting time + The average period of time a process spends waiting, Process is normally in the ready queue in waiting time. ‘Turnaround time : Turnaround time start from process submission to completion of process. ‘Tumaround time = Burst time + Waiting time 4. Response time : It is the time from the submission of a request until the first response is produced. It is average function of time during which the Ans. + Depending on t! CPU utilization + processor is busy Fairness + Avoid the process from the starvation, All the processes must be given equal opportunity to execute. Priority + If the operating system assigns priostis to processes, the scheduling mechanism should favor the higher priority processes. 6 A Gi for Enger Stents @ scanned with OKEN Scanner z=... SSCS Process Ma Ln ” eee sess always should sun in about the Toads, me ‘Operating Systems 8. Predictability : A given Pros amount of time under similar 151 , operations the scheduling policy + Depending upon the nature 0 a 7 a Pepente Vr tion and rough ae the SSM cays esis aft by user and Ste parameters. Fei cara eeplain aifrence beowen_ preemptive and non-preemptiyg CPU scheduling. Ans. me Nonpreemptive scheduling ‘Sr.No. Preemptive scheduling a | Pe ain tht pes Sl | RESEESGTE iene CPU ely wn i wig k taking the CPU away and its current CPU burst. Soating te oer =. pec or Nerer lng | Pen ie eecee bee ec It does not ates the design of OS feel J 3. Te alo affects the design of the operating system Kernel 4 Freempeivesebeling is nore Simple, but very inefficen. cole 5.) Bemple Round obia Example: Fist come fist seve rca sethod a 243 Define term scheduler, scheduling and scheduling. algorithm vith expe Ans. « Schedoler + Schedules are wed t0 handles process scheduling 1 on pe fs ae es eas Fes een cides wish process to ran process of Selecting processes from ag. | tse gues sare ou by & scheduler. f Scheduling : In 2 muliprogramming. envionment, usually moe | roy to be executed than could possibly be ru at one time. In ) either operating Systems 21s Process Management CPU scheduling, it switches from one proces to another process, CPU resoures manageraet scheduling Algorithms : are mainly ‘Short-term sch optimize one OF decide which of (CPU is basis on service time ‘used for short-term ‘preemptive or non-preemptive ‘are also will play a role. is commonly known as scheduling Scheduling algorithms or scheduling. policies scheduling. The main objective of Jneduling is to allocate processor time in such a way a5 10 ‘more aspects of system behavior. Scheduling algorithms the processes in the ready queue is to be allocated to the the type of scheduling policy and whether that policy is For scheduling arrival time and [2.5 : Scheduling Algorithms | ats vera process execttion using fol ice - 2 units) 4) RR (Time Process R a For the table given below calculate average waiting time and ge turnaround time and draw a Gantt Chart illustrating the lowing scheduling algorithms. i) SIF (non ~ preemptive) rival Time o “A Gul for Enginccrng Suen | “A Gul for Bngneoring Stadents © scanned with OKEN Scanner

You might also like