Question:
disadvantage of Multithreaded Processes?
safasalem87
17 years ago
why a multithread processes not always perfect than a single thread process?
is there any problems in using multithread processes?
Three answers:
Random Malefactor
17 years ago
I take it you mean besides the possibility of thread sync logic problems? (Multi-threaded programs must be more carefully designed, the basic paradigm becomes considerably more complex with the introduction of multiple threads of execution.)



That aside, there is a phenomena called 'cache sloshing' that will make a multi-threaded program run slower on multiple CPUs than it does on a single CPU. It happens when L2 cache ranges of multiple processors overlap a portion of physical memory. When this occurs, each time slice on the memory bus equates to a reload of L2 cache from memory -- a very expensive overhead op to incur on every bus time slice. (Only one processor can own the memory bus at any given instant.)



The one time I encountered this in a project I was working on, we solved it by allocating an unused chunk of RAM bigger than L2 cache, in between each thread's working memory. Wasteful? Absolutely, but it beat all hell out of scaling negatively under all conditions!
digitallyneosticated
17 years ago
Multithreading generally occurs by time-division multiplexing ("time slicing") in very much the same way as the parallel execution of multiple tasks (computer multitasking): the processor switches between different threads. This context switching can happen so fast as to give the illusion of simultaneity to an end user.



The operating system overhead involved with scheduling and otherwise dealing with a thread, when taken together with the frequency with which the thread does its job, outweighs the amount of work actually performed by that thread. In other words, if a thread does only a little bit of work, but does it very often, the overhead incurred by the operating system as it tries to schedule your thread to run many times per second can outweigh the other benefits you might have sought to gain by introducing the thread into your program. Keep in mind that this does not mean that each thread has to do lots of work when it runs. Having a thread that runs very infrequently, and that does a little bit of work when it does run, is not going to cause system performance to drop. It's threads that wake up and run very often, and that do only a little bit of work when they do run, that will degrade the performance of not only your application, but the machine as a whole.
Matthew
17 years ago
none other than maybe a small price difference by far worth it for future-proofing your pc


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...