Thin Lock Implementation

BCS ao at pathlink.com
Wed Aug 20 10:30:39 PDT 2008


Reply to Walter,

> Walter Bright wrote:
> 
>> BCS wrote:
>> 
>>>> The memory isn't committed until it is used, but the address space
>>>> is. You cannot move the stack if it exceeds its preallocated
>>>> address space allotment.
>>>> 
>>> Must the stack be contiguous? Could you, on a stack overflow, heap
>>> allocate a new chunk and put in a frame that gets back to the last
>>> segment?
>>> 
>> No.
>> 
> I suppose I should explain a bit more. Stack overflows are detected by
> the hardware, which means every PUSH could overflow the stack. It
> isn't practical to then try and continue the stack elsewhere, because
> the corresponding POPs would not know what was going on.
> 

That's what the extra stack frame I mentioned is for. I'll grant you can't 
split a single frame across the sections but if you cold detect an impending 
stack overflow before the function runs (by push/popping the largest block 
that the function can use [calloc aside]) you could then do the new stack 
at that point. When the function returns, it ends up in the extra frame and 
it knows how to return to the right location.





More information about the Digitalmars-d mailing list