diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2012-05-15 09:41:27 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2012-05-15 09:41:57 +0530 |
commit | 439bf404b8fa125cf950dc1aa37838702c5353ea (patch) | |
tree | da5913033bcfa18987da0aabf69ad99b751772a3 /nptl/descr.h | |
parent | 2949684c162a4413e42249d6b2ad554cb468b5be (diff) | |
download | glibc-439bf404b8fa125cf950dc1aa37838702c5353ea.tar.gz |
Allow a single-threaded program to cancel itself
There is nothing in the POSIX specification to disallow a
single-threaded program from cancelling itself, so we forcibly enable
multiple_threads to allow the next available cancellation point in the
thread to run.
Also added additional tests to cover various cancellation scenarios.
Diffstat (limited to 'nptl/descr.h')
-rw-r--r-- | nptl/descr.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nptl/descr.h b/nptl/descr.h index c2fabeb1a0..60d2d22e7a 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -131,6 +131,21 @@ struct pthread #else struct { + /* multiple_threads is enabled either when the process has spawned at + least one thread or when a single-threaded process cancels itself. + This enables additional code to introduce locking before doing some + compare_and_exchange operations and also enable cancellation points. + The concepts of multiple threads and cancellation points ideally + should be separate, since it is not necessary for multiple threads to + have been created for cancellation points to be enabled, as is the + case is when single-threaded process cancels itself. + + Since enabling multiple_threads enables additional code in + cancellation points and compare_and_exchange operations, there is a + potential for an unneeded performance hit when it is enabled in a + single-threaded, self-canceling process. This is OK though, since a + single-threaded process will enable async cancellation only when it + looks to cancel itself and is hence going to end anyway. */ int multiple_threads; int gscope_flag; # ifndef __ASSUME_PRIVATE_FUTEX |