Skip to content

Claude/discretize unixv6 8fqk1 - #2

Open
Sia-Sheerland wants to merge 2 commits into
mainfrom
claude/discretize-unixv6-8fqk1
Open

Claude/discretize unixv6 8fqk1#2
Sia-Sheerland wants to merge 2 commits into
mainfrom
claude/discretize-unixv6-8fqk1

Conversation

@Sia-Sheerland

Copy link
Copy Markdown
Owner

No description provided.

claude added 2 commits March 20, 2026 08:48
Implements the four discretization goals:
1. All logical pages stored discretely (non-contiguous physical pages)
   - Replace MapNode/Allocator with BitMap/BitMapAllocator for page allocation
   - Each physical page tracked individually via Page[] reference count array
   - UserPageManager and KernelPageManager use BitMapAllocator

2. COW (Copy-On-Write) for fork()
   - NewProc() marks parent pages read-only, shares with child via page table copy
   - PageFault handler detects COW faults: if ref count=1 restore RW; else
     decrement ref count, allocate new page, copy contents

3. exec() allocates pages discretely, no memory copy
   - Stack pages allocated one at a time, mapped via 0# shared page table entries
   - Text/data pages allocated individually, frame numbers stored directly in PTEs
   - Eliminates old contiguous block copy approach

4. Text segment sharing with x_caddr[10] array
   - Text.h: x_caddr changed from single address to array of 10 frame numbers
   - Text.cpp: XccDec() iterates per-page, decrements ref counts, frees individually

Additional changes:
- Process.h: Add PageDirectory* pPageDirectory member + GetPageDirectoryPhyAddr()
- ProcessManager: Add AllocPageDirectory(), InitProcPageDirectory(), ModifyPageTable()
- Assembly.h: FlushPageDirectory() now accepts physical address parameter
- MemoryDescriptor.cpp: MapToPageTable() simplified to just flush CR3 with process PD
- SwtchUStruct macro updated to use per-process page directory physical address

https://claude.ai/code/session_01TZ87VQcUEKKAh8e86YYppq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants