diff options
author | johannst <johannes.stoelp@gmail.com> | 2020-09-19 19:16:39 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2020-09-19 19:39:01 +0200 |
commit | b8cc2491d8d2f239df29a6f85ad8b21e0221e8d1 (patch) | |
tree | b8f1f354586198d78168fc8f6e0905a4cce128cb /lib/matcha.cc | |
parent | 1f415f839ccdcc0f455d8b4c9adacbf0f60fc89f (diff) | |
download | matcha-threads-b8cc2491d8d2f239df29a6f85ad8b21e0221e8d1.tar.gz matcha-threads-b8cc2491d8d2f239df29a6f85ad8b21e0221e8d1.zip |
added basic executor
Diffstat (limited to 'lib/matcha.cc')
-rw-r--r-- | lib/matcha.cc | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/matcha.cc b/lib/matcha.cc index 561a08f..6e73a5e 100644 --- a/lib/matcha.cc +++ b/lib/matcha.cc @@ -2,13 +2,12 @@ #include <cassert> #include <cstdint> -#include <cstdio> #include <sys/mman.h> #include <unistd.h> // sysconf // asm fns extern "C" void thread_create(); -extern "C" void yield(void* new_stack, void** old_stack); +extern "C" void yield(const void* new_stack, void* const* old_stack); long get_pagesize() { return sysconf(_SC_PAGESIZE); @@ -51,18 +50,14 @@ Thread::Thread() { void Thread::entry(void* obj) { Thread* t = static_cast<Thread*>(obj); - - puts("thread entry"); t->threadFn(); - puts("thread done"); } -void* gOriginalStack; - void Thread::yield() { - ::yield(gOriginalStack, &mStackPtr); + assert(mExecutor); + ::yield(mExecutor->getStackPtr(), &mStackPtr); } -void Thread::yield_to() const { - ::yield(mStackPtr, &gOriginalStack); +void Executor::yield_to(const Thread* t) const { + ::yield(t->mStackPtr, &mStackPtr); } |