Difference between revisions of "Architecture/Proposal/Advanced Threading-Architecture"
From Apache OpenOffice Wiki
m (Refined code sample.) |
(Simplfied wiki code.) |
||
Line 1: | Line 1: | ||
state: sketch | state: sketch | ||
− | Concept: '''A purely event driven threading architecture, including asynchronous process related signals, I/O and window messages.''' | + | Concept: '''A purely event driven [threading] architecture, including asynchronous process related signals, I/O and window messages.''' |
;Pros: | ;Pros: | ||
Line 13: | Line 13: | ||
;Cons: | ;Cons: | ||
* (assumed to be) Hard to implement. | * (assumed to be) Hard to implement. | ||
− | |||
Pseudo Code for event loop: | Pseudo Code for event loop: | ||
− | + | <pre> | |
− | + | 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; | ||
+ | } | ||
+ | </pre> | ||
Graphical overview:<br> | Graphical overview:<br> | ||
[[Image:Spec_Architecture_Threading_Advanced.jpg]] | [[Image:Spec_Architecture_Threading_Advanced.jpg]] |
Revision as of 14:33, 21 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; }