I have used threading before in my applications and know its concepts well, but recently in my operating system lecture I came across fork(). Which is something similar to threading.
I google searched difference between them and I came to know that:
- Fork is nothing but a new process that looks exactly like the old or the parent process but still it is a different process with different process ID and having it’s own memory.
- Threads are light-weight process which have less overhead
But, there are still some questions in my mind.
- When should you prefer fork() over threading and vice-verse?
- If I want to call an external application as a child, then should I use fork() or threads to do it?
- While doing google search I found people saying it is bad thing to call a fork() inside a thread. why do people want to call a fork() inside a thread when they do similar things?
- Is it True that fork() cannot take advantage of multiprocessor system because parent and child process don't run simultaneously?