-
Notifications
You must be signed in to change notification settings - Fork 1
Development #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #89
Conversation
Caution Review failedThe pull request is closed. WalkthroughChanged IDE init local variable to const and removed the HLT after Yield() in KernelMainHigherHalf’s infinite loop. Replaced legacy __sync_synchronize() barriers with __atomic_thread_fence(__ATOMIC_SEQ_CST) in process termination paths. Minor formatting tweak in FindFreeSlotFast. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant K as KernelMainHigherHalf
participant S as Scheduler
participant CPU
loop infinite
K->>S: Yield()
S-->>K: (returns after context switch)
Note over K: No HLT executed after return
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
kernel/process/Process.c (2)
308-310
: Fix ordering in ASTerminate(): enqueue happens before ZOMBIE — race with cleanupThis violates the documented ordering (set PROC_ZOMBIE, fence, then enqueue). As written, CleanupTerminatedProcesses can observe a non-zombie and skip cleanup permanently.
Apply this diff:
- AddToTerminationQueueAtomic(slot); - proc->state = PROC_ZOMBIE; + proc->state = PROC_ZOMBIE; + __atomic_thread_fence(__ATOMIC_SEQ_CST); + AddToTerminationQueueAtomic(slot);
1164-1173
: GetProcessByPid leaks the read lock on success pathThe early return exits without ReadUnlock, which can deadlock future readers/writers. Unlock before returning the result.
Apply this refactor:
-Process* GetProcessByPid(uint32_t pid) { - ReadLock(&process_table_rwlock); - for (int i = 0; i < MAX_PROCESSES; i++) { - if (processes[i].pid == pid && processes[i].state != PROC_TERMINATED) { - return &processes[i]; - } - } - ReadUnlock(&process_table_rwlock); - return NULL; -} +Process* GetProcessByPid(uint32_t pid) { + ReadLock(&process_table_rwlock); + Process* result = NULL; + for (int i = 0; i < MAX_PROCESSES; i++) { + if (processes[i].pid == pid && processes[i].state != PROC_TERMINATED) { + result = &processes[i]; + break; + } + } + ReadUnlock(&process_table_rwlock); + return result; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
kernel/core/Kernel.c
(1 hunks)kernel/process/Process.c
(3 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: assembler-0
PR: assembler-0/VoidFrame#82
File: kernel/process/Process.h:0-0
Timestamp: 2025-08-14T02:11:27.395Z
Learning: In VoidFrame kernel, FastMemcpy was using SSE2 movdqu instructions without preserving XMM registers, causing crashes when called from interrupt context (like the scheduler's FastSchedule function). The fix is to use only general-purpose registers with 64-bit unrolled copies to maintain performance while being interrupt-safe.
Learnt from: assembler-0
PR: assembler-0/VoidFrame#82
File: kernel/process/Process.h:0-0
Timestamp: 2025-08-14T02:11:58.963Z
Learning: In VoidFrame kernel's FastMemcpy implementation (kernel/memory/MemOps.c), memory corruption occurs under high load due to interrupts occurring between SSE2 movdqu load and store instructions, corrupting XMM register state. The fix requires disabling interrupts around SSE operations and adding memory barriers (sfence) to ensure stores complete atomically.
📚 Learning: 2025-08-11T07:18:24.614Z
Learnt from: assembler-0
PR: assembler-0/VoidFrame#69
File: kernel/etc/Shell.c:82-86
Timestamp: 2025-08-11T07:18:24.614Z
Learning: The order of operations in VoidFrame's `TerminateProcess()` is critical: the process state must be set to PROC_ZOMBIE before adding to the termination queue with a memory barrier between them, otherwise CleanupTerminatedProcesses may process the entry before the zombie state is set.
Applied to files:
kernel/process/Process.c
📚 Learning: 2025-08-10T08:52:13.313Z
Learnt from: assembler-0
PR: assembler-0/VoidFrame#63
File: kernel/etc/Shell.c:24-28
Timestamp: 2025-08-10T08:52:13.313Z
Learning: In VoidFrame's Process.c, PIDs are allocated using `__sync_fetch_and_add(&next_pid, 1)` which only increments and never reuses freed PIDs, causing PID exhaustion after MAX_PROCESSES terminations.
Applied to files:
kernel/process/Process.c
🔇 Additional comments (3)
kernel/process/Process.c (3)
96-112
: LGTM: indentation tweak; logic remains correctThe sentinel check against ~1ULL (ignoring slot 0) is consistent with the “up to 64 processes” bitmap design and the subsequent FastFFS flow.
128-132
: Switch to __atomic_thread_fence(__ATOMIC_SEQ_CST) is correct hereMaintains the full barrier semantics after publishing the queue entry, before advancing tail. Matches the intent better than legacy __sync_synchronize.
260-263
: Correct barrier placement after PROC_ZOMBIE is setMarking the process ZOMBIE and then issuing a full fence before enqueuing prevents CleanupTerminatedProcesses from observing a non-zombie state. This preserves the required ordering.
Summary by CodeRabbit