mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
Test scenario for std::thread.
This commit is contained in:
22
repos/mml/run/thread_test.run
Normal file
22
repos/mml/run/thread_test.run
Normal 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"
|
||||
3
repos/mml/src/app/target.mk
Normal file
3
repos/mml/src/app/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = thread_test
|
||||
SRC_CC = std_thread_test.cc
|
||||
LIBS += base libc stdcxx
|
||||
28
repos/mml/src/app/thread_test.cc
Normal file
28
repos/mml/src/app/thread_test.cc
Normal 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(); });
|
||||
}
|
||||
Reference in New Issue
Block a user