Sharing resources with process or threads

The OS ensures that there is little or no interaction between processes. When creating a multiprocessing application, where multiple processes must interact, a common OS resource must be explicitly shared. This can be a common file, a specific, shared-memory object, or a semaphore with a shared state between the processes. Processes are inherently independent; interaction among them is exceptional.

Multiple threads, in contrast, are part of a single process; all threads of a process share OS resources. We can make an exception to get some thread-local memory that can be freely written without interference from other threads. Outside thread-local memory, operations that write to memory can set the ...

Get Functional Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.