发明名称 Lock free acquisition and release of a semaphore in a multi-core processor environment
摘要 A method for an acquisition of a semaphore for a thread includes decrementing a semaphore count, storing a current thread context of the semaphore when the semaphore count is less than a first predetermined value, determining a release count of a pending queue associated with the semaphore where the pending queue indicates unpended threads of the semaphore, and adding the thread to the pending queue when the release count is less than a second predetermined value.
申请公布号 US9342379(B2) 申请公布日期 2016.05.17
申请号 US201113011116 申请日期 2011.01.21
申请人 WIND RIVER SYSTEMS, INC. 发明人 Richardson Raymond
分类号 G06F9/46;G06F9/52;G06F9/30 主分类号 G06F9/46
代理机构 Fay Kaplun & Marcin, LLP 代理人 Fay Kaplun & Marcin, LLP
主权项 1. A method, comprising: acquiring a semaphore for a current thread from a data structure, wherein the data structure associates the semaphore with a generation number; concurrently with acquiring the semaphore, identifying the associated generation number as one of valid and invalid; concurrently with acquiring the semaphore, identifying a deletion flag as one of set and not set; decrementing a semaphore count of the semaphore upon acquisition of the semaphore when the associated generation number is identified as valid and the deletion flag is identified as not set, wherein the acquisition of the semaphore and a scheduling of the acquisition of the semaphore are both not controlled with a lock; initializing a scheduler stack upon storing a current thread context of the semaphore when the semaphore count is less than or equal to a first predetermined value; locking interrupts to prevent a new operation from preempting a pending operation on the semaphore upon initializing the scheduler stack; determining a release count of a pending queue associated with the semaphore, the release count is determined based on a predetermined threshold number of threads that can be added to the pending queue of the semaphore; generating a thread identification for the current thread when the release count is zero; and adding the thread identification to the pending queue as a representation of the current thread when the release count is less than a second predetermined value.
地址 Alameda CA US