Add affinity
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
build { core init app/threads }
|
||||
build { core init drivers/timer app/threads }
|
||||
|
||||
create_boot_directory
|
||||
|
||||
@@ -10,17 +10,25 @@ install_config {
|
||||
<service name="CPU"/>
|
||||
<service name="ROM"/>
|
||||
</parent-provides>
|
||||
<affinity-space width="4" />
|
||||
<default-route>
|
||||
<any-service><parent/><any-child/></any-service>
|
||||
</default-route>
|
||||
<default caps="50"/>
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="threads">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
build_boot_image { core ld.lib.so init threads }
|
||||
build_boot_image { core init timer threads }
|
||||
|
||||
append qemu_args " -nographic -smp 4 "
|
||||
append qemu_args " -nographic -smp 4,cores=4 "
|
||||
|
||||
run_genode_until forever
|
||||
source ${genode_dir}/repos/genode-Profiler/run/profiler.inc
|
||||
set show_plot true
|
||||
|
||||
run_genode_until "done123" 30
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
|
||||
#include <util/profiler.h>
|
||||
|
||||
Genode::size_t Component::stack_size() { return 32 * 1024; }
|
||||
|
||||
namespace Threads {
|
||||
@@ -9,15 +11,31 @@ namespace Threads {
|
||||
}
|
||||
|
||||
struct Threads::MyThread : Genode::Thread {
|
||||
Timer::Connection &_timer;
|
||||
Genode::String<64> _name;
|
||||
|
||||
void entry() {
|
||||
for(int i = 0; i<10000; i++) {
|
||||
Genode::log("i=", i);
|
||||
{
|
||||
PROFILE_SCOPE(_name.string(), "yellow", _timer)
|
||||
for(int i = 0; i<500000000; i++) {
|
||||
__asm__("NOP");
|
||||
//Genode::log("i=", i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MyThread(Genode::Env &env, Genode::String<64> name) : Genode::Thread(env,
|
||||
Name(name),
|
||||
4 * 1024)
|
||||
MyThread(Genode::Env &env,
|
||||
Genode::String<64> name,
|
||||
Timer::Connection &timer,
|
||||
int pos) : Genode::Thread(env,
|
||||
Genode::Cpu_session::Name(name.string()),
|
||||
4 * 1024,
|
||||
Genode::Affinity::Location(pos, 0),
|
||||
Genode::Cpu_session::Weight(1),
|
||||
env.cpu()
|
||||
),
|
||||
_timer(timer),
|
||||
_name(name)
|
||||
{
|
||||
start();
|
||||
};
|
||||
@@ -27,11 +45,22 @@ struct Threads::MyThread : Genode::Thread {
|
||||
struct Threads::Main {
|
||||
Genode::Env &_env;
|
||||
|
||||
Timer::Connection timer { _env };
|
||||
|
||||
Main(Genode::Env &env) : _env(env) {
|
||||
Genode::log("Hello World from Threads::Main!");
|
||||
|
||||
static Threads::MyThread t1(_env, Genode::String<64>("thread_1"));
|
||||
static Threads::MyThread t2(_env, Genode::String<64>("thread_2"));
|
||||
static Threads::MyThread t1(_env, Genode::String<64>("thread_1"), timer, 0);
|
||||
static Threads::MyThread t2(_env, Genode::String<64>("thread_2"), timer, 1);
|
||||
static Threads::MyThread t3(_env, Genode::String<64>("thread_3"), timer, 2);
|
||||
static Threads::MyThread t4(_env, Genode::String<64>("thread_4"), timer, 3);
|
||||
|
||||
t1.join();
|
||||
t2.join();
|
||||
t3.join();
|
||||
t4.join();
|
||||
|
||||
Genode::log("done123");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user