Test scenario for std::thread.

This commit is contained in:
Michael Müller
2022-06-30 12:03:50 +02:00
parent b6d313bbe6
commit f9d28eb8e0
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
build 'core init app/thread_test'
create_boot_directory
install_config {
<config>
<parent-provides>
<service name="LOG"/>
<service name="PD"/>
<service name="CPU"/>
<service name="ROM"/>
</parent-provides>
<default-route>
<any-service><parent/></any-service>
</default-route>
<default caps="200"/>
<start name="thread_test">
<resource name="RAM" quantum="10M"/>
</start>
</config>
}
build_boot_image "core ld lib.so init thread_test"
append qemu_args "-nographic -m 64"

View File

@@ -0,0 +1,3 @@
TARGET = thread_test
SRC_CC = std_thread_test.cc
LIBS += base libc stdcxx

View File

@@ -0,0 +1,28 @@
#include <base/component.h>
#include <thread>
#include <iostream>
#include <chrono>
namespace ThreadTest {
struct Main;
}
struct ThreadTest::Main
{
Genode::Env &_env;
void execute()
{
while(true) {
std::cout << "Hello world" << std::endl;
std::this_thread::sleep_for(std::chrone::seconds(1));
}
}
};
void Component::construct(Genode::Env &env)
{
static ThreadTest::Main main(env);
std::thread([main]
{ main->execute(); });
}