• Navigation überspringen
  • Zur Navigation
  • Zum Seitenende
Organisationsmenü öffnen Organisationsmenü schließen
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
  • FAUZur zentralen FAU Website
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Suche öffnen
  • English
  • Campo
  • StudOn
  • FAUdir
  • Stellenangebote
  • Lageplan
  • Hilfe im Notfall
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
Menu Menu schließen
  • Lehrstuhl
    • Team
    • Aktuelles
    • Kontakt und Anfahrt
    • Leitbild
    • 50-jähriges Jubiläum
    Portal Lehrstuhl
  • Forschung
    • Forschungsbereiche
      • Betriebssysteme
      • Confidential Computing
      • Embedded Systems Software
      • Verteilte Systeme
    • Projekte
      • AIMBOS
      • BALu
      • BFT2Chain
      • DOSS
      • Mirador
      • NEON
      • PAVE
      • ResPECT
      • Watwa
    • Projektkampagnen
      • maRE
    • Seminar
      • Systemsoftware
    Portal Forschung
  • Publikationen
  • Lehre
    • Sommersemester 2025
      • Applied Software Architecture
      • Ausgewählte Kapitel der Systemsoftware
      • Betriebssystemtechnik
      • Projekt angewandte Systemsoftwaretechnik
      • System-Level Programming
      • Systemnahe Programmierung in C
      • Systemprogrammierung 1
      • Verteilte Systeme
    • Wintersemester 2025/26
      • Systemprogrammierung 2
      • Betriebssysteme
      • Middleware – Cloud Computing
      • Echtzeitsysteme
      • Virtuelle Maschinen
      • Web-basierte Systeme
      • Projekt angewandte Systemsoftwaretechnik
      • Aktuelle Entwicklung in Verteilten und Objektorientierten Betriebssystemen (für Bachelor-/Masterarbeit)
    Portal Lehre
  • Examensarbeiten
  1. Startseite
  2. Extern

Extern

Bereichsnavigation: Lehre
  • Betriebssysteme
    • Vorlesung
      • Folien
    • Übung
      • Seminar
      • Aufgaben
      • Aufgabe 0: C++ Streams
        • Aufgabe 1: Ein-/Ausgabe
          • Aufgabe 2: Unterbrechungen
            • Aufgabe 3: Pro-/Epilog
              • Aufgabe 4: Kontextwechsel
                • Assembler Crashkurs
                  • C++ Crashkurs
                    • Entwicklungsumgebung
                      • FAQ
                        • Ruhmeshalle

                      Aufgabe 4: Kontextwechsel

                      Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
                      Thread Class Referenceabstract
                      Multithreading

                      The is an object used by the scheduler. More...

                      #include <thread/thread.h>

                      + Inheritance diagram for Thread:
                      [legend]
                      + Collaboration diagram for Thread:
                      [legend]

                      Public Member Functions

                       Thread ()
                       Constructor Initializes the context using prepareContext with the highest aligned address of the reserved_stack_space array as stack pointer (top of stack). More...
                       
                      void go ()
                       Activates the first thread on this CPU. More...
                       
                      void resume (Thread *next)
                       Switches from the currently running thread to the next one. More...
                       
                      virtual void action ()=0
                       Method that contains the thread's program code. More...
                       

                      Public Attributes

                      const size_t id
                       Unique ID of thread.
                       
                      volatile bool kill_flag
                       Marker for a dying thread.
                       

                      Static Public Attributes

                      static const size_t STACK_SIZE = 4096
                       Stack size for each thread.
                       

                      Static Protected Member Functions

                      static void kickoff (Thread *object)
                       Function to start a thread. More...
                       

                      Protected Attributes

                      StackPointer stackpointer
                       Current stack pointer of thread for context switch.
                       

                      Detailed Description

                      The is an object used by the scheduler.

                      Constructor & Destructor Documentation

                      Thread::Thread ( )

                      Constructor Initializes the context using prepareContext with the highest aligned address of the reserved_stack_space array as stack pointer (top of stack).

                      Note
                      Remember: Stacks grow to the lower addresses on x86!
                      Todo:
                      Implement constructor

                      Member Function Documentation

                      void Thread::kickoff ( Thread *  object)
                      staticprotected

                      Function to start a thread.

                      For the first activation of a thread, we need a "return address" pointing to a function that will take care of calling C++ virtual methods. For this purpose, we use this kickoff() function.

                      Activating kickoff

                      The thread initialization via prepareContext() not only initializes the Stack for the first thread change, but also pushes the address of kickoff() as return address to the stack. Consequently, the first execution of context_switch() will start execution by returning to the beginning of kickoff() .

                      This kickoff() function simply calls the action() method on the thread passed as parameter and, thus, resolves the virtual C++ method.

                      Note
                      As this function is never actually called, but only executed by returning from the threads's initial stack, it may never return. Otherwise garbage values from the stack will be interpreted as return address and the system might crash.
                      Parameters
                      objectThread to be started
                      Todo:
                      Implement Method
                      void Thread::go ( )

                      Activates the first thread on this CPU.

                      Calling the method starts the first thread on the calling CPU. From then on, Thread::resume() must be used all subsequent context switches.

                      Todo:
                      Implement Method
                      void Thread::resume ( Thread *  next)

                      Switches from the currently running thread to the next one.

                      The values currently present in the non-scratch (callee-saved) registers will be stored on this thread's stack; the corresponding values belonging to next thread will be loaded (from next's stack).

                      Parameters
                      nextPointer to the next thread.
                      Todo:
                      Implement Method
                      Optional:
                      To detect stack overflows you can check if the bottom of the stack still contains a predefined value (which was set in constructor).
                      virtual void Thread::action ( )
                      pure virtual

                      Method that contains the thread's program code.

                      Derived classes are meant to override this method to provide meaningful code to be run in this thread.

                      Implemented in Application, and KeyboardApplication.


                      The documentation for this class was generated from the following files:
                      • thread/thread.h
                      • thread/thread.cc
                      Friedrich-Alexander-Universität
                      Erlangen-Nürnberg

                      Schlossplatz 4
                      91054 Erlangen
                      • Impressum
                      • Datenschutz
                      • Barrierefreiheit
                      • Facebook
                      • RSS Feed
                      • Xing
                      Nach oben