Go Back   UNIX Socket FAQ > UNIX Platforms > Threads

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2009, 08:10 AM
tomcio tomcio is offline
Regular
 
Join Date: Aug 2006
Location: Poland
Posts: 105
Default pthread and cancellation points

Hello!

I'm trying to do some more advanced things using threads and I don't exactly understand how cancellation points work. I read, that POSIX defines many function as cancellation points (accept(), select(), send() etc.) and also POSIX threads provides pthread_testcancel (). I don't exactly understand when exactly cancellation process is started for threads configured with PTHREAD_CANCEL_DEFERRED option.

One of cancellation points is send() function. Sample pseudocode executed inside thread:
Code:
while (1)
{
send ();
}
What happens when send() is sending some data and I cancel this thread from other place in program. send() execution is canceled immediately and thread exits or cancellation is deferred until next loop iteration?
Reply With Quote
  #2  
Old 07-20-2010, 07:35 AM
i3839 i3839 is offline
Oddministrator
 
Join Date: Jun 2003
Location: Amsterdam
Posts: 2,002
Default

It's cancelled immediately, but if it's a send that doesn't block it might be fast
enough that the next one is cancelled instead.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.