I’m writing a simple client server in C. What are advantages of making a multiprocess server instead of a multithread one?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This can’t realistically be answered without knowing your platform.
The rumors suggest that starting new processes on Windows is extremely expensive but starting new threads is nearly free. So Windows environments prefer threads if performance is the only consideration.
On Linux, threads are implemented as slightly special case variants of new processes. They’re both nearly free. Pick whichever will lead to best code long-term.
On other platforms, threads might be more expensive — or might not be able to make use of multiple processors. On those platforms, pick processes.
Of course, there’s more than just pure performance. There’s something very nice about shared-nothing designs — if you remove all shared data from a program, you drastically reduce the potential for bugs in the sections of code that are concurrently accessing those data structures. Furthermore, since processes do not share run-time memory, an attacker that compromises one process may not be able to control other processes. (Or, it might be more difficult.) Threads would just let the attacker read whatever it wants.