Presentation is loading. Please wait.

Presentation is loading. Please wait.

Event Based Simulation of The Backfilling Algorithm OOP tirgul No

Similar presentations


Presentation on theme: "Event Based Simulation of The Backfilling Algorithm OOP tirgul No"— Presentation transcript:

1 Event Based Simulation of The Backfilling Algorithm OOP tirgul No. 4 2006

2 Outline The CPU allocation task – revisited The Backfilling algorithm Simulation – implementation issues

3 The CPU Allocation Task Task components –Parallel computing machine with N CPUs –A stream of request for running jobs Input for each job –Id, arrival time, num of CPUS estimated run time The task –Continuously decide which jobs to start and when to start

4 First Come First Served Revisited Simple algorithm Non optimal resource usage time now processors

5 Exploiting Free Resources Start small tasks right now Do not delay tasks ahead in the queue time now processors

6 Aggressive Backfilling (EASY) time now processors Start small tasks right now Do not delay the first task in the queue Runs on real parallel machines

7 EASY Scheduler - Overview Main data structures: –waitQueue: a queue of waiting jobs –runList: a list of running jobs Calculate status parameters –shadow time –free CPUs Find a backfill job

8 Data Structures WaitQueue –Sorted according to arrival time –For each job maintain Number of requested CPUs Estimated run time RunList – sorted by termination time timenow processors 1st2nd3rd4th

9 The Status Parameters shadow time The expected time in which the first job in the queue can run – assuming no delays free CPUs: The minimum of : –number of expected free CPUs after 1 st job in queue starts –the CPUs that are currently free timenow processors 1st2nd3rd4th Shadow timefree CPUs (in the initial stage)

10 Calculating Status Parameters set expCapacity = capacity // current # free CPUs while expCapacity < firstJob.numCPUs currJob = next job in runList expCapacity = expCapacity + currJob.numCPUs shadowTime = currJob.ExpectedFinishTime freeCPUs = min ( expCapacity-firstJob.numCPUs, capacity ) timenow processors 1st2nd3rd4th Shadow timefree CPUs (in the initial stage)

11 Decision to Run a New Job – Including Backfilling timenow processors 1st2nd3rd4th Shadow timefree CPUs (in the initial stage) Loop on jobs in waitQueue in arrival order if ( job.numCPUs > capacity) continue else if ( job is 1 st in waitQueue || estTermTimeIfStartsNow <= shadow || job.numCPUs <= freeCPUs ) start job and update freeCPUs

12 Simulation of a Scheduler Goal – analyze different schedulers –Use records of running processes Input for each job –Traces (log file) of real processes running on real machines –Id, arrival time, num of CPUS estimated run time, actual runtime Output –Various statistics on waiting time for each algorithm (average wait time and slow down in our exercise)

13 Log File - Example Id Arrival time Run time # CPUs Expected Time

14 Implementation Using event based simulation principles Main modules: –Simulator Maintains a priority queue of events Types of events: job arrival, job termination –Scheduler Maintains status of currently running jobs Maintains the wait queue Schedules jobs – instructs the simulator when to start

15 Scheduler – Implementation Issues Two types of schedulers –Consider common and distinct features –Simulator should work with different schedulers Note – scheduler can instruct initiation of several processes simultaneously See Strategy pattern in design patterns

16 Parsing Log Files Scanner is too slow for reading complete large files Solution –Use BufferedReader and FileReader –Read each line using Scanner –Integers can be read using nextInt method of Scanner

17 Implementing a Priority Queue Can be implemented using a heap (required in the exercise) Assume heap size is not known in advance → Handle memory allocation carefully Initialize an array with a reasonable size Inserting a new element to a ‘full’ heap How do we expand the heap?


Download ppt "Event Based Simulation of The Backfilling Algorithm OOP tirgul No"

Similar presentations


Ads by Google