This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

printf & ptrhread_cancel()


Hi,
I work with pc386 platform (cvs Snapshot April 5 2001)

There is simple test:

#include <stdio.h>
#include <pthread.h>
#include <time.h>
void *thread_routine(void *arg)
{ 
  for(int count=0;;count++) {
    for(int i=0; i<0x500000; i++);
    printf("%d\n",count);
    /* pthread_testcancel() ;*/
  }
  return NULL;
}
int main()
{
  void *p;    
  pthread_t th;
  pthread_create(&th, NULL, thread_routine, 0);
  for(;;)  {
    for(int i=0; i<0x1000000; i++);
    printf("Cancel...\n");  pthread_cancel(th);
    printf("join ...");   pthread_join(th, &p);   printf(" ret=%x\n", (int)p);
    if ( p == PTHREAD_CANCELED ) 
      break;
  }
}

It prints:
0 
1  
Cancel...

If printf() is a cancellation point, I should see on the screen: "join...ret=..."
If printf() is not cancellation point,  thread_routine () should work.
But after pthread_cancel() call the system "dies".

What's wrong?

If I uncomment  pthread_testcancel() in thread_routine, it works properly.

My  configuration:
ecosconfig new pc elix
ecosconfig remove CYGPKG_NET
ecosconfig remove CYGPKG_IO_ETH_DRIVERS
CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS =1
CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG = 1

Thanks in advance.

--
Boris Guzhov,
St.Petersburg, Russia





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