This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

re: pthreads


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]