Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Operating System Articles
Page 70 of 171
Actions taken by a kernel to context-switch between kernel-level threads.
Context Switching involves storing the context or state of a process or thread so that it can be reloaded when required and execution can be resumed from the same point as earlier. This is a feature of a multitasking operating system and allows a single CPU to be shared by multiple processes and threads. When the kernel needs to switch between kernel-level threads, it performs a series of specific actions to ensure proper state preservation and restoration. Unlike user-level thread switching, kernel-level thread context switching requires direct kernel intervention and system-level operations. Actions Taken by Kernel for Context ...
Read MoreProgramming challenges in multicore systems
The trend towards multicore systems continues to place pressure on system designers and application programmers to make better use of multiple computing cores. Designers of operating systems must write programming algorithms that utilize multiple processor cores to enable parallel execution as shown below − Parallel Execution on a Multicore System CPU Package Core 1 Task A Task B ...
Read MoreMultithreaded using the Pthreads API
Pthreads refers to the POSIX standard (IEEE 1003.1c) that defines an API for thread creation and synchronization. This is a specification for thread behavior, not a specific implementation, allowing operating system designers to implement it according to their requirements. The Pthreads API provides a standardized way to create multithreaded programs in C, enabling concurrent execution of multiple threads within a single process. Each thread shares the same memory space but can execute different parts of the program simultaneously. How Pthreads Work In a Pthreads program, separate threads begin execution in specified functions. The main thread starts in ...
Read MoreWhat is Thread cancellation?
Terminating a thread before it has completed is called thread cancellation. For example, if multiple threads are concurrently searching through a database and one thread returns the result, the remaining threads might be canceled. Another situation occurs when a user presses a stop button on a web browser to halt page loading. Often, a web page loads using several threads — each image is loaded in a separate thread. When the stop button is pressed, all threads loading the page are canceled. A thread that is to be canceled is often referred to as the target thread. Cancellation of ...
Read MoreThread-local storage (TLS)
Thread-local storage (TLS) is a mechanism that allows each thread to maintain its own separate copy of certain data variables. While threads in a process normally share the same memory space, TLS creates private storage areas that are unique to each individual thread, enabling thread-specific data management without the need for explicit synchronization. How Thread-Local Storage Works In a typical multithreaded environment, all threads share the process's global variables and heap memory. However, with TLS, the system creates separate instances of specified variables for each thread. When a thread accesses a TLS variable, it automatically gets its own ...
Read MoreScheduler activations
Scheduler activations is a technique that enables effective communication between the user-thread library and the kernel. This mechanism provides an elegant solution to the problem of managing user threads efficiently while maintaining kernel awareness of thread activities. How Scheduler Activations Work The kernel provides an application with a set of virtual processors (also called Lightweight Processes or LWPs). The application can then schedule user threads onto these available virtual processors. The key innovation is that the kernel must inform the application about certain critical events through a mechanism called upcalls. Scheduler Activations Architecture ...
Read MoreLightweight process (LWP)
Many systems implement either the many-to-many or the two-level model by placing an intermediate data structure between user and kernel threads. This data structure is typically known as a Lightweight Process (LWP) and serves as a virtual processor for scheduling user threads. How Lightweight Processes Work To the user-thread library, the LWP appears to be a virtual processor on which the application can schedule a user thread to run. Each LWP is attached to a kernel thread, and it is the kernel threads that the operating system schedules to run on physical processors. ...
Read MoreData structures of a Windows thread
Windows implements the Windows API, which is the primary API for the family of Microsoft operating systems (Windows 98, NT, 2000, XP, and Windows 7). A Windows application runs as a separate process, and each process may contain one or more threads. Additionally, Windows uses the one-to-one mapping, where each user-level thread maps to an associated kernel thread. Components of a Windows Thread The general components of a thread include − A thread ID uniquely identifying the thread A set of registers representing the status of the processor A user stack, employed when the thread is ...
Read MoreHardware Synchronization
Hardware Synchronization provides solutions to the critical-section problem using atomic hardware instructions. These hardware-based techniques form the foundation for more sophisticated synchronization mechanisms and offer better performance than pure software solutions. Hardware synchronization relies on the premise of locking using atomic operations that cannot be interrupted. These instructions allow us to test and modify memory locations or swap values as one uninterruptible unit, making them ideal for implementing mutual exclusion in multiprocessor environments. Why Hardware Support is Needed In uniprocessor systems, disabling interrupts can solve the critical-section problem by preventing preemption. However, this approach fails in multiprocessor ...
Read MorePeterson's Problem
Peterson's solution provides a good algorithmic description of solving the critical-section problem and illustrates some of the complexities involved in designing software that addresses the requirements of mutual exclusion, progress, and bounded waiting. Peterson's Algorithm Peterson's solution is restricted to two processes that alternate execution between their critical sections and remainder sections. The processes are numbered P0 and P1. We use Pj to denote the other process when Pi is present; that is, j = 1 - i. Shared Data Variables Peterson's solution requires the two processes to share two data items: int turn; ...
Read More