×

Efficient mechanism for preventing starvation in counting semaphores

  • US 7,984,439 B2
  • Filed: 03/08/2005
  • Issued: 07/19/2011
  • Est. Priority Date: 03/08/2005
  • Status: Expired due to Fees
First Claim
Patent Images

1. A computer-implemented method for allocating a plurality of resources to a plurality of threads in a counting semaphore that protects the plurality of resources, said method comprising:

  • maintaining a count of how many of the resources the semaphore currently has available for the threads;

    putting one of the threads to sleep on a wait queue if the semaphore does not have enough of the protected resources that are available to satisfy the one of the threads;

    waking the sleeping thread up from the wait queue if the protected resources become available for the sleeping thread;

    allowing other threads to steal the protected resources from the woken thread before the woken thread can execute;

    allowing a starving one of the threads to be woken and execute if the starving one of the threads has had more than a predetermined maximum number of the protected resources stolen from it;

    allowing other threads to steal resources from the sleeping thread on the wait queue if the sleeping thread needs the plurality of protected resources and the semaphore has fewer of the protected resources available than the sleeping thread needs; and

    maintaining a count of the number of the protected resources that are stolen from one of the threads to determine if the thread is starving.

View all claims
  • 1 Assignment
Timeline View
Assignment View
    ×
    ×