aaahas.blogg.se

Terminate pthread c
Terminate pthread c






terminate pthread c

Finally, some threads are able to perform some special cleanup processing as part of being terminated (either through cancellation or through a pthread_exit call). The degree to which a thread persists after it has been asked to go away is known as its cancelability type. Now you must consider when it might go away≈maybe immediately, maybe a bit later. Let's assume that you can indeed cancel this thread. The ability of a thread to go away or not go away when asked by another thread is known as its cancelability state.

terminate pthread c

Now you must reckon whether the thread you've targeted can be canceled at all. Okay, so you've decided that you'd like to cancel a thread. If one thread returns the results you are looking for, all other threads running the same routine could be canceled. In an odd sense, you can consider cancellation to be a very rough synchronization mechanism: after you've canceled a thread, you know exactly where it is in its execution! A simple example of a thread you might want to cancel would be a thread performing a read-only data search. One reason you may want to cancel a thread is to save system resources (such as CPU time) when your program determines that the thread's activity is no longer necessary. Pthreads ProgrammingChapter 4 - Managing Pthreadsīradford Nichols, Dick Buttlar and Jacqueline Proulx FarrellĬopyright ╘ 1996 O'Reilly & Associates, Inc.Ĭancellation allows one thread to terminate another.








Terminate pthread c