Cancelsichere Bibliotheks- und Systemfunktionen

Asynchronous CancellationSafe Functions

  • grundsätzlich sind POSIX Bibliotheksfunktionen nicht asynchron cancelsicher
  • d.h. wenn Programm async. cancelsafe sein soll, dann sollte man einen Wrapper rund um die Funktion machen
 #define async_cancel_safe_read(fd, but, amt) \
     { \
     int oldtype; \
     pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, &oldtype); \
     if ( read( fd, buf, amt) < 0 ) \
         perror("read"), exit(-1);    \
     pthread_setcanceltype(oldtype, NULL); \
     pthread_testcancel(); \
     }

Cancellation Punkte in System- und Bibliotheksaufrufen

  • bei Deferred Cancellation kann ein Thread nur an wohl definierten Punkten unterbrochen werden
  • grundsätzlich dienen alle Funktionen, welche tendenziell lange brauchen (meistens I/O) als Cancellation Points
  • siehe Liste p184

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Use <fn>...</fn> to insert automatically numbered footnotes.
  • You can use the <go> tags just like the <a> for nicer urls.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.