While designing any system usually we might confuse between thread and process usage . We think should we use thread or process for our requirement. Which will be the best choice.?
So Here are some guidelines to help you……
- All threads inside a program always run from the same executable binary. Where a child process , may run a from different executable binary by calling an exec function.
- If one process crashes or has a buffer overrun, it does not affect any other process at all, whereas if a thread crashes, it takes down all of the other threads in the process because threads share the same virtual memory space and other resources.
- Threads should be used for programs that need fine-grained parallelism. For example, if a problem can be broken into multiple, nearly identical tasks, threads may be a good choice. Processes should be used for programs that need coarser parallelism.
- Sharing data among threads is quite easy because threads share the same memory. Sharing data among processes needs to the use of IPC mechanisms which is quite complex.
- Processes are more heavy-weight than threads, and have a higher start up and shutdown cost. Interprocess communication (IPC) is also harder and slower than inter-thread communication.
Note : There is also some discussion about saying t in Windows processes are heavy and expensive compared to threads, and in Linux the difference is much smaller.
2 Comments to “Whether should i use processes or threads in Linux?”
Search in this website
Find us on Facebook
Find us on stackoverflow
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language