Changes between Version 4 and Version 5 of scheduler


Ignore:
Timestamp:
Aug 4, 2017, 3:10:27 PM (4 years ago)
Author:
max@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • scheduler

    v4 v5  
    1 Dans cette section nous spécifions l'ordonnanceur d'ALMOS-MKH. Ce dernier est par cœur et a pour rôle de gérer les états des threads. TODO
     1In this section, we describe the scheduling mechanisms used by ALMOS-MKH.
     2
     3== A. Threads List ==
     4
     5There are two lists of threads in ALMOS-MKH: a list of ''user'' threads and a list of ''kernel''
     6threads.
     7
     8== B. Context Switches ==
     9
     10ALMOS-MKH supports switching context among threads only when they do not hold any kernel locks.
     11
     12Context switches have two causes:
     13 * The currently-executing thread explicitly asks to be rescheduled. When such a thing happens,
     14   it is guaranteed that the current thread does not hold any kernel locks.
     15 * A rescheduling interrupt (such as a tick) was received and it is decided that another thread
     16   needs to execute. The mechanism to ensure that the currently-executing thread does not hold
     17   any kernel locks is more complex, and described below.
     18
     19When a rescheduling interrupt is received, the interrupt routine that is called gives a look
     20at the currently-executing thread. If this thread does not hold any kernel locks, the rescheduling
     21is performed right away. Otherwise, the interrupt routine adds a flag in the thread's structure,
     22to indicate that a rescheduling is necessary. The interrupt routine then returns to the original
     23context.
     24
     25The thread keeps executing, and at some point, will release its last lock. When this last release
     26is performed, the thread will give a look at the rescheduling flag in its structure. If this flag
     27is set, the thread performs the rescheduling itself: this behavior is the same as if it was the
     28thread that had asked to be rescheduled in the first place. In this scenario, it is therefore
     29guaranteed that no kernel locks are held.
     30
     31== C. Kernel Mode Preemption ==
     32
     33ALMOS-MKH supports descheduling a userland thread that is currently in kernel mode - as a result
     34of a syscall for example.