Cancelsichere Bibliotheks- und Systemfunktionen
Submitted by rac on 13 January, 2008 - 18:30.
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
»
- Printer-friendly version
- Download PDF
- 466 reads

Post new comment