Meeting Summary: CS 631-01 Systems Foundations¶
- Date: Apr 30, 2026
- Time: 08:19 AM Pacific Time (US and Canada)
- Meeting ID: 870 0988 0761
Quick Recap¶
The session centered on teaching operating system concepts through hands-on examples in the Octux OS environment. Greg led a deep dive into:
- Process management fundamentals:
fork,exec, and file descriptor redirection - Copy-on-write behavior in page tables and process isolation
- Pipes as kernel-managed communication channels between processes
- Processor modes (machine, supervisor, user) and page table structures
The session prepared students for upcoming lectures on kernel-level system call implementation.
Next Steps¶
Greg¶
- Provide the first assignment: S-Trace implementation
- Distribute the repository for Octoks and autograder tests
- Include instructions and the “Run Octoks” Python script for automation
Students¶
- Clone the provided Octoks repository
- Implement the S-Trace assignment as specified
- Submit the modified Octoks repository by next week’s due date
Detailed Summary¶
Unix fork System Call Implementation¶
forkcreates a new process by logically copying:- The parent’s memory (via page tables)
- The file table and file descriptor table
- The child initially shares the parent’s memory mappings until a write occurs (copy-on-write).
- Upcoming topics include
fork,exec, redirection, pipes, and kernel-level system call implementations. - Use case:
forkis essential for creating new processes to run applications.
Copy-on-Write (COW) and Process Isolation¶
- On
fork, the kernel copies the parent’s page table for the child and marks pages read-only. - When either process writes to a shared page, the kernel allocates a new page and copies the data (COW), enabling efficient isolation.
- Discussion focused on RISC-V page tables and how they support COW semantics.
Lazy Copying (“Confidence” Technique) and Memory Operations¶
- The “confidence” technique refers to lazy copying: only page tables are copied upfront; actual memory is copied on write faults.
- A brief review covered how store instructions trigger page faults that drive COW.
- Greg introduced the “Run Octoks” Python script to automate running commands within Octux for the assignment.
- Overview of
exec: replaces a process’s memory image with a new program.
Process Control and exec Mechanics¶
- During
exec: - The process ID (PID) and file descriptor table are retained.
- The process’s address space is replaced by the new program’s code and data.
- Example:
- Parent forks a child (e.g., PID 3).
- Child calls
execto runls. - Child exits; parent waits for completion.
- Emphasis:
forkandexecunderpin process creation across modern systems.
File Descriptor Redirection: Basics¶
- Redirection can be performed in the child after
forkand beforeexec. - Example:
- Close file descriptor 1 (stdout) to free the slot.
- Open a file; the OS reuses the lowest available FD (now 1), redirecting stdout to the file.
- Result: Output that would go to the terminal is written to the file.
File Descriptor Redirection: System Calls and Practices¶
execpreserves file descriptor table modifications made before the call.- Two common methods to redirect stdout to a file:
dup2(fd, 1)to atomically duplicate onto FD 1- Close FD 1 and then open the target file (FD reuse)
- Special FDs:
- 0: stdin
- 1: stdout
- 2: stderr
- Best practices:
- Reuse 0/1/2 for terminal I/O when appropriate
- Close FDs when no longer needed to free resources and avoid leaks
Kernel Pipe System: Overview¶
pipe()creates a unidirectional channel with two file descriptors:- Read end and write end
- Processes must close unused ends to prevent:
- Blocking readers (if writers remain open)
- Blocking writers (if readers remain open and buffer is full)
- Proper closure also signals end-of-data (EOF) to readers.
- Plans include combining pipes with
forkandexecto connect independent programs.
Unix Pipes: Concept and Limitations¶
- Pipes connect output of one program to input of another (e.g.,
ls | wc) without intermediate files. - Characteristics and limitations:
- Fixed-size kernel buffer (commonly on the order of hundreds of bytes; historically around 512 bytes in Unix)
- Suitable for streaming data
- Not suitable for random access patterns or very large data without careful design (buffers can fill)
macOS/Linux Environment Troubleshooting¶
- The session included troubleshooting differences between macOS and Linux environments.
- Considerations included external installations and directory requirements.
- After a clean build and rerun, a working solution was found, though the root cause remained uncertain.
Kernel Pipes, Processor Modes, and Isolation¶
- Demonstration: Using a pipe to redirect the output of
lsintowcthrough file descriptors. - Emphasis on closing unnecessary pipe ends to avoid deadlocks or indefinite blocking.
- Introduction to processor modes:
- Machine, supervisor, and user modes
- Operating system responsibilities:
- Isolation between processes
- Resource management via page tables, protection, and syscalls
- Preview: An upcoming assignment with user-level programs and the S-Trace tool for observing system calls in Octux.
Assignments and Tools¶
- Assignment: Implement S-Trace to observe system calls made by programs running on Octux.
- Repository: Octoks (to be provided by Greg), including autograder tests.
- Utility: “Run Octoks” Python script for automating runs inside Octux.
Note: Names and tools reflect the course materials as presented (Octux OS environment and the Octoks repository).