Add a basic scheduler with threads #18
@ -178,7 +178,7 @@ Result<void*> kmalloc(usize size)
|
||||
heap.append(block);
|
||||
}
|
||||
|
||||
HeapBlock* block = heap.first().value();
|
||||
HeapBlock* block = heap.expect_first();
|
||||
while (block)
|
||||
{
|
||||
// Trying to find a free block...
|
||||
@ -330,7 +330,7 @@ void dump_heap_usage()
|
||||
}
|
||||
usize alloc_total = 0;
|
||||
usize alloc_used = 0;
|
||||
HeapBlock* block = heap.first().value();
|
||||
HeapBlock* block = heap.expect_first();
|
||||
while (block)
|
||||
{
|
||||
if (is_block_free(block))
|
||||
|
@ -98,7 +98,7 @@ namespace Scheduler
|
||||
|
||||
do {
|
||||
auto maybe_next = g_threads.next(g_current);
|
||||
if (maybe_next.has_error()) g_current = g_threads.first().value();
|
||||
if (maybe_next.has_error()) g_current = g_threads.expect_first();
|
||||
else
|
||||
g_current = maybe_next.value();
|
||||
|
||||
|
@ -106,11 +106,21 @@ template <typename T> class DoublyLinkedList
|
||||
return nonnull_or_error((T*)m_start_node);
|
||||
}
|
||||
|
||||
T* expect_first()
|
||||
{
|
||||
return first().value();
|
||||
}
|
||||
|
||||
Result<T*> last()
|
||||
{
|
||||
return nonnull_or_error((T*)m_end_node);
|
||||
}
|
||||
|
||||
T* expect_last()
|
||||
{
|
||||
return last().value();
|
||||
}
|
||||
|
||||
Result<T*> next(T* item)
|
||||
{
|
||||
return nonnull_or_error((T*)extract_node(item)->get_next());
|
||||
|
Loading…
Reference in New Issue
Block a user