Moved all the common scheduler attributes into base.go
This commit is contained in:
parent
57512ac2dd
commit
9dc5bdada2
16 changed files with 270 additions and 563 deletions
|
@ -29,30 +29,7 @@ starvation of power intensive tasks.
|
|||
// electronScheduler implements the Scheduler interface
|
||||
type TopHeavy struct {
|
||||
base // Type embedded to inherit common functions
|
||||
tasksCreated int
|
||||
tasksRunning int
|
||||
tasks []def.Task
|
||||
metrics map[string]def.Metric
|
||||
running map[string]map[string]bool
|
||||
wattsAsAResource bool
|
||||
classMapWatts bool
|
||||
smallTasks, largeTasks []def.Task
|
||||
|
||||
// First set of PCP values are garbage values, signal to logger to start recording when we're
|
||||
// about to schedule a new task
|
||||
RecordPCP bool
|
||||
|
||||
// This channel is closed when the program receives an interrupt,
|
||||
// signalling that the program should shut down.
|
||||
Shutdown chan struct{}
|
||||
// This channel is closed after shutdown is closed, and only when all
|
||||
// outstanding tasks have been cleaned up
|
||||
Done chan struct{}
|
||||
|
||||
// Controls when to shutdown pcp logging
|
||||
PCPLog chan struct{}
|
||||
|
||||
schedTrace *log.Logger
|
||||
}
|
||||
|
||||
// New electron scheduler
|
||||
|
@ -68,16 +45,18 @@ func NewTopHeavy(tasks []def.Task, wattsAsAResource bool, schedTracePrefix strin
|
|||
// Classification done based on MMPU watts requirements.
|
||||
mid := int(math.Floor((float64(len(tasks)) / 2.0) + 0.5))
|
||||
s := &TopHeavy{
|
||||
smallTasks: tasks[:mid],
|
||||
largeTasks: tasks[mid+1:],
|
||||
wattsAsAResource: wattsAsAResource,
|
||||
classMapWatts: classMapWatts,
|
||||
Shutdown: make(chan struct{}),
|
||||
Done: make(chan struct{}),
|
||||
PCPLog: make(chan struct{}),
|
||||
running: make(map[string]map[string]bool),
|
||||
RecordPCP: false,
|
||||
schedTrace: log.New(logFile, "", log.LstdFlags),
|
||||
base: base{
|
||||
wattsAsAResource: wattsAsAResource,
|
||||
classMapWatts: classMapWatts,
|
||||
Shutdown: make(chan struct{}),
|
||||
Done: make(chan struct{}),
|
||||
PCPLog: make(chan struct{}),
|
||||
running: make(map[string]map[string]bool),
|
||||
RecordPCP: false,
|
||||
schedTrace: log.New(logFile, "", log.LstdFlags),
|
||||
},
|
||||
smallTasks: tasks[:mid],
|
||||
largeTasks: tasks[mid+1:],
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
Reference in a new issue