Strange problem with gettimeoftheday function


 
Thread Tools Search this Thread
Operating Systems Linux Strange problem with gettimeoftheday function
# 1  
Old 04-11-2008
Bug 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. Smilie 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,
# 2  
Old 04-11-2008
Bug Re Strange problem with gettimeofthe day

Sorry I mentioned the function name wrongly. It is gettimeofday and not gettimeoftheday.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strange third argument in shell function

In one of my shell function I found the following set_default_values () { prog=$1 PROC_DT=$2 RESET_ALL="${3-N}" #echo "Processing date as passed = , Program name = " ...... I understand the first and second arguments, but don't understand... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

Strange function call in the shell script parse_prog_args $@

I am converting shell script to Perl. In shell I have a code parse_prog_args() { if then while do case $1 in -P* | -p* ) export PROCESS_DATE=$2 export MM=`echo $2 | cut -c5-6` export DD=`echo $2 | cut -c7-8` export YY=`echo $2 | cut -c3-4` export... (4 Replies)
Discussion started by: digioleg54
4 Replies

3. Shell Programming and Scripting

strange problem

hello all, i am having problem in accessing a directory.I dont think its a permission issue.can anyone help me out. I am using korn sell code: $ ls -ltr sc* lrwxrwxrwx 1 essbase essbase 21 Oct 8 2010 sc_ssp -> /work/nfs/nas2/sc_ssp $ cd sc_ssp ksh: sc_ssp: not found $ (6 Replies)
Discussion started by: manid
6 Replies

4. Shell Programming and Scripting

Strange Problem

Hi All, I am encountering an unexpected problem while running my process, using daemon placed in /etc/init.d/. I have a process that is opening shared library using dlopen. When I run my process on the command line, it is able to open the library. But when I used daemon to run my process, I... (0 Replies)
Discussion started by: qwerty-1
0 Replies

5. UNIX and Linux Applications

strange behavior of PSQL user defined function

Segregated the problematic portion, and showing for your view here., 1. Following is the function definition, create or replace function new_del(id integer) returns void as $$ begin raise info 'dollar :%',$1; delete from testing where id=$1; end ; $$ language 'plpgsql'; ... (1 Reply)
Discussion started by: thegeek
1 Replies

6. Shell Programming and Scripting

Strange problem.

Well, my script started off to do what i wanted. Now, i think its not recognizing the pattern so its not moving anything. What i have to do is execute my script command for the move to take effect. So i did that and yayy it worked. Strange thing is that my DESTDIR was empty to begin with.... (2 Replies)
Discussion started by: oxoxo
2 Replies

7. Shell Programming and Scripting

Very strange things happened in the shell function

Here is the script: #!/bin/bash #set -xv RAWDATAFILE="temp1" GOODDATAFILE="temp2" FindSOS() { local NUM=0 #return value for the id of SOS local cnt=1 if grep "EOS" $1 then sed -e 's/.*<CobDate>//' -e 's/<\/.*//' <$1 > ${RAWDATAFILE} sed -n -e '/EOS/,/SOS/ s/*/&/p' <${RAWDATAFILE}... (2 Replies)
Discussion started by: tpltp
2 Replies

8. UNIX for Dummies Questions & Answers

Converting gettimeoftheday output to string

Hi .. is there a way i can retrieve the output of gettimeoftheday in a string (1 Reply)
Discussion started by: p_aishwarya
1 Replies

9. Shell Programming and Scripting

Strange problem

I am using SunOS 5.9 and I don't know why all my commands are getting executed as if an extra 'enter' has been pressed. What could be the reason and how to correct it? Please help. Asty (2 Replies)
Discussion started by: Asty
2 Replies

10. UNIX for Dummies Questions & Answers

Strange problem.Please Help !

I¡¯m a network operator, mine is an IBM PC server 320, operating system SCO unix 3.2v4.2, triton 3.1 of Baan. Recently, my server went dead every a few hours, no sign & signal shows malfunction suddenly. It looks like a sudden power failure, but the indicator of main power supply is on. Normal... (1 Reply)
Discussion started by: lyhsm
1 Replies
Login or Register to Ask a Question