Parallelism vs Concurrency Parallelism refers to multiple threads executing simultaneously across different processors at the exact same moment. Concurrency involves rapid context switching between threads on a single processor, creating the illusion of simultaneous execution. Thread Lifecycle State...
Theoretical Foundations of Concurrency Understanding Programs and Processes A program represents static code that serves as the blueprint for application execution. In contrast, a process is the dynamic execution of a program, encompassing the entire lifecycle from code loading to completion. Operat...
Concurrency Theory Why Multithreading is Necessary There are significant speed differences between CPU, memory, and I/O devices. To effectively utilize CPU performance and balance these speed disparities, computer architecture, operating systems, and compilers contribute through: CPU caching to bala...
AbstractQueuedSynchronizer (AQS) is a foundational class used in synchronization utilities like ReentrantLock, Semaphore, and CountDownLatch. It serves as an abstract template that provides a set of rules and tools to implement custom locks by overriding its abstract methods. (I). Internal Structure...
Synchronized Lock Semantics The synchronized keyword in Java enforces mutual exclusion by associating a monitor (intrinsic lock) with an object or class. Its behavior depends on what is being locked: Instance-level locks: Applied to non-static methods or synchronized(this) blocks — each object insta...
Threading Paradigms: Message-Based vs Shared-State Synchronization The most robust threading paradigm is message-based synchronization, typically implemented using a thread-safe queue class (mt_queue). Threads communicate exclusively via these queues, eliminating the need for explicit locks. The onl...
Introduction This document explores mutexes as a mechnaism for managing concurrency and race conditions within the Linux kernel. It covers theoretical aspects and the corresponding API functions provided by the kernel. Mutex Overview What Are Mutexes? Similar to systems like FreeRTOS and UCOS, mutex...
Map Concurrency Safety in Go Go maps are not inherently concurrency-safe. As reference types, when multiple maps point to the same underlying data structure, modifications to one map affect all others. The primary reasons for this lack of concurrency safety include: Absence of built-in locking mecha...
Synchronization Blocks and Lock Selection First Iteration: Single Elevator In the initial implementation, no explicit synchronized blocks were used. A BlockingQueue served as the container for passenger requests shared between threads. This container inherently ensures thread safety and blocks when...