c - What are pthread cancelation points used for? -


In some cases the respondents say that unless the programmers do not know that they are doing the pthread cancellation points (in many cases) If there are very well, the cancellation points should not be used.

My question --- what is the use of pthread cancellation points?

[Updated from the comment]

  1. Does a cancellation status allow those specific API calls to be canceled?
  2. Why not others and others?
  3. Does anyone want to use them for something else?
  4. Is he a hack to deal with a problem in the kernel, or are they contained in some things that are with posics?
  5. Do you want to use the user-level code or only the cancellation point in the API?

    whether a cancellation point allows to cancel those special API calls is?

    Stuck with PTHREAD_CANCEL_DEFERRED, this can be the center of confusion. You are thinking about it at the rear side about the Allow system call (the API does not name your name) to cancel the cancellation point, checks the call whether a cancellation request is pending or No. Conceptually you can think about this (manually) setting a switch Automatic cancellation points will check whether it is in effect and a deliberate call to pthread_testcancel where convenient or otherwise necessary - For example, between a long moving calculation loop where can not be otherwise cancellable system call cancellation points automatically call any pthread cleanup handlers For those who were set and which can be chained in the same way as atexit calls.

    Many people choose (if this is practical for their situation) to set their own switches and the means of closing the thread at that point in the thread when they check the switch PTHREAD_CANCEL_DEFERRED is basically that it (possibly) provides several points on steroids where this switch examines perceptively and by this the developer will consider the implications of cancellation at each of those points. Mitigation is forced.

    Why not those and others? / P>

    You will need to discuss this on a call basis, but the main reason is due to unexpected side effects.

    Do you have user-level code or just in the API?

    Yes, you want to use them in user-level code. You know as a programmer what resource you are using and how the thread has been canceled and how to clear the logical implications of canceling at any point.

    PTHREAD_CANCEL_ASYNCHRONOUS wax and another ball of your own nightmare. Conceptually you can think about this almost because the thread is being destroyed by a kill signal - it can be interrupted anywhere - but it provides the opportunity to run clean up handlers. The problem is that it is really difficult to do that eg What if this is canceled between malloc ? It is, in fact, quite useless outside the carefully thought out situations.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -