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
MCA Articles
Page 9 of 95
Data parallelism vs Task parallelism
Data parallelism and task parallelism are two fundamental approaches to parallel computing that enable efficient utilization of multi-core systems. Understanding their differences is crucial for designing optimal parallel applications. Data Parallelism Data parallelism involves executing the same task concurrently on different subsets of the same dataset across multiple computing cores. Each core performs identical operations on its assigned portion of data. Example − Array Summation Consider summing an array of size N: Data Parallelism - Array Summation Array [0, 1, 2, 3, 4, 5, 6, 7] ...
Read MoreHow to implement monitors using semaphores?
Monitors are high-level synchronization constructs that provide mutual exclusion and condition synchronization. Since many systems only provide semaphores as primitive synchronization tools, we need to implement monitors using semaphores. This implementation requires careful handling of mutual exclusion, condition variables, and signaling semantics. Basic Monitor Structure with Semaphores For each monitor, we need several semaphores and counters: mutex − A binary semaphore (initialized to 1) for mutual exclusion next − A semaphore (initialized to 0) for signaling processes to wait next_count − Integer counter for processes suspended on next Every monitor function F is wrapped ...
Read MoreProcess Synchronization in Solaris
Process Synchronization in Solaris refers to the mechanisms used by the Solaris operating system to coordinate access to shared resources among multiple processes and threads. Solaris implements a variety of sophisticated locking mechanisms to support multitasking, multithreading, and multiprocessing environments while ensuring data consistency and preventing race conditions. Types of Synchronization Mechanisms Solaris provides several synchronization primitives, each optimized for different scenarios and performance requirements. Solaris Synchronization Mechanisms Synchronization Primitives ...
Read MoreTransactional memory
Transactional memory originated in database theory and provides an alternative strategy for process synchronization. It allows multiple operations on shared data to be grouped together and executed atomically, without the complexity of traditional locking mechanisms. A memory transaction is an atomic sequence of memory read-write operations. If all operations in a transaction complete successfully, the transaction is committed. Otherwise, the operations must be aborted and rolled back to maintain data consistency. Traditional Locking vs Transactional Memory Consider a function update() that modifies shared data. Traditionally, this function would use mutex locks or semaphores: void update() ...
Read MoreDeadlock with mutex locks
Deadlock can occur in multithreaded Pthread programs when multiple threads compete for mutex locks in conflicting orders. This happens when threads acquire locks in different sequences, potentially creating a circular dependency where each thread waits for resources held by others. Mutex Lock Initialization An unlocked mutex is initialized using the pthread_mutex_init() function. Threads acquire and release mutex locks using pthread_mutex_lock() and pthread_mutex_unlock() respectively. If a thread attempts to acquire an already locked mutex, the call to pthread_mutex_lock() blocks the thread until the owner releases the lock. Example − Deadlock Scenario Consider the following example where two ...
Read MoreHow does a process look like in memory?
A process is a program loaded into memory and executing. When a program is created, it exists as bytes stored on the hard disk as a passive entity. The program becomes an active process when loaded into memory — either by double-clicking in Windows or entering the executable name on the command line (e.g., a.out or prog.exe). A process in memory consists of several distinct segments, each serving a specific purpose during program execution. Process Memory Layout STACK (High Address) Grows Down ...
Read MoreBig Endian and Little Endian
Big Endian and Little Endian are two different ways that computer systems store multi-byte values in memory. The terms refer to which byte (most significant or least significant) is stored first in a sequence of memory addresses. Byte Order Storage Methods Little Endian − The least significant byte (low-order byte) is stored at the starting address (A), and the most significant byte (high-order byte) is stored at the next address (A + 1). Big Endian − The most significant byte (high-order byte) is stored at the starting address (A), and the least significant byte (low-order byte) is ...
Read MoreLinux Process Monitoring
In Linux, the top command is a powerful utility used to monitor running processes in real-time. It displays an ordered list of active processes and updates regularly, showing critical system information like CPU usage, memory consumption, swap memory, cache size, buffer size, process IDs (PIDs), users, and commands. This tool is essential for system administrators to identify processes consuming high memory and CPU resources. How Top Command Works The top command provides a dynamic view of the system's running processes. It refreshes every few seconds by default and sorts processes by CPU usage, with the most resource-intensive processes ...
Read MoreWhat's the difference between a context switch, a process switch and a thread switch in Linux?
Context switching is the fundamental mechanism that allows a multitasking operating system to share a single CPU among multiple processes and threads. It involves storing the current execution state so that it can be restored later, enabling seamless resumption from the same point. Types of Context Switches There are three main types of context switches in Linux, each with different overhead costs and complexity levels. Context Switch (General) A context switch is the general term for saving the current execution state (registers, program counter, stack pointer) of a running task and loading the state of another ...
Read MoreWhat is loopback address?
The loopback address is a special IP address range (127.0.0.0 – 127.255.255.255) reserved for internal communication within a single computer system. The most commonly used loopback address is 127.0.0.1, also known as localhost. This address allows processes on the same machine to communicate with each other through the network stack without requiring physical network hardware. How Loopback Addresses Work When a process sends data to a loopback address, the operating system intercepts the packet and routes it back to itself internally. The data never leaves the computer or passes through the Network Interface Card (NIC). Instead, it is ...
Read More