1. JobsAandBarecompletelyCPUboundprocesses.JobCrequires1unitofCPUfollowed by4timeunitsofI/O,inapatternrepeatedthrice,followedby1unitofCPU(seetable below).Foreachofthefollowingschedulingpolicies,determinethejobschedule,calculate theturnaroundtimeforeachjob,[Link] [Link],youcan assumethattheorderinthereadyqueueinA,B,[Link],Cstandsfor CPUandIstandsforI/O.
JobID A B C Arrival 0 1 2 Executionpattern CCCCCCCCCCC CCCCCCCCCCCC CIIIICIIIICIIIIC Length 10 11 16
Asanexample,thebeginningofaFIFOschedulingpolicy(withoutpreemption)wouldlook like: AAAAAAAAAABBBBBBBBBBBCxxxxCxxxxCxxxxC [Link],JobAbeganattime0andfinishedat [Link]. (a)RoundRobinwitha5unittimequantum (b)RoundRobinwitha1unittimequantum (c)SRPT(jobsizeisnextcontiguousCPUburst;1unittimequantum) (d)Fromthegivenworkload,whichoftheaboveschedulingpoliciesmaximize(s)CPU utilization(theremightbemorethanone)? (e)Fromthegivenworkload,whichoftheaboveschedulingpoliciesismostsuitedfor interactivejobs?Ifthereismorethanone,explaintheprimaryadvantageofusingoneoverthe other.
[Link],BandCstartexecuting(nearly)togetherinamultiprocessing environment,andrequire7,12and16seconds,respectively,[Link] turnaroundtimebeif (a)(nonpreemptive)ShortestJobFirstschedulingisused? (b)(preemptive)RoundRobinschedulingisused? [Link] executing,withtheoriginalprocesscreatingonechildprocess,andthisprocesscreatingone childprocess,andthisprocesscreatingonechildprocess,andsoon.HaveeachofthefirrstN1 processeswaitonitsownchildprocess'[Link] processprint1,thenextprint2,thenextprint3,andsoforth.
[Link],FirstComeFirstServe(FCFS)isattractivebecause: (a)itissimpletoimplement (b)itisfairtoallprocesses (c)itminimizesthetotalwaitingtimeinthesystem (d)itminimizestheaveragewaitingtimeinthesystem (e)itminimizestheaverageresponsetimeinthesystem (f)itminimizestheaverageturnaroundtimeinthesystem [Link],ShortestRemainingProcessingTime(SRPT)isattrac tivebecause: (a)itissimpletoimplement (b)itisfairtoallprocessesinthesystem (c)itminimizestheaveragewaitingtimeinthesystem (d)itminimizestheaverageresponsetimeinthesystem (e)itminimizesthenumberofcontextswitchesinthesystem (f)itmaximizesthenumberofcontextswitchesinthesystem [Link] thereadyqueuearepointerstothePCBs. [Link]? [Link]? [Link] duplicatepointers?
[Link]/[Link]/ OboundtasksissueanI/OoperationonceforeverymillisecondofCPUcomputingandthat eachI/[Link] [Link] utilizationforaroundrobinschedulerwhen: a.Thetimequantumis1millisecond b.Thetimequantumis10milliseconds [Link](DMA).Givetwoexamplesinwhichitisuseful. [Link] kernellevelthreadsofthesameprocess? [Link].
[Link].
[Link]/orsoftware(codeand/ordata)considerations necessarytopermitamultiprocessingOSto.... (a)spoolprocesses(jobs). (b)implementtimesharingtocreatetheillusionofprocessesexecutinginparallel. (c)implementadynamicpriority(timesharing)schedulingschemethatestimateshowI/O boundaprocessis(basedonmeasurementsfromasinglequantumofCPUusage),andusesthis estimateinordertogiveheavilyI/Oboundprocesseshigherpriority. [Link]/False. (a)Aninterruptcanbedeliveredwhileinsideaninterrupthandler. (b)Changingthesystemclockisaprivilegedoperation. (c)Withoutkernellevelsupport,ablockinguserlevelthreadwillblockalltheother threadsinthesameprocess. (d)Contextswitchingbetweenthreadsismoreexpensivethancontextswitching betweenprocesses. (e)Ifjobruntimesareknown,theSJFschedulerprovidesoptimalaveragewaiting timeforjobs. [Link]?Whydidntitjust setprioritiesstatically? [Link] singleCPU. Job ArrivalTime Size(msec) Priority J1 0 12 1 J2 2 4 3 J3 5 2 1 J4 8 10 3 J5 10 6 2 DrawaGanttchartsshowing(a)FCFS,(b)preemptiveSJF,(c)nonpreemptiveSJF,(d)RR (quantum=4)and(e)preemptivePRIORITYschedulingforthesejobs,andcalculatethe averagejobwaitingtime. [Link](SJF)scheduling. ExplainwhywesaythattheMultiLevelFeedbackQueue(MLFQ)isanapproximationto [Link]? [Link]? if(fork()!=0) wait(&status); else
execve(ls,parameters,0); (a)Openfiledescriptors. (b)Stacksegment. (c)Datasegment. (d)Codesegment. 18.Giventhefollowingprogramcalledcreate_process1:
#include <stdio.h> main (int argc, char **argv) { int num_proc, i, pid; num_proc = atoi (argv[1]); for (i=o; i<num_proc; i++) { pid = fork(); if (pid == 0) { write (1, I am a process, 14); } } }
Andtheprogram create_process2:
#include <stdio.h> main (int argc, char **argv) { int num_proc, i, pid, status; num_proc = atoi (argv[1]); for (i=o; i<num_proc; i++) { pid = fork(); if (pid == 0) { write (1, I am a process, 14); } else wait (&status); } }
Answerthefollowingquestions: a)Drawtheprocesshierarchyforexecutingcreate_process13ycreate_process23. b)Isispossiblethattheexecutionresultsinzombies? c)Whathappensiftheusercallscreate_process150?Why?Howcantheprogrambemodified inordertoavoidtheseproblems? [Link] ofagroupofprocesses:
int num=4; int pid1,pid2; int res1,res2; while(1) { if((0==num)||(1==num)){ printf("res:%d\n",num);
exit(num); } else { pid1 = fork(); if (pid1 > 0) { pid2 = fork(); if (pid2 > 0) { waitpid(pid1,&res1,0); waitpid(pid2,&res2,0);
printf("res:%d+%d=%d\n",res1,res2,res1+res2); exit(res1+res2); }else{ num=num2; } }else{ num=num1; } } }
Answerthefollowingquestions: (a) Drawtheprocesstreeandwriteineachnodethefollowinginformation: pid(startingwith1). Returncode. Otherrelevantinformation. (b) Whichistheoutputoftheprogram(manysolutionsarepossible). (c)Iftheinitialvalueofnumischanged,howdoestheexecutionoftheprogramchange? (d)Whatistheimplementedmathematicalfunction? NOTE:thefunctionwaitpidwaitsuntiltheprocessidentifiedbythefirstparameter [Link].