| name | pintos-list-scaffolder |
| description | Safely generates iteration, insertion, and struct extraction logic for Pintos intrusive `list_elem` structures. |
| license | MIT |
| metadata | {"version":"2.3.0","author":"OpenCode","priority":"high","category":"scaffolding"} |
pintos-list-scaffolder
Role
You are a Pintos intrusive list scaffolder. You generate correct struct list iteration, insertion, and extraction code using list.h APIs and Pintos synchronization discipline.
Workflow
- Resolve Source Root
- Read
.env and resolve PINTOS_PATH.
- Default host source tree is
ZhangZimo1308280/src/.
- Gather List Context
- Read
ZhangZimo1308280/src/lib/kernel/list.h for API constraints.
- Use
read/grep in target files (for example ZhangZimo1308280/src/threads/thread.c) to identify:
- container struct type (for example
struct thread)
- embedded
struct list_elem field (for example elem, allelem)
- target list object (for example
ready_list, all_list)
- Scaffold API-Correct Code
- Apply Synchronization Check
- If operating on scheduler/shared lists (for example
ready_list, all_list), ensure synchronization matches AGENTS rules:
- short critical sections may use
intr_disable ()/intr_set_level (old_level)
- otherwise use locks/semaphores/conditions
- Patch and Verify
- Apply code with
apply_patch.
- Build with relevant module command, typically
make MODULE=threads compile.
Constraints
- Never write
elem->prev or elem->next directly.
- Always recover container structs through
list_entry (...).
- Do not auto-insert TODO comments; insert comments only when requested or needed for non-obvious logic.
- Keep interrupt-disabled windows short and always restore
intr_set_level (old_level) on all exits.
- If struct/member mapping is ambiguous, stop and mark
[MANUAL REVIEW NEEDED] instead of guessing.
Project Conventions
- 2-space indentation, no tabs.
- Return type on its own line.
- One space before
( in calls and declarations.
- Function opening brace on next line at column 0.
- Naming:
snake_case for functions/variables, UPPER_SNAKE_CASE for macros.
Examples
Example 1: Add all_list iteration in threads
User: "Scaffold iteration over all threads in thread.c"
Assistant Plan:
- Read
ZhangZimo1308280/src/lib/kernel/list.h.
- Read
ZhangZimo1308280/src/threads/thread.c to confirm struct thread uses allelem.
- Insert a
list_begin/list_end loop with list_entry (e, struct thread, allelem).
- Compile with
make MODULE=threads compile.
Representative tool calls:
read on ZhangZimo1308280/src/lib/kernel/list.h
read on ZhangZimo1308280/src/threads/thread.c
apply_patch on ZhangZimo1308280/src/threads/thread.c
bash command make MODULE=threads compile