I'm working on a port of ruby-1.9.3-p327 to AmigaOS 4 and as part of this I am working on the system dependent thread implementation code.
What has me confused currently is the implementation of the native_thread_init_stack() function which apparently allocates a region of the thread stack for some kind of virtual machine.
This is what the win32 version of the function looks like:
static void
native_thread_init_stack(rb_thread_t *th)
{
MEMORY_BASIC_INFORMATION mi;
char *base, *end;
DWORD size, space;
CHECK_ERR(VirtualQuery(&mi, &mi, sizeof(mi)));
base = mi.AllocationBase;
end = mi.BaseAddress;
end += mi.RegionSize;
size = end - base;
space = size / 5;
if (space > 1024*1024) space = 1024*1024;
th->machine_stack_start = (VALUE *)end - 1;
th->machine_stack_maxsize = size - space;
}
To me it looks like it's allocating from the upper end of the stack for this and leaves space on the lower end, but shouldn't this be the opposite as FWICT from googling Windows should have a decreasing stack same as AmigaOS?
Also looking at the pthreads version only makes things more confusing as it seems to use the entire stack region leaving no space at all for the thread to use for auto variables?
Edited by salass00 on 2012/12/17 21:47:34