mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Clean up threads' kernel stacks on exit
Add a destructor to threads in order to deallocate their kernel stacks.
This commit is contained in:
@@ -37,6 +37,11 @@ thread::thread(process &parent, uint8_t pri, uintptr_t rsp0) :
|
|||||||
set_state(state::ready);
|
set_state(state::ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread::~thread()
|
||||||
|
{
|
||||||
|
kutil::kfree(reinterpret_cast<void*>(m_tcb.kernel_stack));
|
||||||
|
}
|
||||||
|
|
||||||
thread *
|
thread *
|
||||||
thread::from_tcb(TCB *tcb)
|
thread::from_tcb(TCB *tcb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public:
|
|||||||
/// Get the pointer to the thread object containing this TCB
|
/// Get the pointer to the thread object containing this TCB
|
||||||
static thread * from_tcb(TCB *tcb);
|
static thread * from_tcb(TCB *tcb);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~thread();
|
||||||
|
|
||||||
/// Get the `ready` state of the thread.
|
/// Get the `ready` state of the thread.
|
||||||
/// \returns True if the thread is ready to execute.
|
/// \returns True if the thread is ready to execute.
|
||||||
inline bool ready() const { return has_state(state::ready); }
|
inline bool ready() const { return has_state(state::ready); }
|
||||||
|
|||||||
Reference in New Issue
Block a user