Changeset 624 for trunk/kernel/libk/busylock.h
- Timestamp:
- Mar 12, 2019, 1:37:38 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/busylock.h
r623 r624 2 2 * busylock.h: local kernel busy-waiting lock definition. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018 )4 * Authors Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 34 34 * a shared object located in a given cluster, made by thread(s) running in same cluster. 35 35 * It uses a busy waiting policy when the lock is taken by another thread, and should 36 * be used to execute very short actions, such as accessing basic allocators ,or higher36 * be used to execute very short actions, such as accessing basic allocators or higher 37 37 * level synchronisation objects (barriers, queuelocks, or rwlocks). 38 * WARNING: a thread cannot yield when it is owning a busylock.39 38 * 40 39 * - To acquire the lock, we use a ticket policy to avoid starvation: the calling thread … … 42 41 * value until current == ticket. 43 42 * 44 * - To release the lock, the owner thread increments the "current" value, 45 * decrements its busylocks counter. 43 * - To release the lock, the owner thread increments the "current" value. 46 44 * 47 * - When a thread takes a busylock, it enters a critical section: the busylock_acquire()45 * - When a thread takes a busylock, it enters a critical section: the acquire() 48 46 * function disables the IRQs, takes the lock, increments the thread busylocks counter, 49 * andsave the SR in lock descriptor and returns.47 * save the SR in lock descriptor and returns. 50 48 * 51 * - The busylock_release() function releases the lock, decrements the thread busylock52 * counter, restores the SR to exit the critical section, and returns 49 * - The release() function releases the lock, decrements the thread busylock 50 * counter, restores the SR to exit the critical section, and returns. 53 51 * 54 * - If a thread owning a busylock (local or remote) tries to deschedule, the scheduler 55 * signals a kernel panic. 52 * WARNING: a thread cannot yield when it is holding a busylock (local or remote). 53 * 54 * This rule is checked by all functions containing a thread_yield() AND by the scheduler, 55 * thanks to the busylocks counter stored in the calling thread descriptor. 56 * 1) all functions call "thread_assert_can_yield()" before calling "thread_yield()". 57 * 2) The scheduler checks that the calling thread does not hold any busylock. 58 * In case of violation the core goes to sleep after a [PANIC] message on TXT0. 56 59 ******************************************************************************************/ 57 60 58 61 /******************************************************************************************* 59 62 * This structure defines a busylock. 60 * The < type> and <xlist> fields are used for debug.61 * The typedefines the lock usage as detailed in the kernel_config.h file.63 * The <xlist> field is only used when DEBUG_BUSYLOCK is set. 64 * The <type> field defines the lock usage as detailed in the kernel_config.h file. 62 65 ******************************************************************************************/ 63 66
Note: See TracChangeset
for help on using the changeset viewer.