commit 0319d58c823e50fc8f7776408f1e07dcf20aea65
parent 04003be530824c91d5a8ef8c7732d38fab24ef42
Author: Andrew Laack <andrew@laack.co>
Date: Tue, 20 Jan 2026 20:27:26 -0600
Took OS notes
Diffstat:
9 files changed, 140 insertions(+), 0 deletions(-)
diff --git a/docs/Cache.md b/docs/Cache.md
@@ -0,0 +1,17 @@
+# Cache
+
+**Source:** CS 6200
+
+**Chapter:** P2L1
+
+**Definition:** The processor cache is often implemented on SRAM and dramatically decreases memory read costs, going from hundreds of cycles for direct memory access to a few cycles when the data is cached.
+
+## Specifics
+
+- Hot and cold cache
+ - The cache is hot when the cache is populated by the current process's memory
+ - The cache is cold when the current process's memory is not loaded into the cache, resulting in cache misses
+- L1, L2, and L3
+ - Each level is often larger, but slower than the prior
+
+See also [context switching](ContextSwitching.md)
diff --git a/docs/ContextSwitching.md b/docs/ContextSwitching.md
@@ -0,0 +1,11 @@
+# Context Switching
+
+**Source:** CS 6200
+
+**Chapter:** P2L1
+
+**Definition:** Context switching is the process by which the OS switches between the execution of two different processes.
+
+Context switching is done by interrupting the currently executing process, writing its registers to the process's [PCB](ProcessControlBlock.md), and then loading the saved register values from the other process's PCB into the registers.
+
+This operation can be expensive because there are direct costs, like loading / unloading instructions, and indirect costs like cold cache and cache misses.
diff --git a/docs/IOQueue.md b/docs/IOQueue.md
@@ -0,0 +1,9 @@
+# I/O Queue
+
+**Source:** CS 6200
+
+**Chapter:** P2L1
+
+**Definition:** When a process makes an I/O request the OS moves the process to the I/O queue. The process will remain on the I/O queue until receiving the I/O information and moving back to the ready queue.
+
+NOTE: The I/O queue is **not** managed by the scheduler.
diff --git a/docs/InterProcessCommunication.md b/docs/InterProcessCommunication.md
@@ -0,0 +1,21 @@
+# Inter-Process Communication (IPC)
+
+**Source:** CS 6200
+
+**Chapter:** P2L1
+
+**Definition:** IPC is the sharing of data between running processes.
+
+## Approaches
+
+1. Message-passing
+
+The Operating System establishes a communication channel between the processes (like a shared buffer), and the processes interact with it by writing / reading to the shared communication channel.
+
+It is the job of the OS to manage this channel, including defining APIs for reading / writing. This also means there is overhead because the OS is the arbiter of messages.
+
+2. Shared memory
+
+The OS establishes the shared memory channel and then maps this into the virtual address space for both processes. This mapping has a non-zero startup cost so sometimes message passing may be more efficient.
+
+This keeps the OS out of the way during communication, but this also adds code complexity because the OS is not defining APIs to send and receive messages.
diff --git a/docs/OperatingSystems.md b/docs/OperatingSystems.md
@@ -43,3 +43,8 @@
- [Process](Process.md)
- [Virtual Address Space](VirtualAddressSpace.md)
- [Page Table](PageTable.md)
+- [Process Control Block](ProcessControlBlock.md)
+- [Context Switching](ContextSwitching.md)
+- [Cache](Cache.md)
+- [I/O Queue](IOQueue.md)
+- [Inter Process Communication](InterProcessCommunication.md)
diff --git a/docs/Process.md b/docs/Process.md
@@ -9,3 +9,36 @@
## Specifics
Each process has its own virtual address space.
+
+## States
+
+The below is a list where the first layer is the state and the second layer transitions.
+
+- New
+ - Admitting
+ - Processes start in the new state. This is when the OS determines if it's okay to start the process by allocating the PCB and other init resources. The OS then moves the process to the ready state.
+- Ready
+ - Scheduler dispatch
+ - Scheduler gives CPU to the ready process
+- Running
+ - I/O or event wait
+ - Enters waiting state while CPU isn't needed by the process
+ - Exit
+ - Finishes execution and returns status code
+ - Interrupt
+ - Moves back to ready state for context switching
+- Waiting
+ - I/O or event completion
+- Terminated
+
+## Process Creation
+
+Processes can create child processes. Most operating systems start with some privileged processes (root processes) which then start child processes that are unprivileged.
+
+The main child creation processes are
+
+1. Fork
+ - Creates a new child process and (mostly) copies the parent PCB into the child PCB
+ - There are necessary distinctions between the processes so they can identify themselves
+2. Exec
+ - Replaces the current process's PCB with a new one
diff --git a/docs/ProcessControlBlock.md b/docs/ProcessControlBlock.md
@@ -0,0 +1,34 @@
+# Process Control Block (PCB)
+
+**Source:** CS 6200
+
+**Chapter:** P2L1
+
+**Definition:** The process control block is a data structure maintained by the operating system that contains process state. There is one PCB for each process.
+
+## Includes
+
+- Process state
+- Process number
+- Program counter
+- Registers
+ - Things like the program counter are automatically updated by the CPU, but the OS must ensure it knows which registers a process is using so it can switch between processes without losing data.
+- Memory limits
+- Open files
+- Priority
+- Signal mask
+- CPU scheduling info
+- ...
+
+The PCB is created when a process is started, and during runtime certain fields may be updated.
+
+## Runtime
+
+Assume process P1 is running and P2 is idle. The CPU registers are currently populated with data from P1. When the OS decides to interrupt P1's execution it performs the following operations:
+
+1. Set P1 as idle
+ - OS interrupts the process to stop subsequent instruction executions
+2. Saves data from registers to P1's PCB
+3. Restores registers based on P2's PCB
+
+This switch is called [context switching](ContextSwitching.md).
diff --git a/docs/Scheduler.md b/docs/Scheduler.md
@@ -5,3 +5,11 @@
**Chapter:** P1L2
**Definition:** An operating system scheduler controls access to the CPU by giving processes execution time.
+
+## High Level Scheduling
+
+If there is currently a process running the OS must preempt (interrupt and save context) the process that is currently running once its CPU time is up. The scheduler will then schedule one of the ready processes to start, and decide how long it can run for. The OS will then dispatch the process to a CPU for it to start executing.
+
+## Scheduler Optimization
+
+If the scheduler runs frequently, it will both result in more cache misses, and spend more cycles on scheduling. This is because the scheduler takes ~the same amount of time to run regardless of timeslice (the amount of time allocated to a scheduled process).
diff --git a/docs/VirtualAddressSpace.md b/docs/VirtualAddressSpace.md
@@ -10,6 +10,8 @@
A virtual address space is addressed from $v_0$ to $v_{max}$.
+NOTE: Just because the address space is contiguous, it doesn't mean all of the memory has been allocated (yet).
+
The virtual address space for a process is made of the following parts:
- Static state (available when the process first loads)