Skip to content

Meeting Summary: CS 631-02 Systems Foundations

  • Date: Apr 30, 2026
  • Time: 02:56 PM Pacific (US and Canada)
  • Meeting ID: 882 2309 0019

Quick Recap

Greg delivered a detailed lecture on Unix operating systems with a focus on:

  • Process creation and control using fork and exec
  • File descriptors, including standard input (0), output (1), and error (2)
  • Redirection mechanics and examples (e.g., using echo and file redirection)
  • Pipes for inter-process communication via kernel-managed memory buffers
  • Practical pipe usage (e.g., connecting ls to wc)
  • Upcoming kernel walkthroughs covering system call pathways, data structures, and implementation details

Next Steps

  • Greg
  • Study the Octoks/Rust pipe implementation in greater depth and present a clearer explanation in a future session.

  • Collaboration (Students)

  • Add four new user programs to the Octo CS 31 starter code in source/user (cargo subdirectory) as specified in Project 5. Use the required underscore filename prefix.
  • Modify the shell per Project 5 requirements.
  • Report any issues encountered when adding programs or following the specification to Greg.
  • Test running Octo CS 31 locally (preferably on macOS; Linux or WSL should also work) and report any problems to Greg.

Summary

Octoks Project Updates and Guidelines

  • Greg outlined recent Octoks updates, including:
  • Scheduler fixes
  • Improvements to the Dupe 2 system call
  • Project 5 guidance:
  • Clone the CS 631 repository.
  • Add new user programs under source/user/cargo using the required underscore prefix.
  • Environment recommendations:
  • Prefer local development on macOS.
  • Linux and possibly WSL should work; students should test and report issues.

Unix Commands and Process Control

  • Students are expected to implement simple Unix-like commands using lecture material and example code.
  • Upcoming content includes:
  • Pipes and kernel concepts (process isolation, virtual memory)
  • Key process control concepts:
  • Process Control Block (PCB) and file table relationships to fork
  • How file descriptors are copied between parent and child processes

Fork System Call Mechanics

  • fork behavior:
  • Creates a child process with a copy of the parent’s memory (stack, heap, code) and file descriptor table.
  • Execution order between parent and child is unspecified; synchronization is performed using wait.
  • Efficiency considerations:
  • In practice, fork combined with exec is optimized via copy-on-write (COW) rather than copying all memory.
  • This relies on virtual memory and page tables.

Virtual Memory and Page Tables

  • Virtual memory maps virtual addresses to physical memory via page tables.
  • Fork implementation details:
  • The child receives a new virtual address space by copying the parent’s page table.
  • Pages are initially marked read-only; a write triggers a trap, and the kernel creates a private copy (COW).
  • Code sharing:
  • Dynamically linked libraries facilitate shared code pages across processes.
  • Java bytecode generally cannot leverage the same page-level sharing optimization.

Unix Process Mechanics Overview

  • fork:
  • Duplicates the process and copies the file descriptor table.
  • exec:
  • Replaces the process’s memory with a new program while preserving the file descriptor table.
  • File descriptor redirection:
  • Performed by manipulating the file descriptor table before exec.
  • Dupe vs. Dupe 2:
  • Dupe duplicates a file descriptor to the lowest available slot.
  • Dupe 2 duplicates to a specified target descriptor.
  • Correct behavior involves closing and recreating descriptors as needed.

Unix File Descriptor Redirects

  • Standard descriptors:
  • stdin (0), stdout (1), stderr (2) default to the terminal.
  • Redirection:
  • Example: redirecting stdout by closing fd 1 and reopening it to a file.
  • exec preserves the modified file descriptor table, so subsequent programs inherit the redirection.
  • The session paused before transitioning to pipes.

Files and Streams Concepts

  • Clarifications:
  • Sequential vs. random file access
  • Relationship between files and streams in Unix
  • Buffer cache usage by the OS to optimize I/O
  • Environment setup guidance:
  • Use QEMU and Rust on Linux for running examples.
  • Upcoming topic: pipes.

Unix Pipe Mechanisms and Buffers

  • Pipes enable inter-process communication via kernel memory buffers.
  • pipe system call:
  • Returns two file descriptors (read end and write end).
  • Correct usage:
  • Close unused ends to prevent resource leaks and avoid blocking.
  • Buffer model:
  • Typically a fixed-size circular buffer with managed read/write pointers.

Kernel Pipe Implementation

  • Kernel responsibilities:
  • Reading/writing data between processes
  • Managing reference counts and properly unblocking readers/writers when ends close
  • Notes:
  • The current implementation differs from traditional C versions.
  • Further study is needed to clarify sender/receiver buffer details.

Shell Pipe Implementation Demonstration

  • Shell usage of pipes:
  • Example: connecting ls to wc via two forked child processes.
  • File descriptors are set up so that ls writes to the pipe and wc reads from it.
  • Next steps:
  • Upcoming lectures will examine kernel pathways for fork and exec.
  • Students are encouraged to study user-level examples in preparation for the next project.