Changes between Version 3 and Version 4 of kernel_synchro


Ignore:
Timestamp:
Oct 8, 2018, 1:00:59 PM (6 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • kernel_synchro

    v3 v4  
    1515== B) busylocks & remote_busylocks ==
    1616
    17 The '''busylock''' (local) and '''remote_busylock''' (global) are low-level locks implementing a busy-waiting policy for the calling threads. If the lock is already taken by another thread, the calling thread keep polling the lock until success. They are used to protect exclusive  higher level synchronisation primitives (such as the ''queuelocks'' or ''rwlocks'' described below) , or ''simple'' data-structure where the access time is small and can be bounded.
     17The '''busylock''' (local) and '''remote_busylock''' (global) are low-level locks implementing a busy-waiting policy for the calling threads. If the lock is already taken by another thread, the calling thread keep polling the lock until success. They are used to protect higher level synchronisation primitives (such as the ''queuelocks'' or ''rwlocks'' described below) , or ''simple'' data-structure where the locking time is small and can be bounded.
    1818
    19 A thread holding a busy lock cannot reschedule. To enforce this rule, the ''busylock_acquire()'' function enter' a critical section before taking the lock, and saves the SR value in the busy lock descriptor. The thread holding the busy lock  exit the critical section when it calls the ''busylock_release()'' function that releases the lock and restores the SR state. Each time a thread acquire a busy lock, it increments a busylocks counter in the thread descriptor, and decrements is when it releases the lock.
     19A thread holding a busy lock cannot deschedule. To enforce this rule, the ''busylock_acquire()'' function enters a critical section before taking the lock, and saves the SR value in the busy lock descriptor. The thread holding the busy lock  exit the critical section when it calls the ''busylock_release()'' function that releases the lock and restores the SR state. Each time a thread acquire a busylock, it increments a busylocks counter in the thread descriptor, and decrements it when it releases the lock.
    2020The scheduler makes a kernel panic if the current thread busylocks counter is not nul when it executes the ''sched_yield()'' function.
    2121
    22 To avoid starvation, the ''busylock_acquire()'' function uses a ticket policy: the calling thread makes an atomic increment on a "ticket" allocator in lock descriptor, and keep polling the "current" value  until current == ticket. To release the lock, the ''busylock_release()'' function increments the "current" value in lock descriptor.
     22To improve fairness, the ''busylock_acquire()'' function uses a ticket policy: the calling thread makes an atomic increment on a ''ticket'' allocator in lock descriptor, and keep polling the ''current'' value  until ''current'' == ''ticket''. To release the lock, the ''busylock_release()'' function increments the "current" value in lock descriptor.
    2323
    2424== C) queuelock & remote_queuelock ==