Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Mar 2008 13:21:13 +0100
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        freebsd-arch@freebsd.org
Cc:        arch@freebsd.org
Subject:   Re: timeout/callout small step forward
Message-ID:  <200803291321.15896.hselasky@c2i.net>
In-Reply-To: <20080328235600.O72156@desktop>
References:  <10004.1205307334@critter.freebsd.dk> <200803291013.28797.hselasky@c2i.net> <20080328235600.O72156@desktop>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Jeff,

Probably you're right that the chance of congestion is not very high, hence 
most clients will use a per-object lock, except for Giant locked systems. 
Though it would be nice if you could get this part right while you are  first 
working at it.

I get the feeling that you understand my point: Multiple worker threads will 
not help if the functions called by the worker threads are protected by the 
same mutex. Then it is better to run these in series on the same thread.

--HPS

On Saturday 29 March 2008, Jeff Roberson wrote:
> On Sat, 29 Mar 2008, Hans Petter Selasky wrote:
> > 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.
>
> You are worried that there will be too much contention or that there is
> some correctness issue?
>
> If you're worried about contention, it would seem that most callers use
> some per-object mutex for the callout.  So there isn't likely to be
> much contention among callouts.
>
> > 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
>
> _______________________________________________
> freebsd-arch@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-arch
> To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803291321.15896.hselasky>