Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: cs2@irz.inf.tu-dresden.de (Christof Sieber)
Subject: OSF DCE Threads
Date: 1996/04/19	[thread overview]
Message-ID: <4l828e$cio@irz201.inf.tu-dresden.de> (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);
}




             reply	other threads:[~1996-04-19  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-19  4:00 Christof Sieber [this message]
1996-04-22  4:00 ` OSF DCE Threads Dave Butenhof
read-only archive

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