Datenbuffering zwischen Threads

- Zum Austauschen von Daten zwischen Threads
- geht in verschiedenen Modellen
Datenbuffering
Wichtige Begriffe:
- Buffer
- Lock
- Suspend / resume Mechanismus
- Zustandsinfo (Status): wieviel Daten sind im Buffer

  1. producer() {
  2.      ...
  3.      lock shared buffer
  4.      place results in buffer
  5.      unlock buffer
  6.      wake up any consumer threads
  7.      ...
  8. }
  9. consumer() {
  10.      ...
  11.      lock shared buffer
  12.      while buffer is empty
  13.           release lock and sleep
  14.           wake up and reacquire lock
  15.      fetch data from buffer
  16.      unlock buffer
  17.      ...
  18. }

Was Passiert, wenn der Produzent schneller als der Konsument ist?
Dafür gibt es Double Buffering!
Wann kann es angewendet werden:
- wenn Threads miteinander Daten tauschen
- Thread gegenüber anderem Thread sowohl Produzent als auch Konsument
- z.B. bei Peer Modell
Double Buffering

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Use <fn>...</fn> to insert automatically numbered footnotes.
  • You can use the <go> tags just like the <a> for nicer urls.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.