Difference between revisions of "Architecture/Proposal/Advanced Threading-Architecture"

From Apache OpenOffice Wiki
Jump to: navigation, search
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 14: Line 14:
 
* (assumed to be) Hard to implement.
 
* (assumed to be) Hard to implement.
  
 +
Pseudo Code for event loop:
 +
<pre>
 +
void dispatch(int signal) {
 +
  switch(signal) {
 +
  case SIGIO:
 +
    fileHandler(getHandle());
 +
    break;
 +
  case SIGTERM:
 +
    ...
 +
  }
 +
}
  
Pseudo Code for event loop:
+
int quit;
<code>void dispatch(int signal) {</code>
+
sigset_t sigset;
<code>  switch(signal) {</code>
+
 
<code>  case SIGIO:</code>
+
int main(void) {
<code>    fileHandler(getHandle());</code>
+
  int signal;
<code>    break;</code>
 
<code>  case SIGTERM:</code>
 
<code>  ...</code>
 
<code>  }</code>
 
<code>}</code>
 
<code></code>
 
<code>int quit;</code>
 
<code>sigset_t sigset;</code>
 
<code></code>
 
<code>int main(void) {</code>
 
<code>  int signal;</code>
 
<code></code>
 
<code>  while(!quit) {</code>
 
<code>    sigwait(&sigset, &signal);</code>
 
<code>    dispatch(signal);</code>
 
<code>  }</code>
 
<code></code>
 
<code>  return 0;</code>
 
<code>}</code>
 
  
 +
  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;
}

Graphical overview:
Spec Architecture Threading Advanced.jpg

Personal tools