classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5102 - Foundations of Comp Sys

← 5102 - Foundations of Comp Sys

FCS_10 Oct

Date 2026-10-10 Length 1h 47m Words 12,437 Segments 1,662
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5102-foundations-of-comp-sys/2026-10-10 0000 FCS 10 Oct"

title: "FCS 10 Oct"

date: "2026-10-10 00:00"

duration: "1h 46m"

language: "en"

model: "deepseek-ai/DeepSeek-V3.2"

parts: 3

transcript_chars: 64652

generated: "2026-11-23T15:46:04+05:30"


FCS 10 Oct

Overview

This class focused on the practical interface between user-space applications and the operating system kernel via system calls. It began by demonstrating common terminal commands (cat, uname, ps) to illustrate the chain from user input to kernel action. The core activity involved writing, compiling, and tracing simple C programs to observe process creation (fork, getpid) and file I/O (open, read, write) system calls using strace. The session concluded with a discussion on system log management, process visibility, and a preview of upcoming topics like virtual memory and inter-process communication, situating these practical observations within the broader course theme of the hardware/software contract.

Learning outcomes

Core concepts

User space vs. Kernel space

Definition: User space is the memory region where all application programs (e.g., shell, browsers, user-written C programs) run. Kernel space is the protected memory region where the core operating system (the kernel) executes.

Why it matters: This separation is a fundamental security and stability mechanism. Applications in user space cannot directly access hardware or privileged kernel data; they must request services via system calls.

Connection: This boundary is the central theme of the class, explored through tracing system calls that cross from user space into the kernel.

System Call

Definition: A controlled entry point into the kernel through which a user-space application requests a service, such as reading a file, creating a process, or getting the current time.

Why it matters: System calls are the only way for applications to access hardware resources managed by the kernel, enforcing the hardware/software contract.

Connection: The entire class session is built around observing system calls (open, read, write, fork, getpid) using the strace utility.

Process and Process ID (PID)

Definition: A process is a running instance of a program. The kernel assigns each process a unique Process ID (PID) to identify and manage it.

Why it matters: Understanding PIDs is essential for tracking process relationships, resource ownership, and for using tools like ps and strace.

Connection: The getpid() system call was demonstrated, and the fork() system call was shown to create a new child process with a different PID.

File Descriptor

Definition: A unique integer handle returned by the kernel when a process opens a file or other I/O resource (like a network socket). It is used in subsequent read, write, and close calls to refer to that resource.

Why it matters: File descriptors abstract the details of the underlying resource (file on disk, pipe, device) and are a core mechanism for I/O within a process.

Connection: In the file_demo.c example, the open system call returned file descriptor 3, which was then used for read and close.

Fork and Parent-Child Relationship

Definition: fork() is a system call that creates a new child process, which is an almost identical copy of the parent process. The parent's PID becomes the child's Parent Process ID (PPID).

Why it matters: This is the primary mechanism for process creation in Unix-like systems. It establishes a relationship where the parent typically waits for the child to collect its exit status.

Connection: A fork demo program showed the parent and child PIDs, and strace revealed the underlying clone system call and the parent's wait4 call.

Formulas and maths

(Not covered in this session)

Worked examples

Observing Shell and Process IDs

1. Shell PID: Ran echo $$ in the terminal, which displayed the PID of the current shell (e.g., 2006).

2. Process List: Ran ps, which showed active processes including sudo, su, bash, and ps itself.

3. Changing User Context: Exited root shell and re-entered with sudo su -. The new shell had a different PID (2930), demonstrating that a new process was created.

Simple C Program (identity.c)

1. Program Purpose: Printed process ID and system information using getpid() and uname().

2. Compilation: gcc -Wall -Wextra identity.c -o identity

3. Execution Output:

4. Targeted Tracing with strace:

File I/O Program (file_demo.c)

1. Program Flow:

2. Output: The program printed the file descriptor (3) and "bytes returned is 25" (the length of "transaction id transaction 1001").

3. Tracing: strace ./file_demo showed the sequence of openat, write, lseek, read, and close system calls, with file descriptor 3 used throughout.

Fork Program (fork_demo.c)

1. Program Flow:

2. Tracing with strace -f: The -f flag follows child processes.

Attempted Zombie Process Demo

1. Goal: To create a child process that terminates before its parent reads its exit status, leaving it in a "zombie" state.

2. Attempt: Lecturer ran a program where the parent sleep()s for 30 seconds after forking. The child was designed to exit immediately.

3. Check Command: Used ps -o pid,ppid,state,cmd to look for processes in the zombie (Z) state.

4. Outcome: The demonstration failed as the ps output did not show the expected zombie. The lecturer noted the program needed fixing and deferred the demo to the next session.

Questions asked in class

Key takeaways

Exam-style questions

1. You run strace -e openat,read,write cat /etc/hostname. Describe the sequence of system calls you would expect to see and explain the purpose of each in the context of displaying the file's content.

2. A C program calls fork(). Immediately after the fork, how can the child process distinguish itself from the parent process in code? What system calls could each use to print its own PID and its parent's PID?

3. Explain what a zombie process is. What condition creates it, and what system call (or action) by the parent process removes it from the system?

Glossary

Follow-ups

1. mmap (memory mapping) and brk (relating to virtual memory mapping to physical memory).

2. Inter-process communication (IPC).

3. Scheduling and context switch (if not covered tomorrow).

Transcript

One line per segment, [hh:mm:ss] timestamp first.

loading…