public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* RE: Asynchronous cancel
@ 1999-08-12  6:54 Bossom, John
  0 siblings, 0 replies; 3+ messages in thread
From: Bossom, John @ 1999-08-12  6:54 UTC (permalink / raw)
  To: 'Ross Johnson', Rajiv K Shukla; +Cc: pthreads-win32

To elaborate on Ross' response, pthreadCancelableWait and
pthreadCancelableTimedWait provide developers with a low level
"hook" into the win32-pthread cancellation mechanism.
The cancel mechanism is implemented using a Win32 Event.
pthreadCancelableWait blocks waiting on both the handle you
provide AND the cancel event using WaitForMultipleObjects.

You can leverage these two routines to gain the asynchronous
behaviour you seek provided that you only block on Windows
handles.

Ideally, this mechanism should be used under the sheets,
so to speak, to implement the POSIX cancellation points in the
C run-time library.

Hope this helps...
 


-----Original Message-----
From: Ross Johnson [ mailto:rpj@ise.canberra.edu.au ]
Sent: Thursday, August 12, 1999 7:29 AM
To: Rajiv K Shukla
Cc: pthreads-win32@sourceware.cygnus.com
Subject: Re: Asynchronous cancel


On Tue, 10 Aug 1999, Rajiv K Shukla wrote:

> Hello All,
> 
> Sorry if the question has been asked before. We're trying to see if we
> could use the pthreads-win32 package to port our code to NT. It's been
> fine so far but we have hit a snag. It seems that
> pthread_setcanceltype doesn't really do anything. It sets an integer
> variable cancelType (which is part of the pthread_t structure) but the
> flag is used no where. Looks like the only way to cancel a thread is
> to call pthread_cancel and within the cancelled thread call
> pthread_testcancel. But we'd like to be able to cancel a thread
> asynchronously, e.g one of our thread sleeps for a configurable amount
> of time and it could be set pretty high, 1 hour, or 10 hours, or
> whatever. If within the thread I need to call pthread_testcancel in
> order to be cancelled then it's a problem. We'd have to wait that much
> time before we're even able to call pthread_testcancel. 
> 
> I'd appreciate any suggestion that you may have.
> 

At present there is no way in general to asynchronously cancel a
thread. The best device on offer in the package is the
pthreadCancelableWait() and pthreadCancelableTimedWait() functions
(both non-POSIX and non-portable). See the code and comments in
misc.c. They respond to pthread_cancel().

Cheers.
Ross

+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Asynchronous cancel
       [not found] <199908101804.EAA24054@ise.canberra.edu.au>
@ 1999-08-12  4:34 ` Ross Johnson
  0 siblings, 0 replies; 3+ messages in thread
From: Ross Johnson @ 1999-08-12  4:34 UTC (permalink / raw)
  To: Rajiv K Shukla; +Cc: pthreads-win32

On Tue, 10 Aug 1999, Rajiv K Shukla wrote:

> Hello All,
> 
> Sorry if the question has been asked before. We're trying to see if we
> could use the pthreads-win32 package to port our code to NT. It's been
> fine so far but we have hit a snag. It seems that
> pthread_setcanceltype doesn't really do anything. It sets an integer
> variable cancelType (which is part of the pthread_t structure) but the
> flag is used no where. Looks like the only way to cancel a thread is
> to call pthread_cancel and within the cancelled thread call
> pthread_testcancel. But we'd like to be able to cancel a thread
> asynchronously, e.g one of our thread sleeps for a configurable amount
> of time and it could be set pretty high, 1 hour, or 10 hours, or
> whatever. If within the thread I need to call pthread_testcancel in
> order to be cancelled then it's a problem. We'd have to wait that much
> time before we're even able to call pthread_testcancel. 
> 
> I'd appreciate any suggestion that you may have.
> 

At present there is no way in general to asynchronously cancel a
thread. The best device on offer in the package is the
pthreadCancelableWait() and pthreadCancelableTimedWait() functions
(both non-POSIX and non-portable). See the code and comments in
misc.c. They respond to pthread_cancel().

Cheers.
Ross

+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Asynchronous cancel
@ 1999-08-10 11:03 Rajiv K Shukla
  0 siblings, 0 replies; 3+ messages in thread
From: Rajiv K Shukla @ 1999-08-10 11:03 UTC (permalink / raw)
  To: pthreads-win32

Hello All,

Sorry if the question has been asked before. We're trying to see if we
could use the pthreads-win32 package to port our code to NT. It's been
fine so far but we have hit a snag. It seems that
pthread_setcanceltype doesn't really do anything. It sets an integer
variable cancelType (which is part of the pthread_t structure) but the
flag is used no where. Looks like the only way to cancel a thread is
to call pthread_cancel and within the cancelled thread call
pthread_testcancel. But we'd like to be able to cancel a thread
asynchronously, e.g one of our thread sleeps for a configurable amount
of time and it could be set pretty high, 1 hour, or 10 hours, or
whatever. If within the thread I need to call pthread_testcancel in
order to be cancelled then it's a problem. We'd have to wait that much
time before we're even able to call pthread_testcancel. 

I'd appreciate any suggestion that you may have.

Thank you,

-- Rajiv Shukla

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-12  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-12  6:54 Asynchronous cancel Bossom, John
     [not found] <199908101804.EAA24054@ise.canberra.edu.au>
1999-08-12  4:34 ` Ross Johnson
  -- strict thread matches above, loose matches on Subject: below --
1999-08-10 11:03 Rajiv K Shukla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).