Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the POSIX cancellation points?

What are the POSIX cancellation points? I'm looking for a definitive list of POSIX cancellation points.

I'm asking because I have a book that says accept() and select() are cancellation points, but I've seen sites on the internet claim that they are not.

Also, if Linux cancellation points are different than POSIX cancellation points I want a list of them too.

like image 231
Corin Fletcher Avatar asked Jan 11 '09 23:01

Corin Fletcher


People also ask

What are cancellation points?

A cancellation point in general is any point in the control flow where control returns to the scheduler. The only possible meaning of "cancellation" is to not get scheduled again, so you can only cancel something if you can influence the scheduling decisions.

Is Sem_wait a cancellation point?

sem_wait is a cancellation point. It always returns 0. sem_trywait is a non-blocking variant of sem_wait . If the semaphore pointed to by sem has non-zero count, the count is atomically decreased and sem_trywait immediately returns 0.

What are the mechanism are available to cancel the threads?

Asynchronous cancellation − One thread terminates immediately the target thread. Deferred cancellation − The target thread checks periodically whether it should terminate, allowing it an opportunity to terminate itself in an orderly fashion.

What is Cancelling a thread?

Cancellation allows a thread to request the termination of any other thread in the process. Cancellation is an option when all further operations of a related set of threads are undesirable or unnecessary.


1 Answers

The POSIX 1003.1-2003 standard gives a list in the System Interfaces section, then General Information, then Threads (direct link courtesy of A. Rex). (Added: POSIX 1003.1-2008 is now available on the web (all 3872 pages of it, in PDF and HTML). You have to register (free). I got to it from the Open Group Bookstore.)

Cancellation Points

Cancellation points shall occur when a thread is executing the following functions:

  • accept()
  • aio_suspend()
  • clock_nanosleep()
  • close()
  • connect()
  • creat()
  • fcntl() (When the cmd argument is F_SETLKW)
  • fdatasync()
  • fsync()
  • getmsg()
  • getpmsg()
  • lockf()
  • mq_receive()
  • mq_send()
  • mq_timedreceive()
  • mq_timedsend()
  • msgrcv()
  • msgsnd()
  • msync()
  • nanosleep()
  • open()
  • pause()
  • poll()
  • pread()
  • pselect()
  • pthread_cond_timedwait()
  • pthread_cond_wait()
  • pthread_join()
  • pthread_testcancel()
  • putmsg()
  • putpmsg()
  • pwrite()
  • read()
  • readv()
  • recv()
  • recvfrom()
  • recvmsg()
  • select()
  • sem_timedwait()
  • sem_wait()
  • send()
  • sendmsg()
  • sendto()
  • sigpause()
  • sigsuspend()
  • sigtimedwait()
  • sigwait()
  • sigwaitinfo()
  • sleep()
  • system()
  • tcdrain()
  • usleep()
  • wait()
  • waidid()
  • waitpid()
  • write()
  • writev()


A cancellation point may also occur when a thread is executing the following functions:


  • access()
  • asctime()
  • asctime_r()
  • catclose()
  • catgets()
  • catopen()
  • closedir()
  • closelog()
  • ctermid()
  • ctime()
  • ctime_r()
  • dbm_close()
  • dbm_delete()
  • dbm_fetch()
  • dbm_nextkey()
  • dbm_open()
  • dbm_store()
  • dlclose()
  • dlopen()
  • endgrent()
  • endhostent()
  • endnetent()
  • endprotoent()
  • endpwent()
  • endservent()
  • endutxent()
  • fclose()
  • fcntl() (For any value of the cmd argument. [Presumably except F_SETLKW which is listed.]
  • fflush()
  • fgetc()
  • fgetpos()
  • fgets()
  • fgetwc()
  • fgetws()
  • fmtmsg()
  • fopen()
  • fpathconf()
  • fprintf()
  • fputc()
  • fputs()
  • fputwc()
  • fputws()
  • fread()
  • freopen()
  • fscanf()
  • fseek()
  • fseeko()
  • fsetpos()
  • fstat()
  • ftell()
  • ftello()
  • ftw()
  • fwprintf()
  • fwrite()
  • fwscanf()
  • getaddrinfo()
  • getc()
  • getc_unlocked()
  • getchar()
  • getchar_unlocked()
  • getcwd()
  • getdate()
  • getgrent()
  • getgrgid()
  • getgrgid_r()
  • getgrnam()
  • getgrnam_r()
  • gethostbyaddr()
  • gethostbyname()
  • gethostent()
  • gethostid()
  • gethostname()
  • getlogin()
  • getlogin_r()
  • getnameinfo()
  • getnetbyaddr()
  • getnetbyname()
  • getnetent()
  • getopt() (if opterr is non-zero.)
  • getprotobyname()
  • getprotobynumber()
  • getprotoent()
  • getpwent()
  • getpwnam()
  • getpwnam_r()
  • getpwuid()
  • getpwuid_r()
  • gets()
  • getservbyname()
  • getservbyport()
  • getservent()
  • getutxent()
  • getutxid()
  • getutxline()
  • getwc()
  • getwchar()
  • getwd()
  • glob()
  • iconv_close()
  • iconv_open()
  • ioctl()
  • link()
  • localtime()
  • localtime_r()
  • lseek()
  • lstat()
  • mkstemp()
  • mktime()
  • nftw()
  • opendir()
  • openlog()
  • pathconf()
  • pclose()
  • perror()
  • popen()
  • posix_fadvise()
  • posix_fallocate()
  • posix_madvise()
  • posix_openpt()
  • posix_spawn()
  • posix_spawnp()
  • posix_trace_clear()
  • posix_trace_close()
  • posix_trace_create()
  • posix_trace_create_withlog()
  • posix_trace_eventtypelist_getne
  • posix_trace_eventtypelist_rewin
  • posix_trace_flush()
  • posix_trace_get_attr()
  • posix_trace_get_filter()
  • posix_trace_get_status()
  • posix_trace_getnext_event()
  • posix_trace_open()
  • posix_trace_rewind()
  • posix_trace_set_filter()
  • posix_trace_shutdown()
  • posix_trace_timedgetnext_event(
  • posix_typed_mem_open()
  • printf()
  • pthread_rwlock_rdlock()
  • pthread_rwlock_timedrdlock()
  • pthread_rwlock_timedwrlock()
  • pthread_rwlock_wrlock()
  • putc()
  • putc_unlocked()
  • putchar()
  • putchar_unlocked()
  • puts()
  • pututxline()
  • putwc()
  • putwchar()
  • readdir()
  • readdir_r()
  • remove()
  • rename()
  • rewind()
  • rewinddir()
  • scanf()
  • seekdir()
  • semop()
  • setgrent()
  • sethostent()
  • setnetent()
  • setprotoent()
  • setpwent()
  • setservent()
  • setutxent()
  • stat()
  • strerror()
  • strerror_r()
  • strftime()
  • symlink()
  • sync()
  • syslog()
  • tmpfile()
  • tmpnam()
  • ttyname()
  • ttyname_r()
  • tzset()
  • ungetc()
  • ungetwc()
  • unlink()
  • vfprintf()
  • vfwprintf()
  • vprintf()
  • vwprintf()
  • wcsftime()
  • wordexp()
  • wprintf()
  • wscanf()


An implementation shall not introduce cancellation points into any other functions specified in this volume of IEEE Std 1003.1-2001.

The side effects of acting upon a cancellation request while suspended during a call of a function are the same as the side effects that may be seen in a single-threaded program when a call to a function is interrupted by a signal and the given function returns [EINTR]. Any such side effects occur before any cancellation cleanup handlers are called.

Whenever a thread has cancelability enabled and a cancellation request has been made with that thread as the target, and the thread then calls any function that is a cancellation point (such as pthread_testcancel() or read()), the cancellation request shall be acted upon before the function returns. 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 or whether the cancellation request remains pending and the thread resumes normal execution.

Ugh! Can't get the table to work very well it looked OK in preview and nothing like a table afterwards. Look at the URL for the information! There are a lot of possible cancellation points.

like image 92
Jonathan Leffler Avatar answered Oct 16 '22 01:10

Jonathan Leffler