Expanded thread playground scenario with topology session.

This commit is contained in:
Michael Mueller
2022-10-13 16:11:47 +02:00
parent 51818bd0fc
commit bad3ae4bd0
2 changed files with 12 additions and 1 deletions

View File

@@ -15,10 +15,12 @@ install_config {
<service name="CAP"/>
<service name="RM"/>
<service name="SIGNAL"/>
<service name="TOPO"/>
</parent-provides>
<default-route>
<any-service><parent/><any-child/></any-service>
</default-route>
<affinity-space width="16" height="1"/>
<default caps="200"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
@@ -29,6 +31,7 @@ install_config {
</start>
<start name="thread_test">
<resource name="RAM" quantum="10M"/>
<affinity xpos="0" ypos="0" width="8" height="1"/>
<route>
<service name="Timer"> <child name="timer"/> </service>
<any-service><parent/><any-child/></any-service>
@@ -40,4 +43,5 @@ set boot_modules {
core init timer vfs.lib.so ld.lib.so libm.lib.so libc.lib.so stdcxx.lib.so thread_test
}
build_boot_image $boot_modules
append qemu_args "-nographic -m 64"
append qemu_args "-nographic"
run_genode_until forever

View File

@@ -1,5 +1,6 @@
#include <base/component.h>
#include <timer_session/connection.h>
#include <topo_session/node.h>
#include <base/heap.h>
#include <cstdint>
#include <memory>
@@ -38,6 +39,7 @@ class Thread_test::Test_thread : public Thread
auto end = _timer.elapsed_ms();
// auto end = std::chrono::steady_clock::now();
Genode::log("Thread ", _id, " woke up afer", (end-start), " ms.");
Genode::log("My affinities are ", this->affinity().xpos(), "x", this->affinity().ypos(), " node: ", _env.topo().node_affinity_of(this->affinity()).id(), " native region: ", _env.topo().node_affinity_of(this->affinity()).native_id());
}
}
};
@@ -56,6 +58,7 @@ public:
{
Affinity::Space space = env.cpu().affinity_space();
Genode::log("Having ", env.topo().node_count(), " NUMA regions.");
Genode::log("Size of Affinity space is ", space.total());
Genode::log("-----------------------------");
for (unsigned i = 1; i < space.total(); i++)
@@ -73,6 +76,10 @@ public:
_threads.insert(&thread->_list_element);
}
for (auto thread = _threads.first(); !thread; thread->next()) {
thread->object()->join();
}
/* Test, whether unique_ptrs work */
//auto unique_thread = std::unique_ptr<Test_thread>(new (_heap) Test_thread(env, 255, env.cpu().affinity_space().location_of_index(0)));
//unique_thread->start();