forked from Bananymous/banan-os
I don't know why I though the block chain had to be stored fully in the ThreadBlocker, that did not even fix the problem I was trying to fix when I last rewrote it. Roll back to doubly linked list of block chain and now just check that the node is contained within the ThreadBlocker before removing and after acquiring the ThreadBlocker's lock. Also there is no need to have a separate lock the node's blocker field. We can just perform an atomic reads and writes to it. We can still get a blocker that the node is no longer part of, but this can be resolved with a simple check. This patch reduces ThreadBlocker's size from over 200 bytes to just 12 bytes +4 bytes padding
37 lines
695 B
C++
37 lines
695 B
C++
#pragma once
|
|
|
|
#include <kernel/ProcessorID.h>
|
|
#include <kernel/Lock/SpinLock.h>
|
|
|
|
namespace Kernel
|
|
{
|
|
|
|
class Thread;
|
|
class ThreadBlocker;
|
|
|
|
struct SchedulerQueueNode
|
|
{
|
|
SchedulerQueueNode(Thread* thread)
|
|
: thread(thread)
|
|
{}
|
|
|
|
Thread* const thread;
|
|
|
|
SchedulerQueueNode* next { nullptr };
|
|
SchedulerQueueNode* prev { nullptr };
|
|
|
|
uint64_t wake_time_ns { static_cast<uint64_t>(-1) };
|
|
|
|
BAN::Atomic<ThreadBlocker*> blocker { nullptr };
|
|
SchedulerQueueNode* block_chain_prev { nullptr };
|
|
SchedulerQueueNode* block_chain_next { nullptr };
|
|
|
|
ProcessorID processor_id { PROCESSOR_NONE };
|
|
bool blocked { false };
|
|
|
|
uint64_t last_start_ns { 0 };
|
|
uint64_t time_used_ns { 0 };
|
|
};
|
|
|
|
}
|