Efficient mechanism for preventing starvation in counting semaphores
First Claim
Patent Images
1. A method for allocating resources to threads in a counting semaphore, said method comprising:
- maintaining a count of how many of the resources the semaphore currently has available for the threads;
putting threads to sleep on a wait queue if the semaphore does not have enough of the resources available to satisfy a thread;
waking a thread up from the wait queue if resources become available for the thread;
allowing other threads to steal resources from the woken threads before the woken threads can execute; and
allowing a starving thread to be woken and execute if the starving thread has had more than a predetermined maximum number of resources stolen from it.
1 Assignment
0 Petitions
Accused Products
Abstract
An algorithm for preventing starving threads in a counting semaphore for a computer operating system. The algorithm operates in a stealing mode where threads can steal resources from other threads if none of the threads is starving, and operates in a first-in first-out mode if one or more of the threads becomes starving.
15 Citations
21 Claims
-
1. A method for allocating resources to threads in a counting semaphore, said method comprising:
-
maintaining a count of how many of the resources the semaphore currently has available for the threads;
putting threads to sleep on a wait queue if the semaphore does not have enough of the resources available to satisfy a thread;
waking a thread up from the wait queue if resources become available for the thread;
allowing other threads to steal resources from the woken threads before the woken threads can execute; and
allowing a starving thread to be woken and execute if the starving thread has had more than a predetermined maximum number of resources stolen from it. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
-
-
13. A method for allocating resources to threads in a counting semaphore, said method comprising:
-
operating in a stealing mode where threads can steal resources from other threads if none of the threads is starving; and
operating in a first-in first-out mode if one or more of the threads are starving. - View Dependent Claims (14, 15, 16, 17, 18)
-
-
19. A method for allocating resources to threads in a counting semaphore, said method comprising:
-
maintaining a count of how many of the resources the semaphore currently has available for the threads;
putting threads to sleep on a wait queue if the semaphore does not have enough of the resources available to satisfy a thread;
waking a thread up from the wait queue if resources become available for the thread;
maintaining a count of how many resources are needed by the threads that have been woken from the wait queue and are waiting to execute;
maintaining a count of how many resources the sleeping threads and the woken threads have attempted to get from the semaphore, but have failed;
allowing other threads to steal resources from the woken thread before the woken thread can execute;
allowing other threads to steal resources from a thread sleeping at a front of the wait queue if the sleeping thread needs a plurality of resources and the semaphore has fewer resources available than the sleeping thread needs;
maintaining a count of the number of resources that are stolen from a thread to determine if the thread is starving;
allowing a starving thread to be woken and execute if the starving thread has had more than a predetermined number of resources stolen from it, wherein allowing a starving thread to be woken and execute includes putting the starving thread at the front of the wait queue; and
returning to allowing threads to steal resources when the starved thread uses the resources. - View Dependent Claims (20, 21)
-
Specification