delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/10/16:06:52

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Lotus-FromDomain: COMPUTRITION
From: Fred_Smith AT computrition DOT com
To: cygwin AT cygwin DOT com
Message-ID: <85256C4E.005D8BCA.00@cinote.computrition.com>
Date: Thu, 10 Oct 2002 13:17:52 -0400
Subject: re: pthreads
Mime-Version: 1.0

Following up on my two messages of yesterday, I've narrowed down a bit the
problem I am having with pthread_cancel(), to the point where the thread
I'm trying to cancel doesn't do ANYTHING but loop. No calls to any other
functions at all, just an endless loop..

When I call pthread_cancel() I get back a return code of 3, and the thread
is not cancelled. (If the thread loops, printing out some distinct text
once per loop, the text keeps right on printing beyond the cancel call, up
until the app actually exits).

The value of the thread ID (pthread_t) is the same all the way through the
program from the moment the thread is created up to and in fact after the
pthread_cancel call fails.

I'm stumped.

Here's some little bits of code....

The thread creation:

        sys_parms.gc_parms.gc_tid = (pthread_t) 0;
        rc = start_gc((void *) &sys_parms);
printf ("sys_parms.gc_parms.gc_tid=%x\n", sys_parms.gc_parms.gc_tid);

and in start_gc:

     pthread_t gc_id;
     ...
     if (pthread_create (&gc_id , &sys_parms->gc_parms.gc_thr_attr, thr_gc,
     sys_parms) != 0)
                     {       /* pthread_create failure */
                     rc = CANNOT_CREATE_GC_THREAD;
                     }
     printf ("gc_id=%x\n", gc_id);
     sys_parms->gc_parms.gc_tid = gc_id;
     printf ("sys_parms->gc_parms.gc_tid=%x\n",
     sys_parms->gc_parms.gc_tid);


then later when we cancel it:

        printf ("sys_parms.gc_parms.gc_tid=%x, rc=%d\n",
sys_parms.gc_parms.gc_tid, rc);
        if (sys_parms.gc_parms.gc_tid != (pthread_t) 0)
                {
                if ((rc = pthread_cancel (sys_parms.gc_parms.gc_tid)) != 0)
                        {
                        uif_print (uif_fd, "%s%s %s%d%s %s%x%s %d%s",
                                "ERROR: in function ", __FUNCTION__,
                                "Cannot cancel Garbage Collection thread,
rc = ",
                                rc, ".\n", "gc_tid = ",
sys_parms.gc_parms.gc_tid,
                                " errno = ", errno, "\n");
                        return EXIT_FAILURE;
                        }
Am I out in left field here in some way that I'm too blind to see?



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019