What's changed: Initial version
2.5Software (Operating Systems)
Learn the resource management role the OS plays, state transitions in task (process) management, and scheduling schemes (such as round robin) that allocate CPU time. We also cover mutual exclusion (semaphores) needed when multiple tasks compete for a resource, the deadlock this can cause, the basics of file management, and the idea of OSS (open source software).
The OS (operating system) is the unsung hero that allocates limited hardware resources like the CPU and memory fairly and efficiently across multiple programs and users. Understanding this resource-management thinking lets you explain why you can run several applications at once, and why processing sometimes freezes up.
2.5.1The role of the OS and task management
- The OS's core role is resource management. It allocates limited hardware resources—CPU time, main memory, secondary storage, and I/O devices—across multiple programs, abstracting them into a form that is easy for users to work with. This abstraction lets application developers write programs without worrying about hardware details.
- A task (process) is the unit of a running program that the OS manages. It progresses by moving among three states: running (actually being processed by the CPU), ready (prepared to run but waiting its turn for the CPU), and waiting (blocked on something other than CPU availability, such as an I/O completion). Since the CPU can execute only one task at a time, when multiple tasks are ready, scheduling decides the order.
2.5.2Scheduling schemes
| Scheme | Overview |
|---|---|
| Round robin | Fairly assigns the CPU to each task in turn for a fixed slice of time (a time quantum) |
| Priority scheduling | Assigns a priority to each task and runs the highest-priority one first |
| First-come, first-served (FCFS) | A simple scheme that runs tasks in the order they arrive |
- Scheduling decides in what order the CPU is allocated among multiple tasks in the ready state. A representative example is round robin, which gives each task the CPU for a fixed slice of time (a time quantum) in turn; a task whose time runs out is returned to the ready state and placed at the back of the queue, preventing any one task from monopolizing the CPU.
- Which scheduling scheme to choose depends on the use case. Interactive systems that emphasize responsiveness favor a fairly rotating scheme like round robin, while environments with a mix of tasks at different urgency levels suit priority scheduling. However, priority scheduling risks starvation, where a low-priority task never gets allocated the CPU, which sometimes requires countermeasures.
The staples: the three task states are running, ready, and waiting; round robin allocates a fair, fixed time slice to each task; improper mutual exclusion via semaphores can lead to deadlock; a representative deadlock-avoidance strategy is to standardize the order in which resources are acquired. The misconception that "using a semaphore makes deadlock impossible" is also a classic trap.
When multiple tasks try to update the same resource at once (a shared file, or a database record), their updates can collide and corrupt data consistency. The mechanism that prevents this is mutual exclusion, and a representative implementation is the semaphore. A semaphore behaves like a counter of how many units of a resource are free: before using the resource, a task performs a P operation (decrement the counter, waiting if it would go below zero), and after finishing, it performs a V operation (increment the counter to signal release), thereby controlling concurrent access. What you must watch for here is deadlock. For example, if task A holds resource 1 and waits for resource 2 to free up, while task B simultaneously holds resource 2 and waits for resource 1, each keeps waiting for the other to release its resource, and processing never moves forward. Even when the semaphore mechanism itself is used correctly, deadlock can still occur if the order in which resources are acquired is wrong, so the belief that "using a semaphore makes deadlock impossible" is mistaken. Practical countermeasures against deadlock include standardizing the order in which all tasks acquire resources (e.g., always deciding to acquire resource 1 before resource 2, which prevents the circular wait described above), and aborting and retrying a task after a timeout if it cannot acquire what it needs. From a file-management perspective, the OS manages files and directories in a hierarchical structure and lets access permissions (read, write, execute) be set per user or group for each file—also part of resource management in a broad sense.
2.5.3The idea of OSS
- OSS (Open Source Software) is software whose source code is published, allowing anyone to use, modify, and redistribute it under the terms of a defined license. Among major operating systems, Linux is a widely adopted OSS kernel, used broadly from server workloads to embedded devices (including as the basis of Android). Benefits of a company adopting OSS include reduced licensing costs and the ability to benefit from community-driven improvements.
Trap: "implementing mutual exclusion with semaphores guarantees deadlock can never occur" is wrong—even if the semaphore itself works correctly, acquiring resources in the wrong order can still create a circular wait and cause deadlock. Also, "round robin always processes the highest-priority task first" is wrong—round robin's principle is fair allocation in fixed time slices; considering priority is the job of priority scheduling. "Since OSS is free, it may be freely redistributed without checking the license terms" is also wrong—even OSS requires complying with the conditions set by its specific license (such as attribution requirements or an obligation to republish modifications).
2.5.4Section summary
- The OS's core role is resource management. The three task states (running/ready/waiting) are controlled by scheduling (such as round robin)
- Mutual exclusion (semaphores) prevents concurrent access to a resource. Acquiring resources in the wrong order can still cause deadlock (using a semaphore does not guarantee prevention)
- The OS manages files via a hierarchical structure and access permissions. OSS publishes its source and allows modification/redistribution, but compliance with its license terms is still required
Sign in to track progress — Log in.
Quick check
(just a quick review)Q1. Which state describes a task that is actually being processed by the CPU right now?
Q2. Task A holds resource 1 and waits for resource 2 to be released, while task B holds resource 2 and waits for resource 1 to be released, so neither ever makes progress. What is this situation called?
Q3. Which is the most appropriate representative countermeasure to prevent deadlock from occurring?

