From a5caf7ca991dc48959f75ebed70f5018302e53d2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 24 Oct 2018 01:02:55 +0200 Subject: [PATCH] Make the kmalloc global stats variable volatile. I know I'm praying for cargo here, but this does fix a weird issue where logging the sum_alloc and sum_free globals wouldn't display symmetric values all the time. --- Kernel/Task.cpp | 11 +++++++++++ Kernel/kmalloc.cpp | 4 ++-- Kernel/kmalloc.h | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index 6c0ba1d43d8..564ba726f99 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -497,6 +497,17 @@ bool scheduleNewTask() if (task == prevHead) { // Back at task_head, nothing wants to run. + kprintf("Nothing wants to run!\n"); + kprintf("PID OWNER STATE NSCHED NAME\n"); + for (auto* task = s_tasks->head(); task; task = task->next()) { + kprintf("%w %w:%w %b %w %s\n", + task->pid(), + task->uid(), + task->gid(), + task->state(), + task->timesScheduled(), + task->name().characters()); + } kprintf("Switch to kernel task\n"); return contextSwitch(Task::kernelTask()); } diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index b142a3f60e2..dbd873836d8 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -27,8 +27,8 @@ typedef struct PRIVATE BYTE alloc_map[POOL_SIZE / CHUNK_SIZE / 8]; -DWORD sum_alloc = 0; -DWORD sum_free = POOL_SIZE; +volatile DWORD sum_alloc = 0; +volatile DWORD sum_free = POOL_SIZE; static SpinLock s_kmallocLock; diff --git a/Kernel/kmalloc.h b/Kernel/kmalloc.h index b5f31046bc6..3862b68aefd 100644 --- a/Kernel/kmalloc.h +++ b/Kernel/kmalloc.h @@ -4,8 +4,8 @@ void kmalloc_init(); void *kmalloc(DWORD size) __attribute__ ((malloc)); void kfree(void*); -extern DWORD sum_alloc; -extern DWORD sum_free; +extern volatile DWORD sum_alloc; +extern volatile DWORD sum_free; inline void* operator new(size_t, void* p) { return p; } inline void* operator new[](size_t, void* p) { return p; }