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:
Martin Stein
2015-03-27 14:05:55 +01:00
committed by Christian Helmuth
parent 955977b516
commit c9272937e7
71 changed files with 1230 additions and 483 deletions

View File

@@ -31,6 +31,8 @@ class Vmm::Vcpu_dispatcher : public T
{
private:
enum { WEIGHT = Genode::Cpu_session::DEFAULT_WEIGHT };
Cap_connection &_cap;
/**
@@ -61,7 +63,7 @@ class Vmm::Vcpu_dispatcher : public T
Cpu_session * cpu_session,
Genode::Affinity::Location location)
:
T(0, "vCPU dispatcher", stack_size),
T(WEIGHT, "vCPU dispatcher", stack_size),
_cap(cap)
{
using namespace Genode;

View File

@@ -62,8 +62,10 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
{
using namespace Genode;
Thread_capability vcpu_vm = _cpu_session->create_thread(0, "vCPU");
enum { WEIGHT = Cpu_session::DEFAULT_WEIGHT };
Thread_capability vcpu_vm =
_cpu_session->create_thread(WEIGHT, "vCPU");
/* assign thread to protection domain */
_pd_session.bind_thread(vcpu_vm);
@@ -104,12 +106,14 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
{
enum { WEIGHT = Genode::Cpu_session::DEFAULT_WEIGHT };
public:
Vcpu_same_pd(size_t stack_size, Cpu_session * cpu_session,
Genode::Affinity::Location location)
:
Thread_base(0, "vCPU", stack_size, Type::NORMAL, cpu_session)
Thread_base(WEIGHT, "vCPU", stack_size, Type::NORMAL, cpu_session)
{
/* release pre-allocated selectors of Thread */
Genode::cap_map()->remove(tid().exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2);