[Gc] Re[3]: GC + Windows Mobile + Threads + Patch for WINCE

Ivan Maidanski ivmai at mail.ru
Fri Aug 21 04:32:06 PDT 2009


Hi!

Zeyi Lee <biosli at hotmail.com> wrote:
> Ivan Maidanski <ivmai at ...> writes:
> >> I see NO functions in WinCE 5.0 can duplicate handles returned by CreateThread.
> >> Could I change the code like this:
> >> +#ifdef UNDER_CE
> >> + /* DuplicateHandle does not exist on WinCE */
> >> + me -> handle = GetCurrentThread();
> >>+#else
> >> + if (!DuplicateHandle(GetCurrentProcess(),
> >> + GetCurrentThread(),
> >> +#endif
> >Yes, this sounds more correct for WinCE UNDER_CE.
> >> Could you pls help review it? Great thanks in advance!
> >Does it work for you with the above changes?
>  
> Unfortunately, the function "GetCurrentThread" kept returning the same handles.

And the value is -2, right? UNDER_CE is defined, right?

Is GetCurrentThread() defined as (look into pre-processor output):
_inline HANDLE GetCurrentThread(void) {
        return ((HANDLE)(SH_CURTHREAD+SYS_HANDLE_BASE));
}

If the answer is yes (for all) then the things are bad - there's no way to get current thread handle (so GC_register_my_thread will not work, and we can never suspend the main thread and ger its context).

> As the program ran and entered the function GC_stop_world, it said as below:
> -------------win32_threads.c------line: 867----  
>       for (i = 0; i < THREAD_TABLE_SZ; i++) {
>         for (t = GC_threads[i]; t != 0; t = t -> next) {
>           if (t -> stack_base != 0
>               && !KNOWN_FINISHED(t)
>               && t -> id != thread_id) 
> {
>                 GC_suspend(t); 
>             }//if
>         } //for
>     }//for
> GC_suspend suspend the main thread  
> Last night I saw a link with the same question as below. And it did pass.
> (http://mirror.facebook.net/sourceware/pthreads-win32/prebuilt-dll-2-5-0-release/WinCE-PORT),

I saw this too. Could you explain "And it did pass"? We have the same solution.

>  
> Could you pls share you thoughts?
>  
> Best wishes,
> GC Beginner
> Zeyi Lee



More information about the Gc mailing list