Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Dec 1999 21:09:20 +0100
From:      "Steffen Merkel" <d_f0rce@gmx.de>
To:        <freebsd-hackers@freebsd.org>
Subject:   Sorry, but another thread problem!
Message-ID:  <000701bf5238$9918aa80$0201a8c0@blade>

next in thread | raw e-mail | index | archive | help
Hello,

first let me thank all of you for all your great help and the dozens
of responses I got.
Unfortunately I have a very strange problem in a multithreaded
programm I'm writing now. I want to write a programm which
checks if a server is up by pinging it. I looks like that:

######################################
main(){
 readconfig()
 
 for (every server){ pthread_create(..... startscan() ); }
 
  while(1){
    sleep(1);
    printf("Main Awake again\n");
  }
}

startscan(){
  ping(server);
  printf("Going to sleep\n");
  sleep(1);
  printf("Awake again!");
}
########################################

I can see that the servers are getting pinged and that every
thread goes to sleep. As soon as every thread did it's job and
the first thread should awake the program get's a SIGSEGV.
I can't see the message "Awake again" from the first thread but
I saw that the first thread started to sleep and the last thread
finished too and the main thread printed "Awake again!".
Well with my little knowledge of C I would say that there is a
problem with the sleep function. But as soon as I remove the
ping() function the programm operates normally and runs forever.

Can anyone tell me how I can debug such a problem? A program
which seems to crash because of function which doesn't get executed
at crash time.

Meanwhile I'm going mad with those threads because the program
worked fine using fork(). Unfortunately it takes too much ram to
fork a process for every server. That's the reason I want to use
threads.

Steffen

PS: Sorry that I have to bother you again with my incompetence.

Please reply directly to me because I'm not on the list.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000701bf5238$9918aa80$0201a8c0>