System Software Flashcards
(23 cards)
How an OS can be used to maximise the use of resources. 5 points
- Scheduling:
It allocates CPU time efficiently to processes so no time is wasted (e.g. using Round Robin or priority-based scheduling). - Multitasking:
It allows multiple applications to run at once, switching quickly between them to give the illusion of parallelism. - Memory Management:
It dynamically allocates and deallocates memory using techniques like paging and segmentation, ensuring efficient use. - I/O Management:
It queues and manages input/output tasks to avoid idle hardware. - Resource Allocation Policies:
It prevents resource conflicts and deadlocks through management policies and locking mechanisms.
- Describe the ways in which the user interface hides the complexities of the hardware from the user. 4 points
The OS provides user interfaces (UIs)—like graphical (GUI) or command-line (CLI)—that simplify interaction by:
• Abstracting hardware operations: Instead of typing complex machine instructions, users click icons or type simple commands (e.g., copy instead of issuing a series of memory and disk I/O instructions).
• Managing files with directories: Users view and manage files through folders, not sectors and blocks on a disk.
• Providing standard input/output methods: Applications use consistent methods for input (keyboard, mouse) and output (screen, printer), without needing to manage hardware drivers directly.
• Simplifying error handling: Instead of displaying raw hardware error codes, the OS shows friendly messages like “No Internet connection.”
Describe 1. multitasking 2. Process
The abilty of an operating system to run multiple programs or processes at the same time
Process: instance of a program in execution with its own memory space, set of instructions and data
Explain how multitasking works (3) and 2 benefits
- CPU switches between processes very quicky ie context switching
- It gives each process a time slice
- The processes run in this small amount of time but users see programs running at once
- Improves efficiency
- Allows multiple users or apps to share the system
Describe the 3 process states
Process States
- Running
• The process is currently being executed
by the CPU.
• Only one process can be in the running state at a time on a single-core CPU. - Ready
• The process is ready to run but is waiting for CPU time.
• It’s in the queue to be scheduled. - Blocked (or Waiting)
• The process is waiting for an event (like input/output) to finish.
It cannot proceed until that event occurs.
Why is scheduling needed, 4 points
Maximize CPU usage
Ensure fairness, all processes get a turn
Avoid starvation of any process
Increase system efficiency by reducing wait times and turnaround times
Describe First Come First Served algorithm, 3 points
Its non-preemptive
Processes are scheduled in the order they arrive
Simple but unfair, longer jobs can delay shorter ones(convoy effect)
Describe round robin, 4
Preemptive
Each process gets a fixed time slot(quantum)
After its time, its placed at the end of queue if not finished
Fair and good for time sharing systems
If time slice too small, (fast)context switching. If too big ,(slow) latency
Shortest Job First
Non preemptive
Process with the shortest expected execution time runs first
Efficient but had to predict actual job lengths
Shortest Remaining time
Preemptive
If a new process arrives with a shorter time than current one, it takes over
Minimalizes average waiting time
The Role of the Kernel in Interrupt Handling, 6
Kernel use, core part of the OS that controls hardware and manages system software software
Interrupts are signals sent to the processor to gain its attention for either hardware or software
Steps taken when interrupt occurs
1CPU pauses current process
2kernel saves current program state
3appropriate interrupt handler runs
The handler processes the interrupt
May update queues or flags to tell scheduler what needs to be run next
How Interrupts Help with Scheduling, 3 points
-When a process blocks, an interrupt allows the OS to switch to another ready process using context switching.
-Timer interrupts allow fair timesharing using preemptive scheduling
-efficient resource use since CPU uses scheduler to find work to do every during slow I/O intput output
Define and describe virtual memory
A memory management technique that lets programs use more memory than physically available
Uses disk space to act as extra RAM
Help run large programs or multiple programs at once
Describe paging, 5
Memory is split into fixed size blocks
Pages in logical memory and frames in physical memory are the result of splitting into fixed size blocks
The OS maps pages to frames
Allows non-contiguous memory allocation
Helps in efficient memory use and prevents fragmentation
Describe segmentation, 3
Memory is split based on logical sections of a program
Each segment has a base address and limit
Supports logical program structure and protection
The difference between paging and segmentation, 5
Feature:Paging, Segmentation
Memory division:Fixed-size pages,Variable-size segments
Purpose:Efficient memory use, Reflects logical program structure
Fragmentation: No external, possible internal;Can cause external fragmentation
Address: Page number + offset, Segment number + offset
Used for:Memory management, Logical program division (code, stack…)
How pages can be replaced, 6
When physical memory is full, the OS needs to replace a page in memory with another from disk (virtual memory). This is handled by page replacement algorithms.
Common Page Replacement Algorithms:
1. FIFO (First-In, First-Out):
• Removes the page that was loaded earliest.
• Simple but may remove frequently used pages.
2. LRU (Least Recently Used):
• Replaces the page that hasn’t been used for the longest time.
• Based on past access patterns.
3. Optimal Page Replacement:
• Replaces the page that won’t be used for the longest future time.
• Theoretical, used for comparison only (requires future knowledge).
4. Clock Algorithm (Second-Chance):
• Like FIFO but gives a second chance to pages that were recently accessed.
Causes and symptoms if disk thrashing,6
Thrashing happens when a computer spends more time swapping pages in and out of memory than executing actual processes.
Causes:
• Too many processes are loaded, each needing more memory than available.
• Pages are replaced too frequently due to frequent page faults.
• The system is overloaded and virtual memory is overused.
Symptoms:
• Sluggish performance.
• High disk activity.
• Little actual processing.
How to prevent thrashing
Use efficient page replacement algorithms (e.g., LRU).
• Increase RAM.
• Use load control to limit the number of running processes.
• Tune virtual memory settings.
How an interpreter can execute programs without producing a translated version, 4
An interpreter executes a program line by line, directly running the code instead of translating it into machine code first.
Key Points:
• It reads a line, parses it, and executes it immediately.
• No separate compiled file is created.
• Errors are detected at runtime.
• Slower than compiled execution but easier for debugging and development.
Describe the 5 stages in the compilation of a program
- Lexical Analysis:
• Breaks the code into tokens (e.g., keywords, identifiers).
• Removes whitespace and comments.
• Checks for basic syntax errors (e.g., illegal characters). - Syntax Analysis (Parsing):
• Checks the structure of the code using grammar rules.
• Builds a syntax tree.
• Detects syntax errors like missing semicolons or wrong nesting. - Semantic Analysis:(maybe irrelevant)
• Checks for meaning (e.g., undeclared variables, type mismatches).
• Ensures logic is valid according to the language’s rules. - Code Generation:
• Converts the syntax tree into intermediate or machine code.
• Targets a specific hardware architecture. - Code Optimization:
• Improves the efficiency of the generated code.
• Reduces execution time or memory usage.
Example:
Infix: 3 + 4 * 2
RPN?
Example:
Infix: 3 + 4 * 2
RPN: 3 4 2 * +
Step-by-step Evaluation:
1. Push 3
2. Push 4
3. Push 2
4. Encounter *: Pop 2 and 4, compute 4 * 2 = 8, push 8
5. Encounter +: Pop 8 and 3, compute 3 + 8 = 11
Result: 11
Benefits of RPN, 3
Benefits of RPN:
• No need for parentheses
• Easier for computers and compilers to process
• Reduces ambiguity in expressions