From owner-freebsd-hackers Mon Jan 3 9: 0:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from luna.lyris.net (luna.shelby.com [207.90.155.6]) by hub.freebsd.org (Postfix) with ESMTP id BC68C14D68 for ; Mon, 3 Jan 2000 09:00:41 -0800 (PST) (envelope-from kip@lyris.com) Received: from luna.shelby.com by luna.lyris.net (8.9.1b+Sun/SMI-SVR4) id JAA05284; Mon, 3 Jan 2000 09:00:05 -0800 (PST) Received: from (luna.shelby.com [207.90.155.6]) by luna.shelby.com with SMTP (MailShield v1.50); Mon, 03 Jan 2000 09:00:05 -0800 Date: Mon, 3 Jan 2000 09:00:05 -0800 (PST) From: Kip Macy To: Martin Cracauer Cc: Steffen Merkel , freebsd-hackers@FreeBSD.ORG Subject: Re: Limited amount of variables in a multithreaded programm? In-Reply-To: <20000103173027.A61058@cons.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SMTP-HELO: luna X-SMTP-MAIL-FROM: kip@lyris.com X-SMTP-RCPT-TO: cracauer@cons.org,d_f0rce@gmx.de,freebsd-hackers@FreeBSD.ORG X-SMTP-PEER-INFO: luna.shelby.com [207.90.155.6] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG What is wrong with malloc, then free? The stack size of threads on FreeBSD is not that big, but there is no need to be declaring large auto variables. Don't get me wrong, I have blown the stack on FreeBSD, and a number of other OSs as well, but dynamic allocation has fixed it in all cases. -Kip On Mon, 3 Jan 2000, Martin Cracauer wrote: > In <001301bf5540$66b72610$0201a8c0@blade>, Steffen Merkel wrote: > > 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 */ > > } > > In FreeBSD, a normal process (fork/exec) has a stack that grows > automatically as needed. You don't have this for threaded programs > (and it is difficult to do). It's a save guess that this amount of > stack allocation is more than the default stack size for a threaded > program, and the stack cannot grow automatically. > > Did you check out the classic model before tangling with pthreads? :-) > > Martin > -- > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > Martin Cracauer http://www.cons.org/cracauer/ > BSD User Group Hamburg, Germany http://www.bsdhh.org/ > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message