Lock free acquisition and release of a semaphore in a multi-core processor environment
First Claim
Patent Images
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.
3 Assignments
0 Petitions
Accused Products
Abstract
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.
-
Citations
16 Claims
-
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. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A method, comprising:
-
releasing a semaphore for a current thread from a data structure, wherein the data structure associates the semaphore with a generation number; concurrently with releasing the semaphore, incrementing the associated generation number; concurrently with releasing the semaphore, setting a deletion flag; incrementing a semaphore count of the semaphore upon release of the semaphore, wherein the release of the semaphore and a scheduling of the release of the semaphore are both not controlled with a lock; locking the interrupts of the semaphore upon initializing a scheduler stack; determining the presence of a thread in a pending queue of the semaphore when the semaphore count is less than or equal to a first predetermined value, the pending queue including a representation of a current thread, a release count based on a predetermined threshold number of threads that can be added to the pending queue of the semaphore; and removing a head item from the pending queue, based on the pending queue determination, when the pending queue includes at least one pended thread, the head item being a pended thread. - View Dependent Claims (10, 11, 12, 13, 14)
-
-
15. A non-transitory computer readable storage medium with an executable program stored thereon, wherein the program instructs a processor to perform operations 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 thread when the release count is less than a second predetermined value. - View Dependent Claims (16)
-
Specification