3

I understand that when reaching cancellation point it's checked whether request to cancel thread was made or not. In my code the request is made AFTER thread enters sleep(1000) call.

So can anyone explain exactly when is cancellation status checked ? is that when reaching cancellation point or during execution of cancellation point call given the sleep() example

  • 2
    [Posix documentation](http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html): *If a thread has cancelability enabled and a cancellation request is made with the thread as a target while the thread is suspended at a cancellation point, the thread shall be awakened and the cancellation request shall be acted upon. However, if the thread is suspended at a cancellation point and the event for which it is waiting occurs before the cancellation request is acted upon, it is unspecified whether the cancellation request is acted upon [...].* – EOF Aug 07 '18 at 15:21
  • The first answer here: https://stackoverflow.com/questions/23220206/what-are-pthread-cancelation-points-used-for contains the answer to your question. The last paragraph of the second answer is very good advise. – mevets Jun 10 '20 at 17:55

0 Answers0