Date: Thu, 11 Jul 2002 22:04:48 -0700 (PDT) From: Archie Cobbs <archie@dellroad.org> To: Archie Cobbs <archie@dellroad.org> Cc: John Baldwin <jhb@FreeBSD.ORG>, davidx@viasoft.com.cn, freebsd-arch@FreeBSD.ORG, julian@elischer.org Subject: Re: Timeout and SMP race Message-ID: <200207120504.g6C54m736085@arch20m.dellroad.org> In-Reply-To: <200207101815.g6AIFDm28655@arch20m.dellroad.org> "from Archie Cobbs at Jul 10, 2002 11:15:13 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Archie Cobbs writes: > FWIW, here is an API I've used before. This handles all race > conditions and the 'other thread' question. I should also mention that if we were to implement this API it may be useful to generalize it to handle arbitrary events rather than just timeout events (this is how I've implemented it in our application). For example, 'user defined' events could be triggered from any thread simply by calling a trigger function. This would be like an 'event' version of tsleep(): instead of sleeping for the event, a callback function (handler) that you provide would be called when the event occurs. The key is that you get the same benefits mentioned before, i.e., your mutex would already be held when your handler is invoked, there's no race between the handler and cancelling the event, etc. Event-based programming is more efficient than threads when you don't require a stack to store your state while waiting for the event. Not sure how many instances there are in the kernel that could benefit from this however. -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207120504.g6C54m736085>