Linked by Hadrien Grasland on Thu 19th May 2011 21:31 UTC
Permalink for comment 474044
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 06/13/13 14:35 UTC
Linked by Thom Holwerda on 06/11/13 17:07 UTC
Linked by Thom Holwerda on 06/10/13 23:13 UTC
Linked by Thom Holwerda on 06/08/13 14:57 UTC
Linked by Thom Holwerda on 06/07/13 11:40 UTC
Linked by Thom Holwerda on 06/04/13 12:45 UTC
Linked by nfeske on 05/31/13 10:12 UTC
Linked by Thom Holwerda on 05/29/13 16:59 UTC
Linked by Thom Holwerda on 05/24/13 17:26 UTC
Linked by Thom Holwerda on 05/21/13 21:38 UTC
More Features »
Sponsored Links



Member since:
2010-03-08
If things which can run in parallel run in parallel, you get better scalability than with an all-sequential model like async. That's why we have threads at all. They are cheap (or more exactly can be made so). Why not use them ?
If the task is not CPU-bound, and we consider IO waiting times that are typically orders of magnitude larger than instruction execution times, the overhead of creating a thread, which is pretty small on modern hardware, will be irrelevant, since creating a thread is essentially a CPU/memory-bound operation.
If the task is CPU-bound, threads offer significantly better performance.
So you either lose nothing or win a lot. I don't know what's the problem with that.
Again, I'll refer to the asynchronous model as having solved these problems. By handling events asynchronously without threads, all of the overhead disappears since no blocking/synchronization is necessary. Since only one stack is needed for CPU, it should fit entirely within the CPU's L1 cache.
If so much synchronization is needed that it has a significant impact on interrupt processing speed, it is indeed better to use async. That's another reason (apart from the big developer laziness one) why I support both models.
That's why I talk about ease of programming. Multi-threaded programming is harder. You have to get in the right mindset to get it right. But once you get some basic coding patterns that prevent deadlocks and races, I don't think there are so many things that can go wrong.
Which implies going back to the kernel, creating a thread, and waiting until the scheduler dares to run it. Why not have the kernel just do it right away ?
Again, how can processing events sequentially be any more scalable than processing them in parallel ?
But yeah, you're right, separate threads have also other benefits, like a stack/CPU state cleanup each time a new event is processed, or way to introduce "timeout" mechanisms so that if an event takes too much time to be processed, the driver simply reverts the changes and jumps to the next event (effectively reducing the impact of hung drivers).
Yeah, I implicitely included it in "enabling interrupts again". Drivers shouldn't be trusted for that, in my opinion.
Yup, that's the whole point of using a threaded model at all. If you don't want this behaviour, you use the async model and run the pop-up threads sequentially.
Drivers have to explicitely make a choice between using a threaded or an async model. If they use a threaded model for an interrupt where races can occur, they know what they're doing and it's up to them to implement the relevant synchronization mechanisms.
Edited 2011-05-20 22:35 UTC