From 3d51ea5b54a55c5417236ed00212d1e3d5134dd2 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 20 Apr 2021 14:41:49 +0200 Subject: Added kernel threading support. Signed-off-by: Toni Uhlig --- ddk-template-cplusplus.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'ddk-template-cplusplus.cpp') diff --git a/ddk-template-cplusplus.cpp b/ddk-template-cplusplus.cpp index f4e3ce4..aafe492 100644 --- a/ddk-template-cplusplus.cpp +++ b/ddk-template-cplusplus.cpp @@ -1,5 +1,7 @@ #include +#include + class TestSmth { public: @@ -12,10 +14,30 @@ public: } }; +static void threadRoutine(PVOID threadContext) +{ + DbgPrint("ThreadRoutine %p, ThreadContext: %p\n", threadRoutine, threadContext); + for (size_t i = 3; i > 0; --i) + { + DbgPrint("ThreadLoop: %zu\n", i); + } + DbgPrint("Fin.\n"); + DriverThread::Semaphore * const sem = (DriverThread::Semaphore *)threadContext; + sem->Release(); + TERMINATE_MYSELF(STATUS_SUCCESS); +} + static void test_cplusplus(void) { TestSmth t; t.doSmth(); + + DriverThread::Semaphore sem; + DriverThread::Thread dt; + dt.Start(threadRoutine, (PVOID)&sem); + sem.Wait(); + DbgPrint("Thread signaled semaphore.\n"); + dt.WaitForTermination(); } extern "C" -- cgit v1.2.3