[Betrieb System] - Prozess & Thread

Notizen auf Vorlesung [Betrieb System]

Adressraum:


Prozess A
 ________
|Kern    |
----------
|Stack   |   <---- Stack Pointer
|...     | 
|...     |
|        |
|--------|
|BSS     |
|--------|
|DATA    |
|--------|
|Text    |
|--------|

Stack-Segment: Kellerspeicher

  • Funktionsparameter und lokale Variablen
  • Ruecksprung Adresse

Daten-Segment: globale Daten

  • Data: intialisierte Daten
  • BSS: “block started by symbol” per Konvention mit 0 intialisiert erweiterbar durch systemanruf

Textsegment: Maschinencode

  • nur lesbar, ausfuehrbar
  • erste Seite frei zum erkennen nicht-intialisiert Pointer

Thread-Zustände

  1. aktiv: Thread wird gerade auf der CPU ausgeführt, Pro CPU ist zu jedem Zeitpunkt maximal ein Thread aktiv.

  2. blockiert: Warten auf ein Ereignis (z.B. Botschaft, Freigabe eines Betriebsmittels) um weiterarbeiten zu können

  3. bereit: nicht blockiert, aber momentan nicht aktiv. Die bereit-Menge enthält alle Threads, die ummitttelbar aktic werden können

_________        _______          __________
BLOCKIERT| <-----|Aktiv|  <------ | Bereit |
_________|       |_____|  ------> |________|
    |                                 ^
    |_________________________________|

RANDBEDINGUNGEN:

  • Zu jeder Zeit ist höchstens eine Thread pro CPU aktiv
  • eine aktiber Thread ist zu jedem Zeitpunkt genau einer CPU zugeordnet.
  • nur die bereiten Threads erhalten CPU (werden aktiv)
  • Fairness: jeder THread erhält angemessenen Antel CPU-Zeit, kein Thread darf CPU für sich allein beanspruchen.
  • Wohlverhalten von Threads darf bei Implementierung von Threads keine Voraussetzung sein. z.B. while (true) {} darf nicht dazu führen, dass andere Threads nie wieder “drankommen”

Kooperative vs. präemtive Umschaltung

Cooperative vs Preemtive

Cooperative Preemtive
tasks manage their lifecycle scheduler have control over tasks
Task decides when to yield control back to scheduler Scheduler can interrupt tasks
Assign task to worker that is free Assign a time slice for the task
switch task when it yields control switch task when it yields control or its time is up
can results in hang up won’t hang up for a haning task
Scheduler dont’s needs to care about tasks’ state Scheduler needs to maintain a table of tasks’ state i.e. registers, stack pointer
Low switching overhead High switching overhead
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

        
>> SEND COMMENT <<