Mada za sehemu hiiDemonstrate understanding of principles of Operating Systems [Types of OS; Memory management; File management; CPU Scheduling; etc]Mada 3
- Describe the concept of operating systems (evolution, types, architecture, structure and design)
- Describe the impact of operating system design on application system design and performance
- Demonstrate competency in recognising and using operating system design and performance [Process Management (Processes and threads, process creation, synchronisation and Communication), CPU/Processor Scheduling (Deadlock prevention, avoidance and recovery), Memory Management (Main and virtual memory management), File System Structure and implementation, Input/output Systems and device management]
Operating system design directly determines how efficiently a computer uses its hardware resources—CPU time, memory, storage, and peripheral devices. Understanding OS design and performance helps you troubleshoot slow computers, manage multiple programs, and appreciate how applications run smoothly on your device.

Processes and Threads
A process is a program in execution. When you open any application—such as a web browser or music player—the operating system creates a process that requires resources like memory and CPU time. The OS acts as a "headmaster" managing these processes to ensure smooth operation.
A thread is a smaller unit within a process that shares the process's resources (memory and CPU time). Multiple threads within one process can run concurrently, enabling efficient multitasking. For example, when you use a web browser:
- One thread downloads content from the internet
- Another thread displays the page on screen
- A third thread handles your mouse clicks and keyboard input
This allows you to browse while the page loads without the browser freezing.
Process Creation
When you launch software, the OS performs these steps:
- Creates a new process — allocates a unique Process ID (PID)
- Allocates memory — assigns RAM space for the program's code and data
- Sets up the execution context — loads the program into memory and prepares CPU registers
- Adds to the scheduling queue — makes the process ready to run on the CPU
Multiple processes compete for CPU time, so the OS uses scheduling algorithms to manage the queue and ensure smooth multitasking.
Process Synchronisation and Communication
When multiple processes share resources (like a file or printer), they must coordinate access to avoid conflicts. The OS provides mechanisms for this:
- Semaphores: Special flags that signal whether a resource is available. A process checks the semaphore before using a shared resource and updates it to "in use" to prevent others from accessing it simultaneously.
- Critical sections: The part of program code where a shared resource is accessed. The OS ensures only one process can be in its critical section using a particular resource at a time.
Worked Example: Imagine two students sharing one printer at school. Student A sends a document to print (Process 1), and Student B tries to print at the same time (Process 2). Without synchronisation, both documents might mix together. The OS uses a semaphore to let only one process use the printer at a time—Student A's job prints first, then the semaphore signals "available" for Student B.
CPU scheduling decides which process gets the CPU next and for how long. This directly impacts how responsive your computer feels.
Scheduling Algorithms
| Algorithm | How it works | Advantages | Disadvantages |
|---|---|---|---|
| First Come First Served (FCFS) | Processes are served in order of arrival | Fair and simple | Slow if a long process blocks short ones |
| Shortest Job First (SJF) | Shortest processes run first | Minimal average waiting time | Requires knowing process length beforehand |
| Round Robin (RR) | Each process gets equal CPU time in turns | Fair, prevents starvation, responsive | Overhead from frequent context switching |
Round Robin is commonly used because it gives every process a turn while keeping short tasks responsive.
Worked Example: Four students (processes) need to ask questions to one teacher (CPU):
- P1 needs 10 minutes, P2 needs 3 minutes, P3 needs 8 minutes, P4 needs 2 minutes
- FCFS order: P1→P2→P3→P4. Average wait: (0 + 10 + 13 + 21) ÷ 4 = 11 minutes
- SJF order: P4→P2→P3→P1. Average wait: (0 + 2 + 5 + 13) ÷ 4 = 5 minutes
- RR (5-min time quantum): Each student gets 5 minutes, then rotates. P1 waits while others take turns.
Deadlock
Deadlock occurs when two or more processes are each waiting for resources held by another process. Neither can proceed.
Worked Example: Consider two printers and two students:
- Student A has Printer 1 and needs Printer 2
- Student B has Printer 2 and needs Printer 1 Both students wait forever—the system is deadlocked.
Deadlock Prevention Strategies
To prevent deadlock, OS designers use these techniques:
- Mutual exclusion: Only one process can access certain resources (like a printer) at a time
- Hold and wait: A process cannot hold one resource while requesting another—it must release what it has before requesting new ones
- No preemption: Resources cannot be forcibly taken away once allocated
- Circular wait prevention: Order all resources numerically; processes must request them in that order
The OS allocates RAM to processes and manages the computer's memory resources.
Main Memory Allocation Strategies
- First-Fit: Allocate the first available memory block that is large enough for the process
- Best-Fit: Find the smallest available block that fits the process, leaving larger blocks for bigger requests
Memory Fragmentation
As processes come and go, memory becomes divided into small unused sections:
- External fragmentation: Free memory scattered in small blocks, unable to satisfy large requests
- Internal fragmentation: Wasted space within allocated blocks (allocated 16KB but only 12KB used)
Virtual Memory
When RAM is full, the OS uses virtual memory—temporarily moving less-used data to the hard drive. This creates the illusion that the computer has more RAM than physically available.
Worked Example: Your phone has 4GB RAM but opens 10 apps. When you open an 11th app, the OS moves data from the least-used app (say, a game you haven't played in days) to the hard drive. You can still switch back to that game, but it loads more slowly—the OS swaps it back from storage.
The file system organises data on storage devices (hard drives, USB sticks, memory cards).
Directory Structure
- Directories (folders): Contain files and other subdirectories, creating a hierarchical structure
- Files: Store data (documents, photos, programs)
File Allocation Methods
- FAT (File Allocation Table): Maintains a table tracking which clusters (storage units) each file occupies
- Inodes (used in Linux): Store file metadata (size, permissions, location) with pointers to data blocks
Worked Example: On a school computer, you save "essay.docx" to the Documents folder. The file system records: "essay.docx is in the Documents folder, uses clusters 45, 46, and 47 on the disk." When you open the file, the OS reads these locations.
The OS manages communication between the CPU and peripheral devices.
Device Drivers
Device drivers are special programs that translate OS instructions into commands specific to each hardware device. When you connect a printer or keyboard, the driver allows the OS to "understand" the device.
Interrupt Handling
Devices can interrupt the CPU to request attention. For example, when you press a key:
- The keyboard sends an interrupt signal to the CPU
- The OS pauses the current task
- The OS processes the keystroke
- The OS resumes the previous task
This ensures devices get serviced without the CPU constantly checking each one.
In Tanzania, mobile money services like M-Pesa rely on efficient operating system design. When a shop owner in Dar es Salaam processes payments using a smartphone, the OS must manage multiple processes simultaneously—keeping the screen responsive, connecting to the network, and securing transaction data. Understanding CPU scheduling helps explain why the phone might feel slightly slower when many apps are open, and memory management explains why closing unused apps improves performance and saves battery life during busy market days.
Swali
What is a thread in the context of operating systems?
Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.
Ingia ili kufanya mazoeziMwalimu
Umekwama? Niulize chochote kuhusu mada hii.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.
Ingia ili kuuliza