mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kernel] Add lock-releasing version of thread::block()
Add a version of thread::block() that takes a lock and releases it after marking the thread as unready, but before calling the scheduler. Use this version of block() in the wait_queue.
This commit is contained in:
@@ -52,6 +52,18 @@ thread::block()
|
||||
return m_wake_value;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
thread::block(util::scoped_lock &lock)
|
||||
{
|
||||
kassert(current_cpu().thread == this,
|
||||
"unlocking block() called on non-current thread");
|
||||
|
||||
clear_state(state::ready);
|
||||
lock.release();
|
||||
scheduler::get().schedule();
|
||||
return m_wake_value;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread::join()
|
||||
{
|
||||
|
||||
@@ -96,9 +96,14 @@ public:
|
||||
inline void set_priority(uint8_t p) { if (!constant()) m_tcb.priority = p; }
|
||||
|
||||
/// Block this thread, waiting for a value
|
||||
/// \returns The value passed to wake()
|
||||
/// \returns The value passed to wake()
|
||||
uint64_t block();
|
||||
|
||||
/// Block this thread, waiting for a value
|
||||
/// \arg held A held lock to unlock when blocking
|
||||
/// \returns The value passed to wake()
|
||||
uint64_t block(util::scoped_lock &held);
|
||||
|
||||
/// Block the calling thread until this thread exits
|
||||
j6_status_t join();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user