Difference between revisions of "Architecture/Proposal/Advanced Threading-Architecture"
From Apache OpenOffice Wiki
(First sketch.) |
m (Refined code sample.) |
||
Line 17: | Line 17: | ||
Pseudo Code for event loop: | Pseudo Code for event loop: | ||
<code>void dispatch(int signal) {</code> | <code>void dispatch(int signal) {</code> | ||
+ | <code> switch(signal) {</code> | ||
+ | <code> case SIGIO:</code> | ||
+ | <code> fileHandler(getHandle());</code> | ||
+ | <code> break;</code> | ||
+ | <code> case SIGTERM:</code> | ||
<code> ...</code> | <code> ...</code> | ||
+ | <code> }</code> | ||
<code>}</code> | <code>}</code> | ||
<code></code> | <code></code> |
Revision as of 09:36, 7 April 2006
state: sketch
Concept: A purely event driven threading architecture, including asynchronous process related signals, I/O and window messages.
- Pros
- Not calling blocking system calls leads to 'short' lasting mutex acquisitions.
- No hand crafted reschedules necessary anymore.
- Easy utilization of Hyper Threading, multi cores and SMP.
- Controlable CPU utilization and possible avoidance of over utilization.
- 'Simple' architecture.
- One single location where to create threads.
- Cons
- (assumed to be) Hard to implement.
Pseudo Code for event loop:
void dispatch(int signal) {
switch(signal) {
case SIGIO:
fileHandler(getHandle());
break;
case SIGTERM:
...
}
}
int quit;
sigset_t sigset;
int main(void) {
int signal;
while(!quit) {
sigwait(&sigset, &signal);
dispatch(signal);
}
return 0;
}