From: winkler@ibc.inf.tu-dresden.de (Matthias Winkler)
Subject: [Q]: pthreads - How do you enforce a timeout?
Date: 1995/04/19 [thread overview]
Message-ID: <3n2j6u$fms@ibch10.inf.tu-dresden.de> (raw)
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
reply other threads:[~1995-04-19 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox