Multithreading vs Multiprocessing

Images

AttributeMultiprocessMultithreading
DevelopmentCan be easier. Use of fork(2) or clone(2).Use of threads API (pthreads).
Memory overheadSeparate address space per process consumes some memory resources (reduced to some degree by page- level copy-on-write).Small. Requires only extra stack and register space, and space for thread-local data.
CPU overheadCost of fork(2)/clone(2)/exit(2), which includes MMU work to manage address spaces.Small. API calls.
CommunicationVia IPC. This incurs CPU cost including context switching for moving data between address spaces, unless shared memory regions are used.Fastest. Direct access to shared memory. Integrity via synchronization primitives (e.g., mutex locks).
Crash resilienceHigh, processes are independent.Low, any bug can crash the entire application.
Memory UsageWhile some memory may be duplicated, separate processes can exit(2) and return all memory back to the system.Via system allocator. This may incur some CPU contention from multiple threads, and fragmentation before memory is reused.