Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!+ From: Richard.Draves@CS.CMU.EDU Newsgroups: comp.os.mach Subject: Re: timeout on condition_wait() Message-ID: Date: 22 Feb 90 07:28:08 GMT References: <375@kgw2.bwi.WEC.COM> Distribution: usa Organization: Carnegie Mellon, Pittsburgh, PA Lines: 18 In-Reply-To: <375@kgw2.bwi.WEC.COM> Excerpts from netnews.comp.os.mach: 16-Feb-90 timeout on condition_wait() Eric Hammond@kgw2.bwi.WE (2340) > ===> I want to do a condition_wait() with a timeout. <=== I would solve this problem by developing a new abstract data type, timer_condition_t. Export operations like timer_condition_signal, timer_condition_broadcast, timer_condition_wait (which takes a timeout). The question then is how to implement the ADT. One possibility is to have a service thread that is responsible for waking up timed-out sleepers. The service thread would have a queue of wait events. Each wait event would also be on a list tied to the timer_condition_t. The wait event would contain a normal condition_t that is used to do the actual sleeps/wakeups; each sleeping cthread would have its own wait event. And of course you'd need appropriate locking. Rich