Move threading calls into a basic user space library.

This commit is contained in:
Drew Galbraith 2023-06-06 16:56:19 -07:00
parent b0c2a6732b
commit 174d4b10fb
9 changed files with 67 additions and 21 deletions

View file

@ -20,7 +20,7 @@ add_executable(test2
test2.cpp)
target_link_libraries(test2
zion_lib)
mammoth_lib)
set_target_properties(test2
PROPERTIES

View file

@ -1,7 +1,5 @@
#include "zcall.h"
#include "zerrors.h"
#include "mammoth/debug.h"
#include "mammoth/thread.h"
#define CHECK(expr) \
{ \
@ -12,29 +10,19 @@
} \
}
void thread_entry(char* a, char* b) {
ZDebug("In thread");
ZDebug(a);
ZDebug(b);
ZThreadExit();
void thread_entry(void* a) {
dbgln("In thread");
dbgln(static_cast<const char*>(a));
}
int main() {
ZDebug("Testing");
uint64_t t1, t2;
CHECK(ZThreadCreate(Z_INIT_PROC_SELF, &t1));
CHECK(ZThreadCreate(Z_INIT_PROC_SELF, &t2));
dbgln("Main thread");
const char* a = "a";
const char* b = "bee";
const char* c = "cee";
const char* d = "dee";
CHECK(ZThreadStart(t1, reinterpret_cast<uint64_t>(thread_entry),
reinterpret_cast<uint64_t>(a),
reinterpret_cast<uint64_t>(b)));
CHECK(ZThreadStart(t2, reinterpret_cast<uint64_t>(thread_entry),
reinterpret_cast<uint64_t>(c),
reinterpret_cast<uint64_t>(d)));
Thread t1(thread_entry, a);
Thread t2(thread_entry, b);
return 0;
}