Menu

Os Scheduling

0 Comment

SMP5: Scheduler with Signals============================This MP is a variation of SMP4.In the last MP, we built a simulated OS process scheduler. The scheduler canhold only a certain number of processes (workers) at one time. Once the processhas been accepted into the scheduler, the scheduler decides in what order theprocesses execute. We implemented two scheduling algorithms: FIFO and RoundRobin.In this MP, we are to simulate a time-sharing system by using signals andtimers. We will only implement the Round Robin algorithm. Instead of usingiterations to model the concept of “time slices” (as in the last MP), we useinterval timers. The scheduler is installed with an interval timer. The timerstarts ticking when the scheduler picks a thread to use the CPU which in turnsignals the thread when its time slice is finished thus allowing the schedulerto pick another thread and so on. When a thread has completely finished its workit leaves the scheduler to allow a waiting thread to enter. Please note that inthis MP, only the timer and scheduler send signals. The threads passively handlethe signals without signaling back to the scheduler.The program takes a number of arguments. Arg1 determines the number of jobs(threads in our implementation) created; arg2 specifies the queue size of thescheduler. Arg3 through argN gives the duration (the required time slices tocomplete a job) of each job. Hence if we create 2 jobs, we should supply arg3and arg4 for the required duration. You can assume that the autograder willalways supply the correct number of arguments and hence you do not have todetect invalid input.Here is an example of program output, once the program is complete:% scheduler 3 2 3 2 3Main: running 3 workers with queue size 2 for quanta:3 2 3Main: detaching worker thread 3075926960.Main: detaching worker thread 3065437104.Main: detaching worker thread 3054947248.Main: waiting for scheduler 3086416816.Scheduler: waiting for workers.Thread 3075926960: in scheduler queue.Thread 3075926960: suspending.Thread 3065437104: in scheduler queue.Thread 3065437104: suspending.Scheduler: scheduling.Scheduler: resuming 3075926960.Thread 3075926960: resuming.Scheduler: suspending 3075926960.Scheduler: scheduling.Scheduler: resuming 3065437104.Thread 3065437104: resuming.Thread 3075926960: suspending.Scheduler: suspending 3065437104.Scheduler: scheduling.Scheduler: resuming 3075926960.Thread 3075926960: resuming.Thread 3065437104: suspending.Scheduler: suspending 3075926960.Scheduler: scheduling.Scheduler: resuming 3065437104.Thread 3065437104: resuming.Thread 3075926960: suspending.Scheduler: suspending 3065437104.Thread 3065437104: leaving scheduler queue.Scheduler: scheduling.Scheduler: resuming 3075926960.Thread 3075926960: resuming.Thread 3065437104: terminating.Thread 3054947248: in scheduler queue.Thread 3054947248: suspending.Scheduler: suspending 3075926960.Thread 3075926960: leaving scheduler queue.Scheduler: scheduling.Scheduler: resuming 3054947248.Thread 3054947248: resuming.Thread 3075926960: terminating.Scheduler: suspending 3054947248.Scheduler: scheduling.Scheduler: resuming 3054947248.Thread 3054947248: suspending.Thread 3054947248: resuming.Scheduler: suspending 3054947248.Scheduler: scheduling.Scheduler: resuming 3054947248.Thread 3054947248: suspending.Thread 3054947248: resuming.Scheduler: suspending 3054947248.Thread 3054947248: leaving scheduler queue.Thread 3054947248: terminating.The total wait time is 12.062254 seconds.The total run time is 7.958618 seconds.The average wait time is 4.020751 seconds.The average run time is 2.652873 seconds.The goal of this MP is to help you understand (1) how signals and timers work,and (2) how to evaluate the performance of your program. You will firstimplement the time-sharing system using timers and signals. Then, you willevaluate the overall performance of your program by keeping track of how longeach thread is idle, running, etc.The program will use these four signals:SIGALRM: sent by the timer to the scheduler, to indicate another timequantum has passed.SIGUSR1: sent by the scheduler to a worker, to tell it to suspend.SIGUSR2: sent by the scheduler to a suspended worker, to tell it to resume.SIGTERM: sent by the scheduler to a worker, to tell it to cancel.You will need to set up the appropriate handlers and masks for these signals.You will use these functions:clock_gettimepthread_sigmaskpthread_killsigactionsigaddsetsigemptysetsigwaittimer_settimetimer_createAlso, make sure you understand how the POSIX:TMR interval timer works.There are two ways you can test your code. You can run the built-in gradingtests by running “scheduler -test -f0 rr”. This runs 5 tests, each of which canbe run individually. You can also test you program with specific parameters byrunning “scheduler -test gen …” where the ellipsis contains the parameters youwould pass to scheduler.Programming===========Part I: Modify the scheduler code (scheduler.c)———————————————–We use the scheduler thread to setup the timer and handle the scheduling for thesystem. The scheduler handles the SIGALRM events that come from the timer, andsends out signals to the worker threads.Step 1.Modify the code in init_sched_queue() function in scheduler.c to initialize thescheduler with a POSIX:TMR interval timer. Use CLOCK_REALTIME in timer_create().The timer will be stored in the global variable “timer”, which will be startedin scheduler_run() (see Step 4 below).Step 2.Implement setup_sig_handlers(). Use sigaction() to install signal handlers forSIGALRM, SIGUSR1, and SIGTERM. SIGALRM should trigger timer_handler(), SIGUSR1should trigger suspend_thread(), and SIGTERM should trigger cancel_thread().Notice no handler is installed for SIGUSR2; this signal will be handleddifferently, in step 8.Step 3.In the scheduler_run() function, start the timer. Use timer_settime(). Thetime quantum (1 second) is given in scheduler.h. The timer should go offrepeatedly at regular intervals defined by the timer quantum.In Round-Robin, whenever the timer goes off, the scheduler suspends thecurrently running thread, and tells the next thread to resume its operationsusing signals. These steps are listed in timer_handler(), which is called everytime the timer goes off. In this implementation, the timer handler makes use ofsuspend_worker() and resume_worker() to accomplush these steps.Step 4.Complete the suspend_worker() function. First, update the info-50Tags: computer science coding Answers 0Bids 54Madam MichelleGreat-WritersNo_Plagiarism_Quality_WorkDr Ava_MiaWIZARD_KIMwizard kimAsad UllahQuickly answer RESPECT WRITERrunge-kutta acerPHD doctoratesmart-tutorjim claireJessica LuisColossal GeniusJenny Boomabdul_rehman_nadia tutorEmily BluntmbithehansRohanDr Candice_2547Emily Michaelprof avrilChrisProfWendy Lewisimhmd.fCamile Faithbrilliant answerskristine tutorDrNicNgaoEmily ClareYhtomitENS. writerMiss Professorwork solutionscomputerscienceProf.MacQueenStano 001perfectoTerry RobertsDr. ElahiRELIABLE PAPERSkatetutorAcademic Mentorphyllis youngEva GreenElprofessoriSaad FahimSaburBBill_WilliamsUnique_ProfTopAcademicTutorSmarticianOther questions 10ENG315 Week 5 Discussion QuestionsEng 121-Finally Returning To School-Finalchemistry TestECO 550 WEEK 8 DISCUSSIONACC 205 Week 5 AssignmentACC 201 week 2 assignment 2HUM111 Assignment-2-Project-Paper-Comparative-EssayNeurobiology HWITC203 Assignment 1helpNot ratedOs scheduling – part 2SMP5: Scheduler with SignalsIn the last MP, we built a simulated OS process scheduler. The scheduler canhold only a certain number of processes (workers) at one time. Once the processhas …Not ratedOS signalingSMP5: Scheduler with Signals============================This MP is a variation of SMP4.In the last MP, we built a simulated OS process scheduler. The scheduler canhold only a certain number of …Not ratedOs schedulingSMP4: Thread Scheduler (PART 1)======================INSTRUCTIONS============1. OVERVIEW===========In this MP, you will write a user-mode thread scheduler. The basic purposeof a …Not ratedOs scheduling 2SMP4: Thread Scheduler======================INSTRUCTIONS============1. OVERVIEW===========In this MP, you will write a user-mode thread scheduler. The basic purposeof a scheduler is …16/11/201950computerscience