Complex 234: Systems and Networks - Lecture 1: Operating Systems Foundations
Course Administration and Overview
Course Identification: Complex 234: Systems and Networks.
Teaching Staff:
Lecturer (First Half): Vimal. Office located in G 225. Responsible for Operating Systems content.
Lecturer (Second Half): Dr. Junet Hassib. Office located next to Vimal's. Responsible for Networking content.
Learning Objectives: This course focuses on the fundamental concepts of operating systems (systems) and networks.
Lecture Schedule: One 2-hour lecture per week covering approximately one topic each week.
Recommended Resources:
Operating Systems:
Operating System Concepts by Silberschatz et al. (widely known as the "dinosaur book"). Various editions are acceptable as core principles remain consistent.
Operating Systems: Three Easy Pieces by Remzi and Andrea Arpaci-Dusseau. This is a freely available online PDF resource highly recommended for its clear explanation style.
Networking: Computer Networking: A Top-Down Approach by James Kurose.
Assessment Breakdown:
In-lecture Quizzes: Conducted via the Zoro Q platform on mobile devices or laptops. These occur every week (except the first) at any point during the 2-hour window. They consist of 3–5 questions covering previous and current material.
Test: Scheduled for Week 6 (after the recess), worth 15 marks, covering Operating Systems.
Assignments: Three individual assignments.
The first is worth 15 marks (less complex).
Assignments 2 and 3 are worth more marks due to higher complexity.
Grading is split: 50% for the written code and 50% for an oral examination (Viva) where students must explain logic, libraries, and functionality to a demonstrator or lecturer.
Final Exam: Worth 40 marks.
Academic Integrity: Plagiarism is strictly prohibited. Passing off any work not created by the student as their own results in reports to the Academic Integrity Committee.
Labs and Tutorials: There are no scheduled mandatory tutorials. However, specific lab times are listed on Moodle where demonstrators are available for assistance with assignments and course content.
Fundamentals of Computer Architecture and Program Execution
Primary Function of a Computer: Fundamentally, a computer is designed to execute programs. Any application (games, AI models, browsers) must be in the form of a program to run.
The Von Neumann Architecture: This model consists of three core hardware components:
Processor (CPU): The "brains" of the system that executes instructions.
Disk (Storage): A passive storage medium where programs are saved as files.
Memory (RAM): A faster piece of hardware used as a medium between the disk and the CPU.
Execution Process:
Programs are written in high-level languages (C#, Python) and stored on the disk.
Because the disk is orders of magnitude slower than the CPU, the program is loaded from the disk into the memory.
The CPU then communicates with the memory to fetch and execute instructions.
Instruction Sets and Machine Code:
CPUs do not understand high-level languages like Python. They only understand their specific Instruction Set.
Examples: Intel, AMD (x86/AMD64), ARM (used in phones and Apple Silicon).
Compilation: The process of converting high-level code into a sequence of machine instructions for a specific processor.
Machine Code: A sequence of hexadecimal numbers (instructions) specific to the hardware.
Assembly Language: A human-readable representation of machine code (e.g.,
PUSH,MOVE,SUB) used for debugging and analysis via tools likeobjdump. The CPU does not execute assembly; it executes the underlying machine code.
Memory Visualization: In computer science, memory is visualized as a continuous sequence of cells, each capable of storing a byte of information.
The Fetch-Decode-Execute Cycle:
Fetch: The CPU retrieves the instruction from a specific memory address.
Decode: The CPU deciphers the instruction to determine the required action.
Execute: The CPU performs the operation.
This cycle repeats until the final instruction of the program is reached.
Role and Functions of the Operating System
Definition: The Operating System (OS) is a body/collection of software responsible for running programs and making the computer easy to use. It acts as an intermediary between the user/applications and the hardware.
Key Mechanism: Virtualization:
The OS takes a physical resource (like a single CPU or a block of RAM) and transforms it into a logical/virtual construct.
Purpose: To make every process feel as though it owns the entire resource exclusively, hiding the fact that many processes are sharing it.
Library Metaphor: Similar to a library where multiple people share one book. Unlike a library, the OS hides the sharing aspect from the "borrowers" (processes).
Application Programming Interface (API):
The OS provides a collection of functions for users and programs to interact with hardware.
Windows: Known as the Windows API.
Linux/Unix: Known as System Calls (e.g.,
open,read,fork,execv).
Computer System Structure Layers:
Hardware: CPU, Memory, I/O devices.
Operating System: Manages hardware and provides system calls.
System and Application Programs: Compilers, editors, Notepad, browsers (these use system calls under the hood).
Users: Interact with the application programs.
Operating System Subsystems
Functionality within an OS is generally divided into five subsystems:
Process Management: Managing the execution of multiple programs/processes and CPU allocation.
Memory Management: Allocating and protecting memory segments for different processes.
File System Management: Organizing how data is stored and retrieved from disks.
I/O Management: Dealing with input/output devices (mouse, keyboard, printers).
Protection and Security: Ensuring data integrity and preventing unauthorized access.
In-Depth: Process Management and Memory Structures
Process Definition: A process is a "program in execution." While a program is a passive entity on a disk, a process is an active entity within the system.
Note: One program can generate multiple processes (e.g., Google Chrome creates a separate process for different tabs).
Process Address Space: When a process is created, the system reserves a block of memory divided into four sections:
Text Section: Stores the executable machine code/instructions.
Data Section: Stores global variables.
Stack: Used for temporary data during function calls.
Contains: Local variables, function parameters, and return addresses.
Growth: Starts at the top of the allocated space and grows downward as functions are called; it shrinks when functions return.
Heap: Used for dynamically allocated memory (e.g., objects in C#,
mallocin C).Growth: Starts at the bottom (above the Data section) and grows upward.
Context: Used when the required memory size is unknown at compile time.
The Process Life Cycle and State Transitions
To track the hundreds of processes in a system, the OS uses a State Diagram representing five possible states:
New: The process is currently being created.
Running: The CPU is actively executing the process's instructions.
Waiting: The process is blocked, waiting for an event (e.g., I/O completion, user input like a button click).
Ready: The process has everything it needs to run and is simply waiting for the CPU to become available.
Terminated: The process has finished execution and is being removed from the system.
Transitions:
Admitted: New → Ready.
Scheduler Dispatch: Ready → Running.
Interrupt (e.g., Timer): Running → Ready (the OS forces a process off the CPU to allow others a turn).
I/O or Event Wait: Running → Waiting.
I/O or Event Completion: Waiting → Ready.
Exit: Running → Terminated.
Under the Hood: Process Control Blocks (PCB) and Queues
Process Control Block (PCB): A data structure (like a
structin C) maintained by the OS for every process. It contains:Process State: Current status (Ready, Running, etc.).
Process ID (PID): A unique numerical identifier.
Program Counter (PC): Stores the address of the next instruction to be executed, ensuring the process can resume correctly if interrupted.
CPU Registers: Values currently stored in the hardware registers that must be saved during a context switch.
Memory Management Information: Base and limit registers, or page tables.
Accounting Information: CPU usage time, time limits, and job numbers.
I/O Status Information: List of open files and allocated I/O devices.
Queuing Diagrams: The OS manages processes in these states using queues:
Ready Queue: A First-In-First-Out (FIFO) queue of all processes in the Ready state waiting for the CPU.
Device Queues (Wait Queues): Each I/O device (Keyboard, Disk, Printer) has its own queue for processes waiting to use that specific hardware.
Language Implementation: Most languages provide ways to access this data. For example, C# uses the
System.Diagnostics.Processclass to retrieve PIDs and state information.
Questions & Discussion
Question: How do labs work?
Answer: There are no scheduled tutorials or weekly lab submissions. Lab times are on Moodle, and demonstrators are available for help with assignments and course content. Students will use lab time to work on assignments and present their oral examinations (Vivas).
Question: What does a computer do?
Answer: Fundamentally, it executes programs. To do this, it follows the Von Neumann architecture, moving data from disk to memory to the CPU.
Question: What happens to the address of variables in virtualized memory?
Answer: When running multiple instances of a program, each instance might report the exact same memory address for its variables (if ASLR is off). This is because the OS creates a virtual view for each process where they believe they have the same memory layout, even though they occupy different physical RAM locations.