Number 2
System Software
1. Purposes of an Operating System (OS)
Core Operating System Functions & Abstraction
Hardware Abstraction: The OS conceals low-level hardware complexity from the user through multiple mechanisms:
User Interface (UI / GUI): Provides intuitive interaction (icons, menus, point-and-click) so users avoid typing complex low-level code or hardware instructions.
Device Drivers: Software that translates OS commands into hardware-specific instructions, allowing control of peripherals (e.g., printers) via the OS rather than directly on the peripheral device.
Device Mapping: Identifies physical and virtual devices across a network and manages their status.
Top-Layer Abstraction: The user interacts only with the top application layer (e.g., in TCP/IP protocol suites), hiding lower network transport and framing complexities.
Process Management & Multi-Tasking
Multi-Tasking: The concurrent execution of multiple programs/processes sharing CPU time and hardware resources so they appear to run simultaneously.
Efficiency & Monitoring: The OS monitors process states, uses scheduling routines to maximize resource usage, and ensures processes do not clash or starve each other.
The Three Process States
Processes exist in one of three primary states:
Running State: CPU execution time is currently allocated, and the process instructions are actively being executed by the processor.
Ready State: The process is waiting in the ready queue for its allocated CPU time slice; it is fully prepared to execute.
Blocked State: The process cannot run because it is waiting for an I/O operation (e.g., disk read/write) or external event to complete.
State Transitions (Running \(\rightarrow\) Ready)
A process transitions from Running to Ready under the following conditions:
The allocated time quantum / time slice expires in a pre-emptive scheduling scheme (e.g., Round Robin).
The running process is pre-empted by a process with a higher priority entering the ready queue.
An interrupt signal arrives at the CPU.
Process Scheduling
Purpose of Scheduling:
Ensures CPU idle time is minimized and all processes are executed in a timely manner.
Prevents process starvation and guarantees fair access to CPU resources.
Manages execution order according to job priority.
Scheduling Algorithms
Round Robin (RR):
Mechanism: A pre-emptive routine where processes are placed in a queue and each process is allocated a fixed time quantum (time slice). When a time slice ends, the process's state is saved, it is returned to the queue, and the next process is restored.
Benefit: Guarantees equal CPU access, eliminates process starvation, and minimizes average response time.
Shortest Job First (SJF):
Mechanism: A non-pre-emptive routine where queued jobs are sorted and executed in ascending order of estimated CPU burst time. Once execution starts, it runs to completion or until blocked.
Benefit: Maximizes process throughput and significantly reduces overall waiting times for short tasks. (Note: Long jobs may suffer starvation if short jobs are continuously added).
Shortest Remaining Time (SRT):
Mechanism: A pre-emptive version of SJF. If a newly arriving process has a shorter remaining execution time than the currently running process, the current process is pre-empted.
Benefit: Short processes complete extremely rapidly and waiting times are minimized.
First Come First Served (FCFS):
Mechanism: A non-pre-emptive routine where jobs are queued strictly by arrival order and executed one by one.
Benefit: Simple logic with minimal OS processing overhead; prevents starvation since every process is eventually served.
Interrupt Handling & The Kernel
Kernel: The fundamental central core of the Operating System that interfaces between hardware and software.
Interrupt Handling Routine:
The kernel receives an interrupt signal from hardware or software.
It evaluates interrupt priority against the currently running task.
If higher priority, the system shifts into kernel mode.
The kernel consults the Interrupt Descriptor Table (IDT) / Interrupt Vector Table (IVT).
The contents of CPU registers and current process state are saved onto the kernel stack.
The specific Interrupt Service Routine (ISR) is executed, after which the previous process state is restored from the stack.
Memory Management
Virtual Memory: A technique using secondary storage (hard disk or SSD) to extend physical RAM when main memory runs low, enabling large programs or many concurrent tasks to execute.
Division Methods: Paging vs. Segmentation
Feature | Paging | Segmentation |
|---|---|---|
Block Size | Fixed-size blocks called pages. | Variable-sized blocks based on logical structure. |
Management | Divided and managed automatically by the Operating System. | Calculated during compilation by the Compiler. |
Addressing | OS translates page table indices to physical memory addresses. | Logical address uses a Segment Name/Number and an Offset Value mapped via a Segment Map Table. |
Speed | Generally faster access time. | Slower access time due to variable length calculations. |
Disk Thrashing: A critical memory management failure occurring when RAM is exhausted and virtual memory is heavily used. Pages are constantly swapped back and forth between main RAM and secondary storage at an excessive rate, causing heavy hard drive latency. Eventually, more CPU time is spent swapping pages than executing instructions ("thrash point"), causing system lockup.
2. Translation Software (BNF, RPN & Compilers)
Translators: Compilers vs. Interpreters
Compiler: Translates the entire high-level source code into machine code / object code prior to program execution.
Interpreter: Executes high-level source code directly without generating a standalone executable file:
Examines source code one line / statement at a time.
Checks statement for syntax errors.
If error-free, executes the statement immediately.
If an error is found, execution halts and an error report is generated.
Translation must be repeated every time the program runs (including repeated loop iterations).
Stages of Compilation
Compilation progresses through four distinct sequential stages:
Lexical Analysis:
Takes modified source code, removes unnecessary whitespace and comments.
Converts character sequences into a stream of categorized tokens.
Identifiers (variable names, functions) are cataloged into a Symbol Table.
Invalid tokens trigger error reports; valid token streams are passed to Syntax Analysis.
Syntax Analysis (Parsing):
Receives the token stream from the Lexical Analyser.
Checks tokens against the syntax and formal grammar rules of the programming language.
Constructs a Parse Tree.
Outputs syntax error reports if language rules are broken.
Code Generation:
Converts the verified intermediate representation / parse tree into machine code or assembly code instructions.
Code Optimisation:
Reorders code and eliminates redundant instructions to improve efficiency.
Purposes: Minimizes program execution time, CPU cycles, and memory/storage usage.
Examples:
Constant Folding: Replacing constant calculations (e.g., replacing
2 * 6with12at compile time).Redundant Instruction Removal: Eliminating unnecessary register load/store instructions when values are already held in the accumulator.
Formal Syntax Description
Backus-Naur Form (BNF): A formal context-free metadata notation used to define the syntax rules of a programming language.
::=means "is defined as".|means "OR".<non-terminal>represents sub-rules (e.g.,<digit> ::= 0 | 1 | 2).Recursion: Used to express repetition (e.g.,
<word> ::= <letter> | <word><letter>).
Syntax Diagrams: Graphical flowcharts defining syntax rules, utilizing directed arrows, options, and loops to depict valid language structures.
Reverse Polish Notation (RPN / Postfix)
Definition & Benefits:
An unambiguous postfix mathematical notation where operators follow their operands.
Evaluated strictly from left to right without requiring brackets or operator precedence rules (BODMAS).
Stack Evaluation of RPN Expressions
RPN expressions are evaluated using a Stack data structure:
Read the RPN expression from left to right, item by item.
If the item is an operand / value, push it onto the stack.
If the item is an operator, pop the top two values from the stack.
Apply the operator to those two values and push the resulting calculated value back onto the stack.
Repeat until the end of the expression is reached; the final remaining stack element is the result.
Security
1. Key Terminology & Security Objectives
Plain Text: The original, unencrypted text/data before it is processed by an encryption algorithm.
Cipher Text: Text that has been encrypted from plain text using an encryption algorithm.
Public Key: A cryptographic/encryption key in a matched pair that is published/known to all users and can be obtained by anyone to encrypt messages or decrypt a sender's digital signature.
Private Key: A secret, unpublished key that is kept secure by its owner, never transmitted anywhere, and used to decrypt data encrypted with its matching public key.
Core Objectives of Cryptography:
Authenticity: Proves the message came from a genuine, trusted source.
Confidentiality: Ensures only the intended recipient with the decryption key can read the message.
Integrity: Guarantees that the message has not been altered or tampered with during transmission.
Non-Repudiation: Prevents either the sender or the receiver from denying that the transmission occurred.
2. Symmetric vs. Asymmetric Key Encryption
Feature | Symmetric Key Encryption | Asymmetric Key Encryption |
|---|---|---|
Keys Used | Uses a single key for both encryption and decryption. | Uses a matched pair of keys (one public key, one private key). |
Key Sharing | The single key must be shared/exchanged between sender and receiver. | Public key is shared freely; private key is kept secret and never shared. |
Key Distribution | Suffers from the key distribution problem (exchanging the key securely is difficult). | Resolves the key distribution problem. |
Security & Verification | Cannot verify the sender's identity or ensure non-repudiation. Risk is higher if the key is intercepted. | Allows sender verification and non-repudiation. |
Key Length | Shorter keys (e.g., 128 or 256 bits). | Requires much longer keys (e.g., 2048 bits) for equivalent security. |
Speed & Complexity | Simple algorithm; fast processing speed. | Complex algorithm; slower processing speed. |
3. Asymmetric Key Communication Workflows
A. Sending a Private/Confidential Message (Public Key Encryption)
The recipient generates a matched key pair (public key and private key) of encryption keys
The recipient makes their public key available to the sender (or to everyone).
The sender encrypts the message (plain text) using the recipient's public key to create cipher text.
The sender transmits the cipher text to the recipient.
The recipient decrypts the cipher text using their private key.
B. Sending a Verified Message (Digital Signature / Authentication)
The sender generates a matched key pair.
The sender makes their public key publicly available.
The sender encrypts the message (or message digest) using their private key.
The sender transmits the message to the group/recipient.
Anyone receiving the message can decrypt it using the sender's public key, confirming the sender's identity and providing non-repudiation.
4. Digital Certificates
Definition: An electronic/online document issued by a Certificate Authority (CA) to authenticate/prove the online identity of an individual, organisation, or website.
Common Contents:
Name of the certificate holder (Subject)
Subject’s public key
Certificate serial number & version number
Validity period (start date and expiration date)
Subject’s digital signature
Digital signature of the CA / Certificate issuer details
Process to Acquire a Digital Certificate
The organisation generates a public and private key pair locally using a web browser or RSA key generator.
The organisation submits a request to a Certificate Authority (CA).
The CA responds with its own public key and digital certificate signed with the CA's private key.
The organisation gathers authentication details to prove its identity and sends this information (along with its public key) to the CA, encrypted using the CA's public key and signed with the organisation's private key.
The CA verifies the submitted details and issues the signed digital certificate containing the organisation's public key.
5. Digital Signatures
Purpose: Used to verify the origin/authenticity of a message and ensure that it has not been altered during transmission.
Creating a Digital Signature (Sender Side)
The original message is processed through an agreed hashing algorithm to generate a fixed-size message digest.
The message digest is encrypted using the sender's private key to form the digital signature.
The digital signature is attached to the message and sent.
Checking/Verifying a Digital Signature (Receiver Side)
The recipient receives the message and attached digital signature.
The recipient decrypts the digital signature using the sender's public key to recover the original message digest sent by the sender.
The recipient hashes the received message using the agreed hashing algorithm to produce a new message digest.
The recipient compares the two message digests:
If identical: The message has not been altered, and the sender's identity is verified.
If different: The message was modified during transmission or the signature is invalid.
6) SSL / TLS Protocols (Secure Sockets Layer / Transport Layer Security)
Purpose:
Provide end-to-end communication security, privacy, and data encryption over a network/internet.
Enable clients and servers to authenticate each other and maintain data integrity.
Typical Use Cases:
Transmitting sensitive credentials (passwords, session cookies, input forms).
Protecting non-public or financial data in transit against eavesdropping or modification.
Client-Server SSL/TLS Handshake Process
Initiation: A client application initiates a connection request to the server.
Session Start: The client and server begin an SSL/TLS handshake.
Certificate Request: The client requests the server's digital certificate (or the server sends it automatically).
Verification: The client verifies the server’s digital certificate and extracts the server’s public key.
Session Key Negotiation: Encryption algorithms are agreed upon, and temporary symmetric session keys are generated for the session.
Secure Channel Established: Encrypted communication commences using the symmetric session key.
7. Quantum Cryptography
Purpose: Uses the principles of quantum mechanics (e.g., properties of light photons) rather than mathematical algorithms to generate encryption keys, producing virtually unbreakable encryption and detecting eavesdropping.
Benefits
Virtually Unhackable: Relies on rapidly changing quantum states and laws of physics.
Eavesdropping Detection: Any attempt to intercept or observe the transmission alters the quantum state/polarisation of the photons, instantly alerting the receiver.
Guaranteed Key Integrity: Keys cannot be cloned or copied due to the no-cloning theorem.
Enhanced Security: Supports longer, more secure key exchanges suitable for sensitive secrets.
Drawbacks
Short Range: Currently limited to relatively short transmission distances.
High Cost & Specialised Hardware: Requires expensive dedicated optical fibre lines and specialised hardware.
Transmission Vulnerabilities: Photon polarisation can be accidentally altered as light travels through fibre optic cables, causing errors.
Lack of Features: Currently lacks secondary features like digital signatures or certified mail.
Misuse Potential: High level of security can be exploited by criminals or hostile actors to hide communications from law enforcement.