From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,6d9dcbc18ca0e5d4,start X-Google-Attributes: gidfee84,public From: cs2@irz.inf.tu-dresden.de (Christof Sieber) Subject: OSF DCE Threads Date: 1996/04/19 Message-ID: <4l828e$cio@irz201.inf.tu-dresden.de>#1/1 X-Deja-AN: 148375262 distribution: world content-type: text/plain; charset=ISO-8859-1 organization: Dept. of Computer Science, TU Dresden, Germany mime-version: 1.0 newsgroups: comp.unix.osf.osf1 I wrote a program which creates a single thread. The thread only makes a printf(..) in an endless loop. A pthread_cancel(...) delivered to these thread causes the program to halt - not only the thread. Why ? Following test program runs on a DEC ALPHA. Operation System Version is DEC OSF/1 V3.2A (Rev. 17). Compiled and linked: gcc thread.c -Wall -ldce -lpthreads -lmach -lc_r -lm \ -D_SHARED_LIBRARIES -I. -Dalpha -D_REENTRANT Christof. #include #include unsigned long operation(pthread_addr_t arg) { unsigned long *p = (unsigned long*)arg; if (pthread_setcancel (CANCEL_ON) == -1) printf("pthread_setcancel failed.\n"); if (pthread_setasynccancel (CANCEL_ON) == -1) printf("pthread_setasynccancel failed.\n"); while (1) { printf("Thread %ld\n", *p); } } int main() { pthread_t thread; unsigned long ulArg; struct timespec time; time.tv_sec = 1; time.tv_nsec = 0; ulArg = 1; if (pthread_create (&thread, pthread_attr_default, (pthread_startroutine_t)operation, (pthread_addr_t)&ulArg) == -1) { printf("pthread_create failed.\n"); } pthread_delay_np(&time); pthread_cancel(thread); pthread_delay_np(&time); printf("Process finished.\n"); return(0); }