Event Based Simulation of The Backfilling Algorithm - PowerPoint PPT Presentation

About This Presentation
Title:

Event Based Simulation of The Backfilling Algorithm

Description:

Various statistics on waiting time for each algorithm (average wait time and ... Can be implemented using a heap (required in the exercise) ... – PowerPoint PPT presentation

Number of Views:248
Avg rating:3.0/5.0
Slides: 18
Provided by: csHu
Category:

less

Transcript and Presenter's Notes

Title: Event Based Simulation of The Backfilling Algorithm


1
Event Based Simulationof 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 CPUSestimated 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

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

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

processors
time
now
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

processors
time
now
1st
2nd
3rd
4th
9
The Status Parameters
  • shadow timeThe expected time in which the first
    job in the queue can run assuming no delays
  • free CPUsThe minimum of
  • number of expected free CPUs after 1st job in
    queue starts
  • the CPUs that are currently free

Shadow time
free CPUs (in the initial stage)
processors
time
now
1st
2nd
3rd
4th
10
Calculating Status Parameters
  • set expCapacity capacity // current free CPUs
  • while expCapacity lt firstJob.numCPUs
  • currJob next job in runList
  • expCapacity expCapacity currJob.numCPUs
  • shadowTime currJob.ExpectedFinishTime
  • freeCPUs min ( expCapacity-firstJob.numCPUs ,
  • capacity )

Shadow time
free CPUs (in the initial stage)
processors
time
now
1st
2nd
3rd
4th
11
Decision to Run a New Job Including Backfilling
  • Loop on jobs in waitQueue in arrival order
  • if ( job.numCPUs gt capacity)
  • continue
  • else
  • if ( job is 1st in waitQueue
  • estTermTimeIfStartsNow lt shadow
  • job.numCPUs lt freeCPUs )
  • start job and update freeCPUs

Shadow time
free CPUs (in the initial stage)
processors
time
now
1st
2nd
3rd
4th
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 CPUSestimated 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
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?
Write a Comment
User Comments (0)
About PowerShow.com