mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
CPU session: apply quota via relative weightings
Physical CPU quota was previously given to a thread on construction only by directly specifying a percentage of the quota of the according CPU session. Now, a new thread is given a weighting that can be any value. The physical counter-value of such a weighting depends on the weightings of the other threads at the CPU session. Thus, the physical quota of all threads of a CPU session must be updated when a weighting is added or removed. This is each time the session creates or destroys a thread. This commit also adapts the "cpu_quota" test in base-hw accordingly. Ref #1464
This commit is contained in:
committed by
Christian Helmuth
parent
955977b516
commit
c9272937e7
@@ -1,161 +0,0 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
build "core init drivers/timer test/cpu_quota"
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config prio_levels="4">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service><parent/><any-child/></any-service>
|
||||
</default-route>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="init_1" priority="-1">
|
||||
<binary name="init"/>
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<resource name="CPU" quantum="10"/>
|
||||
<config prio_levels="2">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="Timer"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service><parent/><any-child/></any-service>
|
||||
</default-route>
|
||||
|
||||
<!-- should receive 10 % of the CPU time -->
|
||||
<start name="test_slow" priority="-1">
|
||||
<binary name="test-cpu_quota"/>
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<resource name="CPU" quantum="50"/>
|
||||
</start>
|
||||
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="init_2" priority="-2">
|
||||
<binary name="init"/>
|
||||
<resource name="RAM" quantum="100M"/>
|
||||
<resource name="CPU" quantum="80"/>
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="RM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
<service name="Timer"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service><parent/></any-service>
|
||||
</default-route>
|
||||
|
||||
<!-- should receive 25 % of the CPU time -->
|
||||
<start name="test_middle">
|
||||
<binary name="test-cpu_quota"/>
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<resource name="CPU" quantum="25"/>
|
||||
</start>
|
||||
|
||||
<!-- should receive 65 % of the CPU time -->
|
||||
<start name="test_fast">
|
||||
<binary name="test-cpu_quota"/>
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<resource name="CPU" quantum="75"/>
|
||||
</start>
|
||||
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image "core init timer test-cpu_quota"
|
||||
|
||||
#
|
||||
# Execution
|
||||
#
|
||||
|
||||
append qemu_args "-nographic -m 64"
|
||||
|
||||
run_genode_until "test.*\n.*test.*\n.*test.*\n" 60
|
||||
|
||||
#
|
||||
# Conclusion
|
||||
#
|
||||
|
||||
set slow_opt 0.10
|
||||
set middle_opt 0.25
|
||||
set fast_opt 0.65
|
||||
set err 0.02
|
||||
|
||||
regexp {[0-9]+} [regexp -inline {slow.*[0-9]+} $output] slow_cnt
|
||||
regexp {[0-9]+} [regexp -inline {middle.*[0-9]+} $output] middle_cnt
|
||||
regexp {[0-9]+} [regexp -inline {fast.*[0-9]+} $output] fast_cnt
|
||||
set total_cnt [expr $fast_cnt + $middle_cnt + $slow_cnt]
|
||||
|
||||
set slow_fac [expr $slow_cnt / double($total_cnt) ]
|
||||
set middle_fac [expr $middle_cnt / double($total_cnt) ]
|
||||
set fast_fac [expr $fast_cnt / double($total_cnt) ]
|
||||
|
||||
set failed 0
|
||||
if {[expr $slow_fac > $slow_opt + $err || $slow_fac < $slow_opt - $err]} {
|
||||
set is_pc [expr round($slow_fac * 10000) / 100]
|
||||
set opt_pc [expr round($slow_opt * 10000) / 100]
|
||||
puts stderr "Error: Slow counter received $is_pc% of the CPU time."
|
||||
puts stderr " Should receive $opt_pc%."
|
||||
set failed 1
|
||||
}
|
||||
if {[expr $middle_fac > $middle_opt + $err || $middle_fac < $middle_opt - $err]} {
|
||||
set is_pc [expr round($middle_fac * 10000) / 100]
|
||||
set opt_pc [expr round($middle_opt * 10000) / 100]
|
||||
puts stderr "Error: Middle counter received $is_pc% of the CPU time."
|
||||
puts stderr " Should receive $opt_pc%."
|
||||
set failed 1
|
||||
}
|
||||
if {[expr $fast_fac > $fast_opt + $err || $fast_fac < $fast_opt - $err]} {
|
||||
set is_pc [expr round($fast_fac * 10000) / 100]
|
||||
set opt_pc [expr round($fast_opt * 10000) / 100]
|
||||
puts stderr "Error: Fast counter received $is_pc% of the CPU time."
|
||||
puts stderr " Should receive $opt_pc%."
|
||||
set failed 1
|
||||
}
|
||||
if {$failed} {
|
||||
exit -1
|
||||
} else {
|
||||
puts "Test succeeded"
|
||||
}
|
||||
Reference in New Issue
Block a user