Suppose there is a system with 8 cores having 1 thread each and 32 GB of RAM. I want to run in case 1 -> 4 threads of in a single process (threads are independent so no synchronization needed) and case 2 -> 4 processes with single threads each. Keeping aside the memory consumption and the time taken to create them, is there going to be a significant difference in execution times in the above cases on a Linux system ? Why/why not ? Most of the operating system books deal with single core and single threaded systems.
Asked
Active
Viewed 66 times
-1
-
related: https://stackoverflow.com/questions/16354460/forking-vs-threading – NathanOliver May 07 '18 at 19:49
1 Answers
0
Switching threads is cheaper than switching processes since switching threads only requres changing the stack. Switching processes may require invalidating the TLB and slow loading the new page mappings.

doron
- 27,972
- 12
- 65
- 103
-
True. But since we are in a multi-core system, we might not need to context switch the processes as the core count is pretty high. We can make an assumption that not many processes are running on the system. – Yogesh kumar May 07 '18 at 20:12