Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site cheviot.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxb!mhuxr!ulysses!allegra!bellcore!decvax!genrad!panda!talcott!harvard!seismo!mcvax!ukc!cheviot!robert From: robert@cheviot.UUCP (Robert Stroud) Newsgroups: net.unix-wizards Subject: Re: stack space mapping question Message-ID: <248@cheviot.UUCP> Date: Tue, 5-Feb-85 13:09:18 EST Article-I.D.: cheviot.248 Posted: Tue Feb 5 13:09:18 1985 Date-Received: Fri, 8-Feb-85 03:25:21 EST References: <21131@arizona.UUCP> Reply-To: robert@cheviot.UUCP (Robert Stroud) Distribution: net Organization: U. of Newcastle upon Tyne, U.K. Lines: 48 Summary: In article <21131@arizona.UUCP> whm@arizona.UUCP (Bill Mitchell) asks whether stack pages grabbed while the stack is deep are ever reclaimed by the system when the stack recedes. > On 4.2 on Suns and Vaxes, the system does allow (based >on empirical studies rather than code examination) access to pages below >the sp as long as they were properly contained in the stack at some point >in time. Is this implementation dependent or is this some sort of standard >Unix "feature"? > > Thanks in advance, > Bill Mitchell > whm.arizona@csnet-relay > {ihnp4,noao,mcnc,utah-cs}!arizona!whm I don't know about more recent versions of Unix, but this was a "feature" of the PDP-11 V7 implementation where I first met Unix. I used it to extend my data area beyond 56K without fear of a segmentation violation. The memory mapping hardware on this PDP-11 restricted you to 8 segments, each of which could address up to 8K in steps of 64 bytes - or something like that. Because Unix must always have a stack segment, you couldn't extend your memory (using sbrk) beyond 56K (or 8 - 1 segments). However, if you extended the stack segment to its full 8K by setting, de-referencing and then re-setting the stack pointer, and set your break to 56K, then the full 64K address space was addressable without any danger of segmentation violation, and you could sneak a few extra bytes into the bottom of the stack segment from the top of the data segment. The danger with this is that you lose the memory protection facilities and stack overflow checks, but as far as I could tell, the memory was never reclaimed. Obviously, a more modern Unix uses much more sophisticated memory management hardware, so this part of the kernel code has probably been completely rewritten. On the other hand, if it was in V7.... I wasn't particularly proud of this trick, but it got me out of a hole. If anyone else out there is still using PDP-11's(!), they may find it useful. Robert Stroud, Computing Laboratory, University of Newcastle upon Tyne. ARPA robert%cheviot%newcastle.mailnet@mit-multics.arpa UUCP ...!ukc!cheviot!robert "Unix is what runs on Dennis Ritchie's machine!"