Date: Fri, 12 Jul 2002 16:33:30 -0700 From: Peter Wemm <peter@wemm.org> To: Terry Lambert <tlambert2@mindspring.com> Cc: Yar Tikhiy <yar@comp.chem.msu.su>, hackers@freebsd.org Subject: Re: Large variables on stack Message-ID: <20020712233330.9259A3811@overcee.wemm.org> In-Reply-To: <3D2F4DE4.932D4995@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert wrote: > Yar Tikhiy wrote: > > As I see, there are many spots in the FreeBSD userland sources where > > multi-kilobyte automatic variables (e.g., string buffers) are used. > > I've been taught that such variables would better be static or > > allocated on heap. > > > > So the following question comes to my mind: To stay portable to a > > reasonable degree, how large on-stack variables can be used? > > Depends on the system and the stack. Typically, if you want your > code to be portable, you will use as little stack as possible: > > -------------- --------------------------------------------------- > Space Stack size > -------------- --------------------------------------------------- > user 8MB (FreeBSD: 64MB) > user thread 8K (or settable by user on pthread_create) > user signals 40K[8K] (or settable via sigaltstack) > kernel 8K (max; usable is closer to 4K) > -------------- --------------------------------------------------- > > Note that this assumes none of the stack is used elsewhere; in the > kernel example, ther is slightly over 3K used, on average, by the > time you get to run. FWIW; This isn't correct for -current anymore. We have about 7.6K of kernel stack now, and a guard page below it to force a double fault in case of an oveflow. The pcb is above the kernel stack now, and the user area is completely seperate. Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 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?20020712233330.9259A3811>