On Tue, 17 June 2008 12:52:22 -0700, Tim Bird wrote:
Well, there should be a way to ensure this doesn't hog the cpu at all -
unless it is idle or someone is actually waiting for the initialization
to finish. Not sure if nice 19 is good enough for that.
If you want to keep things simple - and I believe initially you should -
you can simply do all initializations in one go. Something like this:
int foo_open(...)
{
wait_for_deferred_init();
...
}
static DECLARE_COMPLETION(init_complete);
void wait_for_deferred_init(void)
{
static atomic_t in_progress = ATOMIC_INIT(-1);
if (!atomic_inc_not_zero(in_progress) {
wait_for_completion(init_complete);
return;
}
for (all deferred initcalls)
foo_init();
complete(init_complete);
free_memory();
}
Jörn
--
Anything that can go wrong, will.
-- Finagle's Law
--