Operating Systems: Memory Management and CPU Scheduling Comprehensive Study Guide
Introduction to Operating Systems (OS)
Definition of an Operating System:
An operating system is a specific category of software that serves two primary roles:
User Interface: It provides the environment for humans to interact with computer hardware and allows the execution of application software.
Resource Management: It acts as a manager for the computer's physical and logical resources, including Memory, the Central Processing Unit (CPU), and Input/Output (I/O) devices.
Fundamentals of Resource Management:
Memory Management: The process of maintaining multiple programs in the computer's memory simultaneously while they await CPU time. This involves tracking where programs are located and ensuring they have sufficient space.
CPU Scheduling: The decision-making process used to determine which specific process currently in memory will be executed by the CPU at any given moment.
Memory Management Techniques and Partitioning
Memory Partitions:
Computer memory is often divided into sections called partitions (e.g., Partition A, Partition B, Partition C, etc.). These partitions house individual programs (e.g., Program 1, Program 2, Program 3).
Partition Selection Algorithms:
First Fit: The OS allocates a process to the very first partition in the memory list that is large enough to contain it.
Best Fit: The OS searches the entire list of partitions and allocates the process to the smallest available partition that is still large enough to hold it. This aims to minimize wasted space within the partition.
Worst Fit: The OS allocates the process to the largest available partition in the memory. This logic is sometimes used to leave behind the largest possible remaining fragments of memory.
Fixed Partition Comparison Exercise 1:
Given Partitions: , , , .
Program Load Order: , , , .
Observed assignment results:
First Fit Strategy: A, C, D, E.
Best Fit Strategy: B, D, A, E.
Worst Fit Strategy: C, E, A, NONE.
Fixed Partition Comparison Exercise 2:
Available Partitions:
Program Request Order: , , , , .
Results by Algorithm:
First-fit:
Best-fit:
Worst-fit:
CPU Scheduling Strategies
Core Objective: To determine which process moves from the Ready State (waiting for CPU) to the Running State (currently executing).
Common Scheduling Algorithms:
First-Come, First-Served (FCFS): Processes are moved to the CPU strictly in the order they arrive in the ready state.
Shortest Job Next (SJN): The OS looks at all processes in the ready state and selects the one with the shortest estimated running time to enter the running state next.
Round Robin (RR): Each process is permitted to run for a specific duration called a Time Slice. If the process is not finished when the slice expires, it is moved back to the ready state to wait for its next turn.
Scheduling Examples and Turnaround Time Calculations
Turnaround Time Definition: The total time taken from the arrival of a process to its completion.
Case Study Data:
Processes through arrive at the same time with the following estimated run times:
Algorithm 1: First-Come, First-Served (FCFS)
Arrival/Execution Order:
Completion Times:
Average Turnaround Time Calculation:
Algorithm 2: Shortest Job Next (SJN)
Execution Order (based on length):
Completion Times:
Average Turnaround Time Calculation:
Algorithm 3: Round Robin (Time Slice = 100)
Detailed Timeline:
runs
runs (Finished at )
runs
runs
runs
runs (Finished at )
runs
runs
runs (Finished at )
runs
runs (Finished at )
runs (Finished at )
Average Turnaround Time Calculation:
Algorithm 4: Round Robin Exercise (Time Slice = 50)
Using the same processes ():
Completion times identified:
Average Turnaround Time Calculation:
Works Cited
Dale, Neil and John Lewis. Computer Science Illuminated. 7th ed., Jones & Bartlett Learning, 2019.