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

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Added category.)
m (Slightly improved.)
Line 1: Line 1:
state: sketch
+
State: draft
 +
Type: Proposal
  
Concept: '''A purely event driven [threading] architecture, including asynchronous process related signals, I/O and window messages.'''
+
==Advanced OOo Threading Architecture==
 +
The advanced threading architecture aims to solve OOs multi threading and concurrency problems.
  
;Pros:
+
===Problem===
* Not calling blocking system calls leads to 'short' lasting mutex acquisitions.
+
The following list gives a brief overview, of where the problems lie,
 +
* unresponsive user interface,
 +
* busy waiting (e.g. frequent re-schedule or yield calls),
 +
* scalability with multiple threads, in particular when doing API programming,
 +
* operations (e.g. loading, saving, printing etc.) are not interruptable.
 +
 
 +
===Solution===
 +
OOo must be changed to be purely event / callback driven.
 +
 
 +
The following list gives a first idea, of what should be done,
 +
* all (potentially) blocking calls need to be event driven,
 +
* all long lasting calls need to be executed by dedicated threads, notifying the consumers via events / callbacks, in case data is available,
 +
* asynchronous signals need to be mapped to events,
 +
* Windows window messages need to be mapped to events,
 +
* the threading architecture must be defined high level, e.g.
 +
** concurrency per application, or
 +
** concurrency per document.
 +
 
 +
====Pros====
 +
* Not calling potential blocking system calls leads to 'short' lasting mutex acquisitions.
 
* No hand crafted reschedules necessary anymore.
 
* No hand crafted reschedules necessary anymore.
 
* Easy utilization of Hyper Threading, multi cores and SMP.  
 
* Easy utilization of Hyper Threading, multi cores and SMP.  
Line 11: Line 32:
 
* One single location where to create threads.
 
* One single location where to create threads.
  
;Cons:
+
====Cons====
 
* (assumed to be) Hard to implement.
 
* (assumed to be) Hard to implement.
  

Revision as of 16:00, 6 July 2006

State: draft Type: Proposal

Advanced OOo Threading Architecture

The advanced threading architecture aims to solve OOs multi threading and concurrency problems.

Problem

The following list gives a brief overview, of where the problems lie,

  • unresponsive user interface,
  • busy waiting (e.g. frequent re-schedule or yield calls),
  • scalability with multiple threads, in particular when doing API programming,
  • operations (e.g. loading, saving, printing etc.) are not interruptable.

Solution

OOo must be changed to be purely event / callback driven.

The following list gives a first idea, of what should be done,

  • all (potentially) blocking calls need to be event driven,
  • all long lasting calls need to be executed by dedicated threads, notifying the consumers via events / callbacks, in case data is available,
  • asynchronous signals need to be mapped to events,
  • Windows window messages need to be mapped to events,
  • the threading architecture must be defined high level, e.g.
    • concurrency per application, or
    • concurrency per document.

Pros

  • Not calling potential 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