Differences between processes and threads
- Processes do not share their address space while threads are executed under the same process address space.
- Context switching is faster between threads than between processes.
- Threads can directly communicate (mutex, direct memory access) with other threads of its process but processes must use IPC (signals, semaphores, queues, shared memory) to communicate with other processes.
Code example
# cat threads_example.c
# gcc -o threads_example threads_example.c -lpthread
No comments:
Post a Comment