diff --git a/repos/mml/run/hello_mxtask.run b/repos/mml/run/hello_mxtask.run
index 6568a0c23f..1576c4779e 100644
--- a/repos/mml/run/hello_mxtask.run
+++ b/repos/mml/run/hello_mxtask.run
@@ -1,6 +1,7 @@
build "core init timer app/hello_mxtask"
create_boot_directory
+
install_config {
@@ -12,9 +13,7 @@ install_config {
-
-
@@ -28,16 +27,19 @@ install_config {
-
+
-
+
+
+
+
}
set boot_modules {
- core init timer vfs.lib.so ld.lib.so libm.lib.so libc.lib.so stdcxx.lib.so mxtasking.lib.so hello_mxtask
+ core init timer vfs.lib.so ld.lib.so libm.lib.so libc.lib.so stdcxx.lib.so hello_mxtask
}
build_boot_image $boot_modules
append qemu_args "-nographic -m 64"
diff --git a/repos/mml/src/app/hello_mxtask/main.cc b/repos/mml/src/app/hello_mxtask/main.cc
index baed9db9ca..0564d8544a 100644
--- a/repos/mml/src/app/hello_mxtask/main.cc
+++ b/repos/mml/src/app/hello_mxtask/main.cc
@@ -22,31 +22,46 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
-#include
-#include
+#include
+//#include
+#include
+//#include
+#include
+
+
class HelloWorldTask : public mx::tasking::TaskInterface
{
public:
constexpr HelloWorldTask() = default;
~HelloWorldTask() override = default;
- mx::tasking::TaskResult execute(const std::uint16_t /*core_id*/, const std::uint16_t /*channel_id*/) override
+ mx::tasking::TaskResult execute(const std::uint16_t core_id, const std::uint16_t channel_id) override
{
- std::cout << "Hello World" << std::endl;
+ //std::cout << "Hello World" << std::endl;
+ Genode::log("Hello world");
// Stop MxTasking runtime after this task.
return mx::tasking::TaskResult::make_stop();
}
};
-void Component::construct(Genode::Env &env)
+
+
+void Libc::Component::construct(Libc::Env &env)
{
// Define which cores will be used (1 core here).
- const auto cores = mx::util::core_set::build(1);
- mx::system::Environment::env = env;
- { // Scope for the MxTasking runtime.
+
+ Genode::log("Starting MxTasking ...");
+ mx::system::Environment::set_env(&env);
+
+ Libc::with_libc([&] () { // Scope for the MxTasking runtime.
+ //mx::system::Environment::env = &env;
+ Genode::log("Initialized system environment for MxTasking");
+ Genode::log("Running on core ", mx::system::topology::core_id());
+ const auto cores = mx::util::core_set::build(1);
+
// Create a runtime for the given cores.
mx::tasking::runtime_guard _{cores};
@@ -57,8 +72,15 @@ void Component::construct(Genode::Env &env)
// Annotate the task to run on the first core.
hello_world_task->annotate(cores.front());
+ Genode::log("Created new task.");
+
+ auto *task2 = mx::tasking::runtime::new_task(cores.front());
+ task2->annotate(cores.front());
// Schedule the task.
+ Genode::log("Spawning new task.");
mx::tasking::runtime::spawn(*hello_world_task);
- }
+ mx::tasking::runtime::spawn(*task2);
+ Genode::log("Task spawned.");
+ });
}
diff --git a/repos/mml/src/app/hello_mxtask/target.mk b/repos/mml/src/app/hello_mxtask/target.mk
index 5c66b5719a..3cd08740b8 100644
--- a/repos/mml/src/app/hello_mxtask/target.mk
+++ b/repos/mml/src/app/hello_mxtask/target.mk
@@ -1,4 +1,5 @@
TARGET = hello_mxtask
SRC_CC = main.cc
-LIBS += base libm libc stdcxx mxtasking
-CXXFLAGS += -Wno-error
\ No newline at end of file
+LIBS += base libc stdcxx mxtasking
+CC_OPT += -Wno-error -fno-aligned-new
+CC_CXX_WARN_STRICT =
diff --git a/repos/mml/src/app/posix_playground/main.cc b/repos/mml/src/app/posix_playground/main.cc
index 5ba113637b..312b7d7b80 100644
--- a/repos/mml/src/app/posix_playground/main.cc
+++ b/repos/mml/src/app/posix_playground/main.cc
@@ -1,9 +1,12 @@
#include
-#include
+#include
+#include
#include
#include
#include
+#include
#include
+#include
namespace Posix_playground {
class Chrono_thread;
@@ -19,12 +22,19 @@ class Posix_playground::Chrono_thread {
void execute()
{
+ std::chrono::time_point start;
+ std::chrono::time_point end;
+
while (true) {
- Genode::log("Pong from Thread ", _id);
- auto start = std::chrono::steady_clock::now();
- std::this_thread::sleep_for(std::chrono::duration_cast(std::chrono::milliseconds(_id * 1000)));
- auto end = std::chrono::steady_clock::now();
- Genode::log("Thread ", _id, " woke up after ", std::chrono::duration_cast(end - start).count());
+ if (&this->_id == nullptr) {
+ Genode::log("WTF? this is a nullptr!");
+ return;
+ }
+ Genode::log("Pong from Thread ", this->_id);
+ start = std::chrono::steady_clock::now();
+ sleep(this->_id);
+ end = std::chrono::steady_clock::now();
+ Genode::log("Thread ", _id, " woke up after ", std::chrono::duration_cast(end - start).count());
}
}
};
@@ -34,16 +44,32 @@ int main(void) {
Genode::log("Let's start some threads");
- std::vector thread_objs(4);
+ std::vector thread_objs(5);
std::vector thread_list(4);
- for (std::uint16_t i = 1; i < 4; i++) {
- thread_objs[i] = new Posix_playground::Chrono_thread(i);
- auto thread = new std::thread([&]
+ Genode::log("Let's use aligned memory for threads objects.");
+
+ for (int i = 0; i < 3; i++) {
+ Posix_playground::Chrono_thread *thread_obj;
+ if(posix_memalign((void**)(&thread_obj), 64, sizeof(Posix_playground::Chrono_thread))) {
+ Genode::error("Could not allocate thread object ", i);
+ continue;
+ }
+ Genode::log("Thread object ", (i+1), " is at address ", (void*)(thread_obj));
+
+ thread_objs[i] = new (thread_obj) Posix_playground::Chrono_thread((std::uint16_t)(i+1));
+
+ auto thread = new std::thread([thread_objs, i]
{ thread_objs[i]->execute(); });
- thread_list.push_back(thread);
+ thread_list[i] = thread;
+ //thread->join();
+ }
+
+ for (auto thread : thread_list) {
thread->join();
}
+ while(true);
+
return 0;
-}
\ No newline at end of file
+}
diff --git a/repos/mml/src/app/posix_playground/target.mk b/repos/mml/src/app/posix_playground/target.mk
index adcd1302c1..b63898e3cb 100644
--- a/repos/mml/src/app/posix_playground/target.mk
+++ b/repos/mml/src/app/posix_playground/target.mk
@@ -1,5 +1,5 @@
TARGET = posix_playground
SRC_CC = main.cc
LIBS += base posix libm libc stdcxx
-CXXFLAGS += -Wno-error
+CC_OPT += -Wno-error -Wno-permissive -fpermissive
diff --git a/repos/mml/src/app/thread_test/thread_test.cc b/repos/mml/src/app/thread_test/thread_test.cc
index 19859f4fbb..1d8f0234b9 100644
--- a/repos/mml/src/app/thread_test/thread_test.cc
+++ b/repos/mml/src/app/thread_test/thread_test.cc
@@ -48,7 +48,7 @@ class Thread_test::Tester
private:
Env &_env;
- Heap _heap{_env.ram(), _env.rm()};
+ Range_allocator _heap; //{_env.ram(), _env.rm()};
Thread_list _threads{};
public:
@@ -68,7 +68,7 @@ public:
for (unsigned i = 1; i < space.total(); i++)
{
Affinity::Location location = env.cpu().affinity_space().location_of_index(i);
- Test_thread *thread = new (_heap) Test_thread(env, (uint16_t)i, location);
+ Test_thread *thread = new (_heap.alloc_aligned(sizeof(Test_thread), 64)) Test_thread(env, (uint16_t)i, location);
thread->start();
_threads.insert(&thread->_list_element);