Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* OSF DCE Threads
@ 1996-04-19  4:00 Christof Sieber
  1996-04-22  4:00 ` Dave Butenhof
  0 siblings, 1 reply; 2+ messages in thread
From: Christof Sieber @ 1996-04-19  4:00 UTC (permalink / raw)



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 <stdio.h>
#include <dce/pthread.h>

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);
}




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-04-22  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-04-19  4:00 OSF DCE Threads Christof Sieber
1996-04-22  4:00 ` Dave Butenhof

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox