Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jan 2000 17:42:43 +0100
From:      "Steffen Merkel" <d_f0rce@gmx.de>
To:        <freebsd-hackers@freebsd.org>
Subject:   Limited amount of variables in a multithreaded programm?
Message-ID:  <001301bf5540$66b72610$0201a8c0@blade>

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

I have a very strange problem here, which is that I can only
define a limited amount of variables within a multithreaded
program.

Some days ago I described the following problem:

>I want to write a programm which checks if a server is up by 
>pinging it. I looks like that:

######################################
main(){

 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.


Meanwhile I was able to trace down the problem within the ping()
function. It seems that I'm defining to many variables.

###########################################
int ping(struct in_addr *ipaddress){
  int s; /* socket handle for socket()*/
  int ident = getpid() & 0xFFFF; /* to ident ICMP message */
  int hlen; /* Header length */
  struct sockaddr_in *to; /* used to prepare tohost */
  struct sockaddr tohost; /* where to send ping - for sendto() */
  struct sockaddr fromhost; 
  struct ip *ip;
  struct icmp *icp; /* used to generate icmp message */
  struct timeval *timetp; /* temporary time storage structure */
  struct timeval actimetp; /* store current time */
  u_char outmessage[MAXPACKET]; /* message we send */
  u_char inmessage[MAXPACKET]; /* message we receive */
  int i,ret;

  int mx_dup_ck = 1024;
  return(10); /* I removed the ping-routine and replaced it with
                    * "return(10);" for testing reasons */
}
################################################

Though the program doesn't fail while it is executing ping() (as
described above), I can make the program run fine, by removing
the line "int mx_dup_ck = 1024;". It seems that the programm
reached a kind of maximum number of variables or something
like that. How can I increase this value or how can I solve my
problem? Any ideas?

Steffen

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?001301bf5540$66b72610$0201a8c0>