time execution of multithreaded process runing on a multiprocessor system

so i have this question concerning multithreaded processes running on multiprocessors.
my machine has 8 logical processors (4 physical cores and 2 threads per core).
i run a process each time with different number of threads (work of process is distributed on those threads created), and i displayed time for the process to complete execution along with time information displayed by "time command" in Linux.

now the time of execution of the process was decreasing as i increase numbers of threads, which is logical since the work is being divided on the threads and these threads benefit of parallelism. based on what i understand when number of threads> number of processors ie number of threads is 16 for example, the time it takes the process to execute should increase. BUT my results were :

for number of threads = 8 , the time for process execution was 592ms :
enter image description here

and for number of threads=16, the time of process execution was 594ms:
enter image description here

my question is : i only see an increase of 2ms, why it didn’t highly increase since we literally have number of threads in the process double the number of processors

>Solution :

You have a ditch to dig, but you only have 8 shovels. Does it matter much if there are 8 spare workers on coffee-break? Sure, a little time might be lost after the break when the shovels are handed over to the rested diggers but, overall, it’s not going to make much difference to how long it takes to finish the ditch.

Leave a Reply