From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9ba4,3345513c14be87b9,start X-Google-Attributes: gidf9ba4,public X-Google-Thread: f678f,3345513c14be87b9,start X-Google-Attributes: gidf678f,public X-Google-Thread: fee84,3345513c14be87b9,start X-Google-Attributes: gidfee84,public From: winkler@ibc.inf.tu-dresden.de (Matthias Winkler) Subject: [Q]: pthreads - How do you enforce a timeout? Date: 1995/04/19 Message-ID: <3n2j6u$fms@ibch10.inf.tu-dresden.de>#1/1 X-Deja-AN: 101096473 distribution: world followup-to: comp.soft-sys.dce content-type: text/plain; charset=ISO-8859-1 organization: Dept. of Computer Science, TU Dresden, Germany keywords: macros, timeout, pthreads mime-version: 1.0 newsgroups: comp.soft-sys.dce,comp.unix.osf.osf1,comp.unix.osf.misc, Hi, I wrote a function foo() that I want to terminate primaturely in case it does not return within a given period of time. I thought I could kick off a pthread for foo() which is a bit of a hassle since I have to pass the params of foo() as pthread_addr_t, however this is not the real problem. After a certain amount of time has elapsed I call pthread_cancel() to terminate foo(). With this solution I have to adapt foo() - it now has to accept exactly one parameter of pthread_addr_t. What I would like was to find a way to define macros so I could write: BEGIN_MONITOR_TIMEOUT(seconds) { foo(param1, param2, param3, param4); } END_MONITOR_TIMEOUT; Does somebody have a clue on how this could be implemented? Am I right in the assumption that one can not simply use exceptions to terminate a thread since you can not raise an exception to a specific thread in a straightforward manner. Thank you, Matthias