From owner-freebsd-hackers Sun Jan 2 8:42:21 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.erlangen.netsurf.de (erlangen.netsurf.de [194.163.170.1]) by hub.freebsd.org (Postfix) with ESMTP id 838FB14E68 for ; Sun, 2 Jan 2000 08:42:18 -0800 (PST) (envelope-from d_f0rce@gmx.de) Received: from blade (user-er-u1.erlangen.netsurf.de [194.163.170.161]) by mail.erlangen.netsurf.de (8.9.3/8.9.3) with SMTP id RAA66483 for ; Sun, 2 Jan 2000 17:42:16 +0100 (CET) Message-ID: <001301bf5540$66b72610$0201a8c0@blade> From: "Steffen Merkel" To: Subject: Limited amount of variables in a multithreaded programm? Date: Sun, 2 Jan 2000 17:42:43 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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