The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-11-2008
xyz123456 xyz123456 is offline
Registered User
 

Join Date: Apr 2008
Posts: 4
Smile Strange problem with gettimeoftheday function

Hi all,
I am using pthread_cond_timedwait function in my program, to generate the time period of waiting i use gettimeoftheday function.

When i run the code after compiling i get a core dump error. However my program runs perfectly if i give a printf statement before the gettimeoftheday function. Can anyone explain this problem . I have pasted the part of the code for your reference:

pthread_mutex_lock(&lock);
//printf("After core dump \n");
gettimeofday(&tp, NULL);
ts.tv_sec = tp.tv_sec;
ts.tv_nsec = tp.tv_usec * 1000;
ts.tv_sec += WAIT_TIME_SECONDS;
pthread_cond_timedwait(&write, &lock, &ts);
pthread_mutex_unlock(&lock);

Thanks in advance,
Reply With Quote
Forum Sponsor