Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/gthulhu/gthulhu.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (g *GthulhuPlugin) applySchedulingStrategy(task *models.QueuedTask) bool {
g.strategyMu.RUnlock()
if exists {
// Apply strategy
if strategy.Priority {
if strategy.Priority > 0 {
// Priority tasks get minimum vtime
task.Vtime = 0
}
Expand Down
16 changes: 8 additions & 8 deletions plugin/gthulhu/gthulhu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func TestGthulhuPluginUpdateStrategyMap(t *testing.T) {

// Create test strategies
strategies := []util.SchedulingStrategy{
{PID: 100, Priority: true, ExecutionTime: 10000},
{PID: 200, Priority: false, ExecutionTime: 20000},
{PID: 100, Priority: 1, ExecutionTime: 10000},
{PID: 200, Priority: 0, ExecutionTime: 20000},
}

// Update strategy map
Expand All @@ -121,8 +121,8 @@ func TestGthulhuPluginUpdateStrategyMap(t *testing.T) {
if strategy, exists := gthulhuPlugin.strategyMap[100]; !exists {
t.Error("Strategy for PID 100 not found")
} else {
if !strategy.Priority {
t.Error("Strategy for PID 100 should have Priority=true")
if strategy.Priority <= 0 {
t.Error("Strategy for PID 100 should have Priority=1")
}
if strategy.ExecutionTime != 10000 {
t.Errorf("Strategy for PID 100 ExecutionTime = %d; want 10000", strategy.ExecutionTime)
Expand All @@ -133,8 +133,8 @@ func TestGthulhuPluginUpdateStrategyMap(t *testing.T) {
if strategy, exists := gthulhuPlugin.strategyMap[200]; !exists {
t.Error("Strategy for PID 200 not found")
} else {
if strategy.Priority {
t.Error("Strategy for PID 200 should have Priority=false")
if strategy.Priority > 0 {
t.Error("Strategy for PID 200 should have Priority=0")
}
if strategy.ExecutionTime != 20000 {
t.Errorf("Strategy for PID 200 ExecutionTime = %d; want 20000", strategy.ExecutionTime)
Expand Down Expand Up @@ -383,8 +383,8 @@ func TestGthulhuPluginRuntimeSimulation(t *testing.T) {

// Set up scheduling strategies
strategies := []util.SchedulingStrategy{
{PID: 100, Priority: true, ExecutionTime: 10000000}, // 10ms
{PID: 200, Priority: false, ExecutionTime: 20000000}, // 20ms
{PID: 100, Priority: 1, ExecutionTime: 10000000}, // 10ms
{PID: 200, Priority: 0, ExecutionTime: 20000000}, // 20ms
}
gthulhuPlugin.UpdateStrategyMap(strategies)

Expand Down
2 changes: 1 addition & 1 deletion plugin/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "time"

// SchedulingStrategy represents a strategy for process scheduling
type SchedulingStrategy struct {
Priority bool `json:"priority"` // If true, set vtime to minimum vtime
Priority int `json:"priority"` // If > 0, set vtime to minimum vtime
ExecutionTime uint64 `json:"execution_time"` // Time slice for this process in nanoseconds
PID int `json:"pid"` // Process ID to apply this strategy to
}
Expand Down
Loading