Solution manual to Operating System concepts

solution manual for operating system by william stallings sixth edition and solution manual of operating system concepts by silberschatz 7th edition
Dr.NaveenBansal Profile Pic
Dr.NaveenBansal,India,Teacher
Published Date:25-10-2017
Your Website URL(Optional)
Comment
SOLUTION MANUAL OF OPERATING SYSTEM BY ABRAHAM SILBERSCHATZ, PETER BAER GALVIN & GREG GAGNE CHAPTER 1 Introduction Practice Exercises 1.1 Whatarethethreemainpurposesofanoperatingsystem? Answer: Thethreemainpuropsesare: Toprovideanenvironmentforacomputerusertoexecuteprograms � oncomputerhardwareinaconvenientandefficientmanner. To allocate the separate resources of the computer as needed to � solve the problem given. The allocation process should be as fair andefficientaspossible. � Asacontrolprogramitservestwomajorfunctions:(1)supervision oftheexecutionofuserprogramstopreventerrorsandimproperuse of the computer, and (2) management of the operation and control of I/Odevices. 1.2 Wehavestressedtheneedforanoperatingsystemtomakeefficientuse of the computing hardware. When is it appropriate for the operating system to forsake this principle and to “waste” resources?Why is such asystemnotreallywasteful? Answer: Single-user systems should maximize use of the system for the user. A GUI might “waste” CPU cycles, but it optimizes the user’s interaction withthesystem. 1.3 Whatisthemaindifficultythataprogrammermustovercomeinwriting anoperatingsystemforareal-timeenvironment? Answer: Themaindifficultyiskeepingtheoperatingsystemwithinthefixedtime constraintsofareal-timesystem.Ifthesystemdoesnotcompleteatask inacertaintimeframe,itmaycauseabreakdownoftheentiresystemit isrunning.Thereforewhenwritinganoperatingsystemforareal-time system,thewritermustbesurethathisschedulingschemesdon’tallow responsetimetoexceedthetimeconstraint. 1 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/2 Chapter1 Introduction 1.4 Keepingin mind the various definitions of operating system, consider whethertheoperatingsystemshouldincludeapplicationssuchasWeb browsersandmailprograms.Argueboththatitshouldandthatitshould not,andsupportyouranswers. Answer: An argument in favor of including popular applications with the operating system is that if the application is embedded within the operating system, it is likely to be better able to take advantage of features in the kernel and therefore have performance advantages over an application that runs outside of the kernel. Arguments against embeddingapplicationswithintheoperatingsystemtypicallydominate however: (1) the applications are applications - and not part of an operating system, (2) any performance benefits of running within the kernel are offset by security vulnerabilities, (3) it leads to a bloated operatingsystem. 1.5 Howdoesthedistinctionbetweenkernelmodeandusermodefunction asarudimentaryformofprotection(security)system? Answer: The distinction between kernel mode and user mode provides a rudi- mentaryformofprotectioninthefollowingmanner.Certaininstructions couldbeexecutedonlywhentheCPUisinkernelmode.Similarly,hard- waredevicescould be accessedonly when the programis executingin kernelmode.Controloverwheninterruptscouldbeenabledordisabled isalsopossibleonlywhenthe CPUisinkernelmode.Consequently,the CPU has very limited capability when executing in user mode, thereby enforcingprotectionofcriticalresources. 1.6 Whichofthefollowinginstructionsshouldbeprivileged? a. Setvalueoftimer. b. Readtheclock. c. Clearmemory. d. Issueatrapinstruction. e. Turnoffinterrupts. f. Modifyentriesindevice-statustable. g. Switchfromusertokernelmode. h. Access I/Odevice. Answer: Thefollowingoperationsneedtobeprivileged:Setvalueoftimer,clear memory,turnoffinterrupts,modifyentriesindevice-statustable,access I/Odevice.Therestcanbeperformedinusermode. 1.7 Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the user job or the operating system itself. Describe two difficulties that you think couldarisewithsuchascheme. Answer: For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/PracticeExercises 3 Thedatarequiredbytheoperatingsystem(passwords,accesscontrols, accountinginformation,andsoon)wouldhavetobestoredinorpassed through unprotected memory and thus be accessible to unauthorized users. 1.8 Some CPUs provide for more than two modes of operation. What are twopossibleusesofthesemultiplemodes? Answer: Although most systems only distinguish between user and kernel modes, some CPUs have supported multiple modes. Multiple modes could be used to provide a finer-grained security policy. For example, rather than distinguishing between just user and kernel mode, you could distinguish between different types of user mode. Perhaps users belonging to the same group could execute each other’s code. The machine would go into a specified mode when one of these users was running code. When the machine was in this mode, a member of the groupcouldruncodebelongingtoanyoneelseinthegroup. Anotherpossibilitywouldbetoprovidedifferentdistinctionswithin kernelcode.Forexample,aspecificmodecouldallowUSBdevicedrivers to run. This would mean that USB devices could be serviced without havingtoswitchtokernelmode,therebyessentiallyallowingUSBdevice driverstoruninaquasi-user/kernelmode. 1.9 Timers could be used to compute the current time. Provide a short descriptionofhowthiscouldbeaccomplished. Answer: A program could use the following approach to compute the current time using timer interrupts. The program could set a timer for some timeinthefutureandgotosleep.Whenitisawakenedbytheinterrupt, it could update its local state, which it is using to keep track of the number of interrupts it has received thus far. It could then repeat this process of continually setting timer interrupts and updating its local statewhentheinterruptsareactuallyraised. 1.10 Givetworeasonswhycachesareuseful.Whatproblemsdotheysolve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), whynotmakeitthatlargeandeliminatethedevice? Answer: Caches are useful when two or more components need to exchange data,andthecomponentsperformtransfersatdifferingspeeds.Caches solvethe transferproblemby providingabuffer ofintermediatespeed betweenthecomponents.Ifthefastdevicefindsthedataitneedsinthe cache,itneednotwaitfortheslowerdevice.Thedatainthecachemust bekeptconsistentwiththedatainthecomponents.Ifacomponenthas adatavaluechange,andthedatumisalsointhecache,thecachemust alsobeupdated.Thisisespeciallyaproblemonmultiprocessorsystems wheremorethanoneprocessmaybeaccessingadatum.Acomponent may be eliminated by an equal-sized cache, but only if: (a) the cache andthecomponenthaveequivalentstate-savingcapacity(thatis,ifthe component retainsitsdatawhenelectricityisremoved,thecache must For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/4 Chapter1 Introduction retaindataaswell),and(b)thecacheisaffordable,becausefasterstorage tendstobemoreexpensive. 1.11 Distinguish between the client–server and peer-to-peer models of distributedsystems. Answer: The client-server model firmly distinguishes the roles of the client and server.Under this model,the client requestsservices that are provided by the server. The peer-to-peermodel doesn’t have such strict roles. In fact, all nodes in the system are considered peers and thus may act as either clients or servers—or both. A node may request a service from another peer, or the node may in fact provide such a service to other peersinthesystem. For example, let’s consider a system of nodes that share cooking recipes. Under the client-server model, all recipes are stored with the server.Ifaclientwishestoaccessarecipe,itmustrequesttherecipefrom thespecifiedserver.Usingthepeer-to-peermodel,apeernodecouldask other peer nodes for the specified recipe. The node (or perhaps nodes) withtherequestedrecipecouldprovideittotherequestingnode.Notice howeachpeermayactasbothaclient(itmayrequestrecipes)andasa server(itmayproviderecipes). For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/Operating- CHAPTER 2 System Structures Practice Exercises 2.1 What is the purpose of system calls? Answer: Systemcallsallowuser-levelprocessestorequestservicesoftheoperat- ing system. 2.2 What are the five major activities of an operating system with regard to process management? Answer: The five major activities are: a. The creation and deletionof both user and system processes b. The suspension and resumption of processes c. The provision of mechanisms for process synchronization d. The provision of mechanisms for process communication e. The provision of mechanisms for deadlock handling 2.3 What are the three major activities of an operating system with regard to memory management? Answer: The three major activities are: a. Keeptrackofwhichpartsofmemoryarecurrentlybeingusedand by whom. b. Decide which processes are to be loaded into memory when memory space becomes available. c. Allocate and deallocate memory space as needed. 2.4 What are the three major activities of an operating system with regard to secondary-storage management? Answer: The three major activities are: 5 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/6 Chapter2 Operating-System Structures Free-space management. • Storage allocation. • Disk scheduling. • 2.5 What is the purpose of the command interpreter? Why is it usually separate from the kernel? Answer: Itreadscommandsfromtheuserorfromafileofcommandsandexecutes them,usuallybyturningthemintooneormoresystemcalls.Itisusually notpartofthekernelsincethecommandinterpreterissubjecttochanges. 2.6 Whatsystemcallshavetobeexecutedbyacommandinterpreterorshell in order to start a new process? Answer: In Unix systems, a fork system call followed by an exec system call need tobeperformedto startanewprocess.The forkcall clones thecurrently executing process,while the exec call overlays anew process based on a differentexecutable over the calling process. 2.7 What is the purpose of system programs? Answer: System programs can be thought of as bundles of useful system calls. They provide basic functionality to users so that users do not need to write their own programs to solve common problems. 2.8 What is the main advantage of the layered approach to system design? What are the disadvantages of using the layered approach? Answer: As in all cases of modular design, designing an operating system in a modular way has several advantages. The system is easier to debug and modify because changes affect only limited sections of the system rather than touching all sections of the operating system. Information is kept only where it is needed and is accessible only within a defined and restricted area, so any bugs affecting that data must be limited to a specific module or layer. 2.9 Listfiveservicesprovidedbyanoperatingsystem,andexplainhoweach createsconvenienceforusers.Inwhichcaseswould itbeimpossiblefor user-levelprograms to provide these services?Explain your answer. Answer: The five services are: a. Program execution. The operating system loads the contents (or sections)ofafileintomemoryandbeginsitsexecution.Auser-level program could not be trusted to properly allocate CPU time. b. I/Ooperations.Disks,tapes,seriallines,andotherdevicesmustbe communicatedwithataverylowlevel.Theuserneedonlyspecify the device and the operation to perform on it, while the system convertsthatrequestintodevice-orcontroller-specificcommands. User-level programs cannot be trusted to access only devices they For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/PracticeExercises 7 should have access to and to access them only when they are otherwise unused. c. File-systemmanipulation.There are many detailsin file creation, deletion, allocation, and naming that users should not have to perform.Blocksofdiskspaceareusedbyfilesandmustbetracked. Deleting a file requires removing the name file information and freeing the allocated blocks. Protections must also be checked to assure proper file access. User programs could neither ensure adherence to protection methods nor be trusted to allocate only free blocks and deallocate blocks on file deletion. d. Communications. Message passing between systems requires messages to be turned into packets of information, sent to the networkcontroller,transmittedacrossacommunicationsmedium, and reassembled by the destination system. Packet ordering and data correction must take place. Again, user programs might not coordinate access to the network device, or they might receive packets destined for other processes. e. Error detection. Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspectedtoensurethatdatahavenotbeencorruptedintransit.All data on media must be checked to be sure they have not changed since they were written to the media. At the software level,media must be checked for data consistency; for instance, whether the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently process- independent(forinstance,thecorruptionofdataonadisk),sothere must be a global program (the operating system) that handles all types of errors. Also, by having errors processed by the operating system,processesneednotcontaincodetocatchandcorrectallthe errors possible on a system. 2.10 Why do some systems store the operating system in firmware, while others store it on disk? Answer: For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system may be not be available for the device. In this situation, the operating system must be stored in firmware. 2.11 Howcouldasystembedesignedtoallowachoice ofoperatingsystems from which to boot? What would the bootstrap program need to do? Answer: Consider a system that would like to run both Windows XP and three different distributions of Linux (e.g., RedHat, Debian, and Mandrake). Each operatingsystemwillbe storedondisk.During systemboot-up, a special program (which we will call the boot manager) will determine which operating system to boot into. This means that rather initially booting to an operating system, the boot manager will first run during systemstartup.Itisthisbootmanagerthatisresponsiblefordetermining which system to boot into. Typically boot managers must be stored at For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/8 Chapter2 Operating-System Structures certainlocationsoftheharddisktoberecognizedduringsystemstartup. Bootmanagersoftenprovidetheuserwithaselectionofsystemstoboot into; boot managers are also typically designed to boot into a default operating system if no choice is selectedby the user. For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/CHAPTER 3 Processes Practice Exercises 3.1 Using the program shown in Figure 3.30, explain what the output will beatLine A. Answer: The result is still 5 as the child updates its copy of value.When control returnstotheparent,itsvalueremainsat5. 3.2 Includingtheinitialparentprocess,howmanyprocessesarecreatedby theprogramshowninFigure3.31? Answer: Thereare8processescreated. 3.3 Original versions of Apple’s mobile iOS operating system provided no meansofconcurrentprocessing.Discussthreemajorcomplicationsthat concurrentprocessingaddstoanoperatingsystem. Answer: FILL 3.4 TheSunUltraSPARCprocessorhasmultipleregistersets.Describewhat happens when a context switch occurs if the new context is already loadedinto one of the registersets. What happens if the new context is in memory rather than in a register set and all the register sets are in use? Answer: The CPU current-register-set pointer is changed to point to the set containingthenewcontext,whichtakesverylittletime.Ifthecontextis in memory, one of the contexts in a register set must be chosen and be moved to memory, and the new context must be loaded from memory into the set. This process takes a little more time than on systems with onesetofregisters,dependingonhowareplacementvictimisselected. 3.5 Whenaprocesscreatesanewprocessusingthefork()operation,which ofthefollowingstateissharedbetweentheparentprocessandthechild process? a. Stack 9 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/10 Chapter3 Processes b. Heap c. Sharedmemorysegments Answer: Only the shared memory segments are shared between the parent process and the newly forked child process. Copies of the stack and theheaparemadeforthenewlycreatedprocess. 3.6 WithrespecttotheRPCmechanism,considerthe“exactlyonce”semantic. Does the algorithm for implementing this semantic execute correctly even if the ACK message back to the client is lost due to a network problem? Describe the sequence of messages and discuss whether “exactlyonce”isstillpreserved. Answer: The “exactly once” semantics ensure that a remore procedure will be executed exactly once and only once. The general algorithm for ensuring this combines an acknowledgment (ACK)schemecombined with timestamps (or some other incremental counter that allows the servertodistinguishbetweenduplicatemessages). The general strategy is for the client to send the RPC to the server along with a timestamp. The client will also start a timeout clock. The clientwillthenwaitforoneoftwooccurrences:(1)itwillreceiveanACK from the server indicating that the remote procedure was performed, or (2) it will time out. If the client times out, it assumes the server was unabletoperformtheremoteproceduresotheclientinvokesthe RPCa second time, sending a later timestamp. The client may not receive the ACK for one of two reasons: (1) the original RPC was never received by the server, or (2) the RPC was correctly received—and performed—by theserverbutthe ACKwaslost.Insituation(1),theuseofACKsallows the server ultimately to receive and perform the RPC. In situation (2), the server will receive a duplicate RPC and it will use the timestamp to identify it as a duplicate so as not to perform the RPC a second time. It isimportanttonotethattheservermustsendasecond ACKbacktothe clienttoinformtheclienttheRPChasbeenperformed. 3.7 Assume that a distributed system is susceptible to server failure. What mechanisms would be required to guarantee the “exactly once” semanticsforexecutionof RPCs? Answer: The server should keep track in stable storage (such as a disk log) information regarding what RPC operations were received, whether they were successfully performed, and the results associated with the operations. When a server crash takes place and a RPC message is received, the server can check whether the RPC had been previously performed and therefore guarantee “exactly once” semanctics for the executionof RPCs. For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/CHAPTER 4 Threads Practice Exercises 4.1 Providethreeprogrammingexamplesinwhichmultithreadingprovides betterperformance than asingle-threadedsolution. Answer: a. A Web serverthat serviceseach requestina separate thread. b. A parallelized application such as matrix multiplication where differentpartsof the matrixmay be worked on in parallel. c. An interactive GUI program such as a debugger where a thread is usedtomonitoruserinput,anotherthreadrepresentstherunning application, and a third threadmonitors performance. 4.2 What are two differences between user-level threads and kernel-level threads?Underwhat circumstances isone typebetterthan the other? Answer: a. User-levelthreadsare unknown bythe kernel,whereasthe kernel isaware of kernelthreads. b. On systems using either M:1 or M:N mapping, user threads are scheduled by the thread library and the kernel schedules kernel threads. c. Kernelthreadsneednotbeassociatedwithaprocesswhereasevery user thread belongs to a process. Kernel threads are generally more expensive to maintain than user threads as they must be representedwith akerneldatastructure. 4.3 Describetheactionstakenbyakerneltocontext-switchbetweenkernel- levelthreads. Answer: Context switching between kernel threads typically requiressaving the value of the CPU registers from the thread being switched out and restoring the CPU registersof the new thread being scheduled. 11 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/12 Chapter4 Threads 4.4 What resources are used when a thread is created? How do they differ fromthose usedwhen aprocess iscreated? Answer: Because a thread is smaller than a process, thread creation typically uses fewer resources than process creation. Creating a process requires allocating a process control block (PCB), a rather large data structure. The PCB includes a memory map, list of open files, and environment variables. Allocating and managing the memory map is typically the most time-consuming activity. Creating either a user or kernel thread involves allocating a small data structure to hold a register set, stack, and priority. 4.5 Assume that an operating system maps user-levelthreads to the kernel using the many-to-many model and that the mapping is done through LWPs. Furthermore, the system allows developers to create real-time threads for use in real-time systems. Is it necessary to bind a real-time threadto an LWP? Explain. Answer: Yes. Timing is crucial to real-time applications. If a thread is marked as real-time but is not bound to an LWP, the thread may have to wait to be attached to an LWP before running. Consider if a real-time thread is running (is attached to an LWP) and then proceeds to block (i.e. must perform I/O, has been preempted by a higher-priority real-time thread, iswaitingforamutualexclusionlock,etc.)Whilethereal-timethreadis blocked,the LWPitwasattachedtohasbeenassignedtoanotherthread. Whenthereal-timethreadhasbeenscheduledtorunagain,itmustfirst wait to be attached to an LWP.Bybindingan LWP to a real-time thread youareensuringthethreadwillbeabletorunwithminimaldelayonce itisscheduled. For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/CHAPTER 5 Process Synchronization Practice Exercises 5.1 In Section 5.4, we mentioned that disabling interrupts frequently can affect the system’s clock. Explain why this can occur and how such effectscanbeminimized. Answer: Thesystemclockisupdatedateveryclock interrupt.Ifinterruptswere disabled—particularly for a long period of time—it is possible the system clock could easily lose the correct time. The system clock is alsousedforschedulingpurposes.Forexample,thetimequantumfora processisexpressedasanumberofclockticks.Ateveryclockinterrupt, theschedulerdeterminesifthetimequantumforthecurrentlyrunning process has expired. If clock interrupts were disabled, the scheduler couldnotaccuratelyassigntimequantums.Thiseffectcanbeminimized bydisablingclockinterruptsforonlyveryshortperiods. 5.2 Explain why Windows, Linux, and Solaris implement multiple locking mechanisms. Describe the circumstances under which they use spin- locks, mutex locks, semaphores, adaptive mutex locks, and condition variables.Ineachcase,explainwhythemechanismisneeded. Answer: Theseoperatingsystemsprovidedifferentlockingmechanismsdepend- ing on the application developers’ needs. Spinlocks are useful for multiprocessor systems where a thread can run in a busy-loop (for a shortperiodoftime)ratherthanincurringtheoverheadofbeingputin a sleep queue. Mutexes are useful for locking resources. Solaris 2 uses adaptive mutexes,meaning that the mutex is implementedwith a spin lock on multiprocessor machines. Semaphores and condition variables are more appropriate tools for synchronization when a resource must beheldfor alongperiodoftime,since spinningisinefficientfora long duration. 5.3 What is the meaning of the term busy waiting? What other kinds of waitingarethereinanoperatingsystem?Canbusywaitingbeavoided altogether?Explainyouranswer. 13 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/14 Chapter5 ProcessSynchronization Answer: Busywaitingmeansthataprocessiswaitingforaconditiontobesatisfied in a tight loop without relinquishing the processor. Alternatively, a process could wait by relinquishing the processor, and block on a condition and wait to be awakened at some appropriate time in the future.Busywaitingcanbeavoidedbutincurstheoverheadassociated with putting a process to sleep and having to wake it up when the appropriateprogramstateisreached. 5.4 Explainwhyspinlocksarenotappropriateforsingle-processorsystems yetareoftenusedinmultiprocessorsystems. Answer: Spinlocks are not appropriate for single-processor systems because the conditionthatwouldbreakaprocessoutofthespinlockcanbeobtained onlybyexecutingadifferentprocess.Iftheprocessisnotrelinquishing the processor, other processes do not get the opportunity to set the program condition required for the first process to make progress. In a multiprocessorsystem,otherprocessesexecuteonotherprocessorsand thereby modify the program state in order to release the first process fromthespinlock. 5.5 Show that, if the wait() and signal() semaphore operations are not executedatomically,thenmutualexclusionmaybeviolated. Answer: A wait operation atomically decrements the value associated with a semaphore. If two wait operations are executed on a semaphore when itsvalueis1,ifthetwooperationsarenotperformedatomically,thenitis possiblethatbothoperationsmightproceedtodecrementthesemaphore value,therebyviolatingmutualexclusion. 5.6 Illustrate how a binary semaphore can be used to implement mutual exclusionamong nprocesses. Answer: Thenprocessesshareasemaphore,mutex,initializedto1.Eachprocess P isorganizedasfollows: i do wait(mutex); / critical section / signal(mutex); / remainder section / while (true); For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/CHAPTER 6 CPU Scheduling Practice Exercises 6.1 A CPU-scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many different schedules are possible? Give a formula intermsof n. Answer: n(nfactorial= n× n–1× n–2×...×2×1). 6.2 Explainthedifferencebetweenpreemptiveandnonpreemptiveschedul- ing. Answer: Preemptiveschedulingallowsaprocesstobeinterruptedinthemidstof its execution, taking the CPU away and allocating it to another process. Nonpreemptive scheduling ensures that a process relinquishes control ofthe CPUonlywhenitfinisheswithitscurrent CPUburst. 6.3 Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use nonpreemptive scheduling, and base all decisionson the informationyou haveatthe timethe decisionmustbe made. Process ArrivalTime BurstTime P 0.0 8 1 P 0.4 4 2 P 1.0 1 3 a. What is the average turnaround time for these processeswith the FCFSschedulingalgorithm? b. What is the average turnaround time for these processeswith the SJFschedulingalgorithm? c. The SJFalgorithmissupposedtoimproveperformance,butnotice thatwechosetorunprocess P attime0becausewedidnotknow 1 15 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/16 Chapter6 CPUScheduling that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P and P are waiting during this idle time, so their waiting time 1 2 mayincrease.Thisalgorithmcouldbeknownasfuture-knowledge scheduling. Answer: a. 10.53 b. 9.53 c. 6.86 Rememberthatturnaroundtimeisfinishingtimeminusarrivaltime,so youhavetosubtractthearrivaltimestocomputetheturnaroundtimes. FCFSis11ifyouforgettosubtractarrivaltime. 6.4 What advantage is there in having different time-quantum sizes at differentlevelsofamultilevelqueueingsystem? Answer: Processes that need more frequent servicing, for instance, interactive processessuchaseditors,canbeinaqueuewithasmalltimequantum. Processes with no need for frequent servicing can be in a queue with a larger quantum, requiring fewer context switches to complete the processing,andthusmakingmoreefficientuseofthecomputer. 6.5 Many CPU-scheduling algorithms are parameterized. For example, the RR algorithm requiresa parameterto indicate the timeslice. Multilevel feedback queues require parameters to define the number of queues, the scheduling algorithms for each queue, the criteria used to move processesbetweenqueues,andsoon. These algorithms are thus really sets of algorithms (for example, the setof RRalgorithmsforalltimeslices,andsoon).Onesetofalgorithms mayincludeanother(forexample,theFCFSalgorithmistheRRalgorithm withaninfinitetimequantum).What(ifany)relationholdsbetweenthe followingpairsofalgorithmsets? a. Priorityand SJF b. Multilevelfeedbackqueuesand FCFS c. Priorityand FCFS d. RRand SJF Answer: a. Theshortestjobhasthehighestpriority. b. Thelowestlevelof MLFQis FCFS. c. FCFS givesthehighest priorityto the job having beenin existence thelongest. d. None. For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/PracticeExercises 17 6.6 Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programsandyetnotpermanentlystarve CPU-boundprograms? Answer: ItwillfavortheI/O-boundprogramsbecauseoftherelativelyshortCPU burstrequestbythem;however,theCPU-boundprogramswillnotstarve becausetheI/O-boundprogramswillrelinquishtheCPUrelativelyoften todotheir I/O. 6.7 Distinguishbetween PCSand SCSscheduling. Answer: PCS scheduling is done local to the process. It is how the thread library schedules threads onto available LWPs. SCS scheduling is the situation wheretheoperatingsystemscheduleskernelthreads.Onsystemsusing either many-to-one or many-to-many, the two scheduling models are fundamentallydifferent.Onsystemsusingone-to-one, PCSand SCS are thesame. 6.8 Assumethatanoperatingsystemmapsuser-levelthreadstothekernel using the many-to-many model and that the mapping is done through theuseof LWPs.Furthermore,thesystemallowsprogramdevelopersto create real-time threads. Is it necessary to bind a real-time thread to an LWP? Answer: Yes,otherwise auserthreadmayhave tocompete foran available LWP priortobeingactuallyscheduled.Bybindingtheuserthreadtoan LWP, thereisnolatencywhilewaitingforanavailable LWP;thereal-timeuser threadcanbescheduledimmediately. 6.9 ThetraditionalUNIXschedulerenforcesaninverserelationshipbetween priority numbers and priorities: the higher the number, the lower the priority. The scheduler recalculates process priorities once per second usingthefollowingfunction: Priority=(recent CPUusage/2)+base where base = 60 and recent CPU usage refers to a value indicating how oftenaprocesshasusedthe CPUsinceprioritieswerelastrecalculated. AssumethatrecentCPUusageforprocess P is40,forprocess P is18, 1 2 and for process P is 10. What will be the new prioritiesfor these three 3 processes when priorities are recalculated? Based on this information, does the traditional UNIX scheduler raise or lower the relative priority ofa CPU-boundprocess? Answer: The priorities assigned to the processes are 80, 69, and 65 respectively. Theschedulerlowerstherelativepriorityof CPU-boundprocesses. For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/CHAPTER 7 Deadlocks Practice Exercises 7.1 List three examples of deadlocks that are not related to a computer- systemenvironment. Answer: � Twocarscrossingasingle-lanebridgefromoppositedirections. � Apersongoingdownaladderwhileanotherpersonisclimbingup theladder. � Twotrainstravelingtowardeachotheronthesametrack. 7.2 Suppose that a system is in an unsafe state. Show that it is possible for the processes to complete their execution without entering a deadlock state. Answer: Anunsafestatemaynotnecessarilyleadtodeadlock,itjustmeansthat we cannot guarantee that deadlock will not occur. Thus, it is possible thatasysteminanunsafestatemaystillallowallprocessestocomplete withoutdeadlockoccurring.Considerthesituationwhereasystemhas 12resourcesallocatedamongprocessesP , P,and P .Theresourcesare 0 1 2 allocatedaccordingtothefollowingpolicy: Max Current Need P 10 5 5 0 P 4 2 2 1 P 9 3 6 2 Currently there are two resources available. This system is in an unsafe state as process P could complete, thereby freeing a total of 1 four resources. But we cannot guarantee that processes P and P can 0 2 complete. However, it is possible that a process may release resources before requesting any further. For example, process P could release a 2 resource, thereby increasing the total number of resources to five. This 19 For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit http://victory4sure.weebly.com/

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.