dougp@voodoo.ucsb.edu (07/22/89)
-Message-Text-Follows- Is there any particular reasor that no microprocessor has limit registors for the stack? What I mean by limit registers is a pair of registors which contains the minimum alowable stack address and the maximum alowable stack address, and cause an exception, trap or interrupt when some code attempts to move the stack pointer out of the range they discribe. Asside from making stack problems much easier to find, this would make it possible to build code which had a dinamicly sized stack. When you got a stack overflow, the exception handler could alocate a new block of memory, move the stack ponter to this new memory and reset the limits. The stack underflow would work similarly, freeing the extra stack space and moving the stack pointer to the previous block. Now this could get a bit messy if you were in a tight loop which was pushing and poping right at the discontinuity of the stack, but this would cirtainly aleviate the problems with programs that sometimes need 200000 bytes of stack when you've only alocated 4000. Douglas Peale
ckp@grebyn.com (Checkpoint Technologies) (07/24/89)
In article <2105@hub.UUCP> dougp@voodoo.ucsb.edu writes: > > Is there any particular reasor that no microprocessor has limit >registors for the stack? What I mean by limit registers is a pair of >registors which contains the minimum alowable stack address and the >maximum alowable stack address, and cause an exception, trap or >interrupt when some code attempts to move the stack pointer out of >the range they discribe. Well, the DEC KDJ11 microprocessor has a stack lower limit register, but this is only for the kernel stack pointer. For simple stack limit checking, you can create unaddressable pages on either end of the stack with a decent MMU (the A2500 has just such an MMU but can't use it this way just yet). Other than those two - I don't know of any CPUs with hardware stack range checking, and I agree it would be a useful item. Or else... use the new Motorola 88000 RISC architecture - it has no built-in concept of a stack... -- First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / / \\ / / Then, the disclaimer: All expressed opinions are, indeed, factual. \ / o Now for the witty part: I'm pink, therefore, I'm spam! \/
cmcmanis%pepper@Sun.COM (Chuck McManis) (07/25/89)
In article <2105@hub.UUCP> dougp@voodoo.ucsb.edu writes: > Is there any particular reasor that no microprocessor has limit >registors for the stack? The 80286/386/486 all have a limit set for their stack segment. If you attempt to write outside of it in either direction it will generate an exception. The Motorola architectures don't include an on chip MMU (until the '030 came along) and since this is primarily an MMU question they left it up to the application to appropriately intialize the MMU. The Lattice compiler generates code to check for stack overflow before entering each function. However it does this by knowing how much stack the function you are calling is going to take. For DOS calls it has to guess, sometimes it guesses wrong. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you. "A most excellent barbarian ... Genghis Kahn!"
pds@quintus.UUCP (Peter Schachte) (07/27/89)
In article <12238@grebyn.com> ckp@grebyn.UUCP (Checkpoint Technologies) writes: >In article <2105@hub.UUCP> dougp@voodoo.ucsb.edu writes: >> >> Is there any particular reasor that no microprocessor has limit >>registors for the stack? The DEC10 does better. On the DEC10, registers are 36 bits wide, divided into two 18 bit half-words. Each half word is big enough to hold an address (256K WORD address space, kind of small). So a stack pointer on holds the top of stack address in one half word, and the stack space remaining in the other half word. PUSH increments one half and decrements the other, signaling an exception if it hits 0. Very nice. -- -Peter Schachte pds@quintus.uucp ...!sun!quintus!pds
sjk@ut-emx.UUCP (sjk) (08/11/89)
[Sorry, if this is a re-post; I think my last attempt bounced.] I have written a couple of programs which seem to require large stacks in which to run, so I have two questions: 1) How can I tell just how large a stack a given program will need? Or is it all just trial and error? 2) What do I lose by always runnig with a larger stack so I don't run my programs, forgetting to change the stack, and wind up visiting meditation heaven? Thanks for any wisdom departed! Scot (Kleinman) sjk@astro.as.utexas.edu Bdah! - M
ain@mentor.cc.purdue.edu (Pat-bob White) (08/12/89)
In article <16943@ut-emx.UUCP> sjk@ut-emx.UUCP (sjk) writes: >I have written a couple of programs which seem to require large >stacks in which to run, so I have two questions: >1) How can I tell just how large a stack a given program will > need? Or is it all just trial and error? I asked this of the authors of Manx & Lattice C at an Amiexpo two years ago and got a response pretty much like "you just have to guess". Seems to me that one could pretty easily ask where the stack is at the beginning of a function call.. but then one must select input to drive the program to use the maximum amount of stack. >2) What do I lose by always runnig with a larger stack so I don't > run my programs, forgetting to change the stack, and wind up > visiting meditation heaven? A separate stack is allocated for every program while it runs -- if you run them with more stack then they need, you have less memory to use while they are running. hope this helps, Pat White ARPA/UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421 U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906 Life is a joke.. so laugh at it :-)
451061@UOTTAWA.BITNET (Valentin Pepelea) (08/12/89)
In article <16943@ut-emx.UUCP> sjk@ut-emx.UUCP (sjk) writes: > I have written a couple of programs which seem to require large > stacks in which to run, so I have two questions: > > 1) How can I tell just how large a stack a given program will > need? Or is it all just trial and error? Look in the Transactor, V2.2, it gives you a function which will let you know how much stack the program you write consumes. Valentin _________________________________________________________________________ "An operating system without Name: Valentin Pepelea virtual memory is an operating Phonet: (613) 231-7476 system without virtue." Bitnet: 451061@Uottawa.bitnet Usenet: Use cunyvm.cuny.edu gate - Ancient Inca Proverb Planet: 451061@acadvm1.UOttawa.CA
perley@vdsvax.crd.ge.com (Perley Donald P) (08/17/89)
In article <16943@ut-emx.UUCP> sjk@ut-emx.UUCP (sjk) writes: >2) What do I lose by always runnig with a larger stack so I don't > run my programs, forgetting to change the stack, and wind up > visiting meditation heaven? As someone pointed out, programs with small stack requirements will get large stacks, chewing up your available memory. One advantage to running programs from the workbench (icon clicking), is that you can specify the stack size in the icon file, and automatically get a large one for programs that need it. I think one of the process spawning programs lets you specify stack size (maybe "runbg, but I'm not sure). Using this in conjuction with an alias in your startup file would also let you get a big stack everytime you run that monster program. -- -don perley perley@crd.ge.com