timeout/callout small step forward

Hans Petter Selasky hselasky at c2i.net
Sat Mar 29 03:12:32 PDT 2008


Hi,

How does this patch handle when multiple callouts use the same mutex ? Imagine 
that two threads are about to lock the same mutex, then the second thread 
will get nowhere while waiting for the first thread to execute the callback.

I think the solution is that callbacks are put in a tree. Giant locked 
callbacks go all into the same tree. Else the user of callouts is responsible 
for making up the tree.

struct callout {
	struct thread *exec_td;
	struct callout *parent;
};

struct callout *c;

while (c->parent != NULL) {
	c = c->parent;
}

if (c->exec_td != NULL) {
	callout should go into the same thread;
} else {
	pick the next free thread and set "c->exec_td"
}

Callouts that belong to the same tree are run from the same thread. This does 
not only apply for callouts, but also multithreaded node systems ...

Yours
  --HPS


More information about the freebsd-arch mailing list