What is “stack thrash”? Or “a stack thrash”? (Since I don’t know the definition I’m not sure if it is a countable or uncountable term.)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Stack thrashing is like heap thrashing, but on the stack.
There, now that’s explained.
Oh, you want more detail huh ?
If you emulate a stack based processor on a processor that isn’t you’re thrashing the stack.
If your C code malloc’s and free’s every other line of code, you’re thrashing the heap.
The point of stack thrashing as a problem is that if you profiled your code, the CPU spending pretty much all it’s time popping and pushing.
For heap thrashing that’s malloc() & free() being your #1 & #2 most used functions.
Now some CPU’s ( rockwell make some) actually are optimized to run a stack based language in hardware.
Oddly enough, the Java Virtual Machine is a stack based model.
Running a really dumb FORTH implementation on x86 hardware will thrash the stack.
The sort of thing you might write after reading the Forth spec, so you emit x86 machine code for forth instructions and DONT optimize it. Forth guys, I apologise, I know your implmentations are a lot better.
Postscript is stack based too, which makes early postscript printers exciting: they had limited ram and slow CPU’s: and ran a stack-thrashing language. I’m sure a lot of effort went into things like the original Apple Laserwriter to make it run better.
It had a Motorola 68000 CPU running at (10ish) megahertz and 1Mb of ram IIRC.
Again, stack thrashers.
Did that help ?