Messages in this thread | | | From | Ingo Oeser <> | Subject | Re: [PATCH] Replace completions with semaphores | Date | Wed, 16 Apr 2008 18:07:24 +0200 |
| |
On Tuesday 15 April 2008, Linus Torvalds wrote: > Would it make sense to use completions for countable events too? Yeah. In > fact, we have some things that really would like to do counting, both in > the sense of "wait for <n> events to all complete" _and_ in the sense of > "allow up to <n> events to be outstanding". Both of which could be done as > a counting function (just make "complete" increment the counter, and then > make "wait for <n> events" initialize it to negative, while "allow <n> > outstanding events" would be a positive counter, and make > "wait_for_completion()" basically be a "decrement and wait until it
Hmm, why not introduce a provide_slots(), wait_for_slot() and free_slot() API?
provide_slots() := initialize a resource with N available slots wait_for_slot() := wait for a slot in countable resource to be free free_slot() := make a slot available
That would: - fit the use case nicely - could be optimized for countable resources with upper limits - allow to measure slot utilization - ... - is not called semaphore :-)
And isn't this the same problem (called scheduling) as: - keeping N cpus busy - keeping N (disk) spindles busy - keeping N nic transmit queues busy - ...
???
But maybe I oversimplify here :-)
Best Regards
Ingo Oeser
| |