Process and Thread Management in Computer Systems
Process and Thread Management in Computer Systems
Process and Thread Management in Computer Systems
Processes can be single-threaded or multi-threaded. A single-threaded model consists of a single execution path per process. It is simpler to manage but inefficient for parallel tasks, making it ideal for basic command-line programs (Silberschatz et al., 2018). On the other hand, a multi-threaded model allows multiple threads to execute within a single process, sharing resources like memory and file handles. This model significantly improves performance, especially for multi-core processors, as seen in web browsers where each tab runs as a separate thread. Multi-threading is implemented using different models. User-Level Threads (ULTs) are managed by user-level libraries, making them fast and lightweight, though they lack direct OS support. In contrast, Kernel-Level Threads (KLTs) are managed by the operating system, offering greater power but incurring higher overhead due to context switching.
The critical-section problem arises when multiple threads or processes attempt to access shared resources, potentially leading to race conditions where the final outcome depends on the order of execution. To prevent such issues, solutions must ensure mutual exclusion, progress, and bounded waiting. A well-known software solution is Peterson’s Algorithm, which provides mutual exclusion using two boolean flags (flag[i] and flag[j]) and a turn variable (Shankar, 2012). The algorithm works by having a process signal its intent to enter the critical section by setting flag[i] = true. If the other process is already in the critical section, the process must wait until it gets its turn. Once granted access, it executes its critical section and, upon completion, sets flag[i] = false, allowing the other process to proceed.
Link: https://drive.google.com/file/d/1ItduKFXsuAHZLuGv0VNVtnxU_cXymABw/view?usp=sharing
References
Shankar, A. U. (2012). Lock using Peterson’s algorithm. Distributed Programming, 207-212. https://doi.org/10.1007/978-1-4614-4881-5_9
Silberschatz, A., Galvin, P. B., & Gagne, G. (2018). Operating system concepts, 10e abridged print companion. John Wiley & Sons.
Comments
Post a Comment