Przemek:

>So it's general problem with accessing console from other threads.
>To be precise it's KbdPeek() and kbhit() is probably simple wrapper to 
>it.
>It means that OW internals are also effected by this problem.
>The question is if it can be resolved or not. Is it OW bug or problem
>with OS2 API. In GCC it seems to be resolved. The question is how.

>It does not have to be printf() behavior. 1-st it's always better to
>redirect output to file to eliminate possible overwriting. The
>second problem can be caused by possible compile time optimizations
>which can change the order of executed instructions. In such case is
>always good to pass to printf() some pointers to variables which are
>used in function you want to trace to disable such optimization.
>It's the reason why I added s_key pointer to "0. hb_gt_os2_ReadKey(%p)"
>though in this case seems that it wasn't help though I'm not sure
>you replicated it.

In all these tests I use outputs to screen and file and they do not show differences in these cases I was not aware of "optimization" and/or "to pass to printf() some pointers" so at last it was not replicated
>Many thanks for detail tests. We know the problem and now we will have
>to find workaround for it. We can make it in simple way and disable
>input for non main thread. BTW can you check if keyboard input works
>correctly in GCC builds for all threads, f.e. inm code like:

Using this code with current Harbour
-------------
   proc main()
   hb_threadJoin( hb_threadStart( @thFunc() ) )
   return
   proc thFunc()
   local k
      while (k:=inkey(0)) != 27
         ? k
      enddo
   return
-------------

the results are:

gcc335
======
--------------------
[E:\harbour811\harbour] bld_os2.cmd pba3 mt
Harbour 1.1.0dev (Rev. 9903)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'pba3.prg'...
Lines 10, Functions/Procedures 2
Generating C source output to 'pba3.c'... Done.

[E:\harbour811\harbour]pba3.exe

        97
       115
       100
       102
       103
       104
--------------------

OpenWatcom 1.7a
===============
--------------------
[E:\harbour811\harbour]bin\pbaos2.cmd -mt pba3
Open Watcom Linker Version 1.7
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
loading object files
searching libraries
creating an OS/2 32-bit executable
[E:\harbour811\harbour]pba3.exe
SYS1808:
The process has stopped.  The software diagnostic
code (exception code) is  0001.
--------------------


>OS2 KBD API has functions KbdGetFocus() and KbdFreeFocus(). It's possible
>that they will resolve the problem for keyboard input.
>Finally we can simply check in GCC source what exactly it does to
>resolve the problem. Seeing Maurilio comment in gtos2.c I guess that GCC
> for OS2 has its own KbdCharIn() instead of direct mapping:
>   #define KbdCharIn          KBD16CHARIN
>and inside this function the problem is resolved. But I only guess.
>I haven't ever seen this compiler.
>For someone who has some experience with OS2 API the problem should
>be easy to resolve or find workaround or give us an answer if it can >work.
I do not know what is KbdCharIn and KBD16CHARIN but two seem to be 
funtions/procedures
 KbdCharIn is in list of OS/2 API anywhere
KBD16CHARIN, searching in Google/Lycos/HotBot/... appears few times and never explain what is and/or where is
David Macias

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

Reply via email to