Re: [PATCH] Replace completions with semaphores

From: Ingo Oeser
Date: Wed Apr 16 2008 - 12:02:32 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/