On Wed, 24 Sep 2008, Maurilio Longo wrote:

Hi Maurilio,

> I'm not completely sure I do understand the way the pre-loading of the stack
> gets done, but I think it ends up in creating a variable in every C function
> which needs access to the stack.

Exactly.

> Now,
> int f()
> {
>   HB_STACK_TLS_PRELOAD
> }
> becomes (more or less)
> int f()
> {
>   PULONG hb_stack_ptr = hb_tls_get( hb_stack_key );
> }
> where hb_stack_key is an index in win32 but the real memory address in OS/2.
> So, when in win32 you call TlsGetValue( hb_stack_key ) you ask for the content
> of that slot of memory, but when you call DosAllocThreadLocalMemory( 1, &k ),
> 1 means you need a single DWORD, &k will contain the address of that DWORD
> which is local to your thread.

Yes it is. Read my message to David. It will not give noticeable speed
difference in OS2 because it only safes one memory access. Just like
in my Linux box where I can use C compiler TLS support.

> So, when every function calls hb_tls_get() in OS/2, you simply get back what
> you passed to it,

Exactly.

> which is not the original pointer you got with
> DosAllocThreadLocalMemory() since the first call did not save it somewhere.

No, it saved it. It's done in hb_stackInit() which should be the first
function whichop operates on allocated TLM. Then it's safe to call
HB_STACK_TLS_PRELOAD.
But I think you just help me to find the reason of problem.

> Maybe I'm just confused by too many macros and I'm simply missing the real way
>  in which this should work, but after a few hours looking at this problem I
> cannot understand what is not working.
> Can you please confirm what I've said or explain to me how pre-loading is
> intended to work?

I think that the problem is caused by hb_xgrab(). You probably uses memory
statistics enabled in your Harbour builds and David disabled them and
this is the reason why it works for him but not for you. I think that
if you recompile Harbour with -DHB_FM_STATISTICS_OFF then it will work
Just simply I made a typo in hb_stackBaseProcInfo() which is called by
memory statistic module from hb_xgrab() which is used before HVM starts
to register .prg modules. HB_STACK_TLS_PRELOAD should be used _after_
hb_stack_ready() in this function. I'll commit fix in a while.
Thank you very much for your help.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to