From f9d28eb8e0fb3cf3373d236871127f0352ebab00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 30 Jun 2022 12:03:50 +0200 Subject: [PATCH] Test scenario for std::thread. --- repos/mml/run/thread_test.run | 22 ++++++++++++++++++++++ repos/mml/src/app/target.mk | 3 +++ repos/mml/src/app/thread_test.cc | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 repos/mml/run/thread_test.run create mode 100644 repos/mml/src/app/target.mk create mode 100644 repos/mml/src/app/thread_test.cc diff --git a/repos/mml/run/thread_test.run b/repos/mml/run/thread_test.run new file mode 100644 index 0000000000..78253eb94e --- /dev/null +++ b/repos/mml/run/thread_test.run @@ -0,0 +1,22 @@ +build 'core init app/thread_test' +create_boot_directory + +install_config { + + + + + + + + + + + + + + + +} +build_boot_image "core ld lib.so init thread_test" +append qemu_args "-nographic -m 64" \ No newline at end of file diff --git a/repos/mml/src/app/target.mk b/repos/mml/src/app/target.mk new file mode 100644 index 0000000000..578ce53722 --- /dev/null +++ b/repos/mml/src/app/target.mk @@ -0,0 +1,3 @@ +TARGET = thread_test +SRC_CC = std_thread_test.cc +LIBS += base libc stdcxx \ No newline at end of file diff --git a/repos/mml/src/app/thread_test.cc b/repos/mml/src/app/thread_test.cc new file mode 100644 index 0000000000..c5ed442b6c --- /dev/null +++ b/repos/mml/src/app/thread_test.cc @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +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(); }); +} \ No newline at end of file