0
votes

i just want to clear my concept on multithreading overheads.In a java book "Java Concurrency In Practice"by Brian Göetz i read following paragraph in Chapter-11 section-11.1.


"While the goal maybe to improve performance overall, using multiple threads always introduces some performance costs compared to the single threaded approach. These include the overhead associated with coordinating between threads(locking,signaling,synchronization),increased context switching,thread creation and teardown,and scheduling overhead."


Why did he separate context switching overhead and scheduling overhead. Is thread scheduling overhead not same as context switch overhead. I am confused in both concepts.

1

1 Answers

0
votes

In simple words:

Context switch means in your process one thread would enter in a wait/sleep state and other would enter in run state i.e. start executing. This does means storing the current state of thread that enters wait state and retrieving the other threads current state inorder to start execution of the same from the point where it entered wait state.

Scheduling overhead means once threads enter into runnable state (ready to execute), OS would reschedule it to one of the processor along with resources it might need.