1/114
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
parallelism
tasks executing at the exact same time
concurrency
tasks making progress during overlapping time intervals
parallelism requirement
the need for multiple cores to run tasks simultaneously
data parallelism
applying the same operation to different chunks of data concurrently
fine-grained parallelism
many small tasks requiring frequent synchronization
speedup
ratio of sequential runtime to parallel runtime (Ts/Tp)
amdahl’s law
the sequential portion limits the maximum achievable speedup
free lunch is over
hardware clock speeds no longer increase, requiring software-level parallelism
thread barrier
synchronization point where threads wait until all arrive
global interpreter lock
CPython's mechanism preventing true parallel execution of CPU-bound threads
multiprocessing
enabling true parallelism for CPU-bound tasks
CPU-bound task
computation-heavy task such as complex simulations
shared memory
threads within a process share memory and global variables
critical section
code requiring exclusive access to shared resources
lock
mechanism ensuring only one thread enters a critical section at a time
classes
fundamental OOP structures important for the course
start()
method that begins thread execution by calling run() internally
threading timer
schedules a function to run after a delay
runnable
state where a thread is ready to run but not yet scheduled
deadlock
threads waiting indefinitely for resources held by each other
threads
best suited for I/O-bound workloads
GIL impact
prevents true parallelism for CPU-bound threaded tasks
heisenbug
bug that changes or disappears when observed
thread-safe
correct behavior under concurrent execution
shared mutable state
the primary cause of thread-safety issues
context switch
events such as blocking I/O that cause the OS to switch threads
thread context
stored CPU state including PC, registers, and stack pointer
thrashing
excessive context switching causing performance degradation
thread pool
collection of reusable worker threads
executor map
method submitting multiple tasks concurrently
shared memory risk
race conditions from unsynchronized access
queue FIFO
retrieves items in first-in, first-out order
queue thread safety
built-in thread-safe design using internal locking
queue sentinel
special value (None) used to signal completion
semaphore count
the number of available permits
binary semaphore
semaphore restricted to values 0 or 1
with semaphore
automatically acquires and releases a permit
thread barrier
synchronizing threads at a checkpoint
process memory
isolated private memory space
process vs thread memory
processes isolate memory; threads share it
multiprocessing
Python interface for creating and managing processes
process ID
unique identifier of a running process
IPC necessity
required because processes cannot share memory directly
GIL workaround
using processes for true CPU parallelism
IPC challenge
higher overhead and complexity than threads
process-safe queue
multiprocessing.Queue for inter-process communication
pipe
pair of connection endpoints for two-way communication
pipe use case
direct parent–child process communication
manager shared state
proxy-based sharing via a manager process
shared_memory
low-overhead shared buffers without pickling
mp value
shared integer accessed via .value
pool map
parallel mapping of a function across data
map vs apply_async
synchronous vs asynchronous task submission
apply_async result
retrieving results via result.get()
close() and join()
stop task submission and wait for tasks to finish
process advantage
true multi-core parallelism for CPU-bound tasks
process drawback
higher memory and communication overhead
process synchronization primitives
must be created via multiprocessing module or Manager
throughput
number of completed tasks per unit time
convoy effect
short jobs stuck behind long ones in FCFS scheduling
SJF drawback
requires predicting CPU burst length
round robin
fixed time slice per process
priority scheduling starvation
low-priority tasks might never run
aging
increasing process priority to prevent starvation
MLFQ
scheduler allowing processes to move between queues
context switch
saving and restoring CPU state to run different tasks
context elements
PC, registers, stack pointer, and process state
preemptive multitasking
OS interrupts running tasks to schedule others
virtual memorY
strong process isolation
private stack
each thread’s separate stack for local variables
cache coherence
keeping shared memory values consistent across CPU caches
false sharing
separate variables sharing a cache line and causing contention
hyperthreading
duplicating some execution resources to expose multiple logical cores
NUMA
memory access time depends on memory’s physical location
GPU advantage
thousands of SIMD cores for massively parallel workloads
advisory file locking
cooperative locking where processes must check locks
mandatory file locking
OS-enforced file locking
Boss
distributes tasks to workers
Worker
executes assigned tasks independently
boss-worker queue
boss sends tasks through a shared queue
producer
creates data or tasks
consumer
processes data or tasks
producer-consumer benefit
decouples production rate from consumption rate
bounded buffer
buffer with fixed maximum capacity
server
listens for client requests and responds
client
sends requests and receives responses
reader-writer problem
multiple readers allowed; writers require exclusivity
writer starvation
writers blocked indefinitely when readers dominate
chopsticks
resource used in the dining philosopher’s problem
dining philosophers issue
risk of deadlock if all hold one chopstick
sleeping barber barber state
sleeps when no customers are present
sleeping barber full shop
arriving customer leaves if no waiting seats
cigarette smokers agent
places two ingredients on the table
cigarette smokers challenge
complex signaling to avoid deadlock or starvation
monte carlo
numerical estimation via repeated random sampling
GIL vs C#
C# has no GIL, allowing true parallel threads
task parallel library
core C# concurrency abstraction for async and parallel tasks
csharp thread class
represents an OS-managed thread
parameterized threading
passing an object to Thread.Start()
join()
waits for a thread to finish execution