Discussion:
Multithreading support in Harbour
Enrico Maria Giordano
2009-11-04 11:28:46 UTC
Permalink
Dear friends, I'd like to know where to find informations about the current
state of the Harbour support for multithreading and if it's stable enough to
be used in the applications.

Many thanks in advance.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic
Przemysław Czerpak
2009-11-04 12:08:33 UTC
Permalink
Post by Enrico Maria Giordano
Dear friends, I'd like to know where to find informations about the
current state of the Harbour support for multithreading and if it's
stable enough to be used in the applications.
Many thanks in advance.
Look at:
doc/xhb-diff.txt: "MULTI THREAD SUPPORT"

In Harbour MT mode is fully functional and AFAIK is production ready
without any known bugs except 4 document problems which has not been
addressed and maybe never will be because they are not strictly
necessary to create final applications:
1. Tracelog is not MT safe. It's not a big problem for normal
applications because this code is disabled in standard builds and
enabled only on explicit user request during Harbour compilation
to debug some Harbour internals so it's rather for developers only.
2. PROFILLER cannot collect information for each thread separately.
It's optional code disabled by default. Before we will touch it
please think how it should work for MT programs.
3. DEBUGGER: only main thread debugger can see the names of file wide
STATICs and have information about line numbers with good break
points. We should add code to share this information between threads.
4. hb_threadQuitRequest() can be ignored by thread in some cases
due to race condition. It may happen if thread will overwrite
request send by caller simultaneously, f.e. by its own BREAK.
I can resolve it but we can also leave it as is and document
such behavior as expected or even remove this function. Killing
other threads in such way is dangerous and can be used only
for some simple situation. It's much safer when user uses his
own mechanism to terminate treads in some safe for his code places.


Harbour PRG level API:

hb_threadStart( [<nThreadAttrs> ,] <@sStart()> | <bStart> | <cStart> [, <params,...> ] ) -> <pThID>
hb_threadSelf() -> <pThID> | NIL
hb_threadId( [ <pThID> ] ) -> <nThNo>
hb_threadJoin( <pThID> [, @<xRetCode> ] ) -> <lOK>
hb_threadDetach( <pThID> ) -> <lOK>
* hb_threadQuitRequest( <pThID> ) -> <lOK>
hb_threadTerminateAll() -> NIL
hb_threadWaitForAll() -> NIL
hb_threadWait( <pThID> | <apThID>, [ <nTimeOut> ] [, <lAll> ] ) => <nThInd> | <nThCount> | 0
hb_threadOnce( @<onceControl> [, <bAction> ] ) -> <lFirstCall>
hb_mutexCreate() -> <pMtx>
hb_mutexLock( <pMtx> [, <nTimeOut> ] ) -> <lLocked>
hb_mutexUnlock( <pMtx> ) -> <lOK>
hb_mutexNotify( <pMtx> [, <xVal>] ) -> NIL
hb_mutexNotifyAll( <pMtx> [, <xVal>] ) -> NIL
hb_mutexSubscribe( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> <lSubscribed>
hb_mutexSubscribeNow( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> <lSubscribed>

* - this function call can be ignored by the destination thread in some
cases. HVM does not guaranties that the QUIT signal will be always
delivered.

xBase++ compatible functions and classes:
ThreadID() -> <nID>
ThreadObject() -> <oThread>
ThreadWait( <aThreads>, <nTimeOut> ) -> <xResult>
ThreadWaitAll( <aThreads>, <nTimeOut> ) -> <lAllJoind>

Thread() -> <oThread> // create thread object
Signal() -> <oSignal> // create signal object

Harbour supports also SYNC methods and SYNC class method implementing
original xBase++ behavior.

It also supports xBase++ concept of moving workareas between threads
using functions like dbRelease() and dbRequest().

In tests/mt you will find few simple test programs for MT mode.
Some of Harbour tools like hbmk2 or uhttpd[2] (examples/httpsrv,
/examples/uhttpd2) use extensively MT mode.

best regards,
Przemek
Enrico Maria Giordano
2009-11-04 12:51:04 UTC
Permalink
-----Messaggio Originale-----
Da: "Przemysław Czerpak" <druzus-***@public.gmane.org>
A: "Harbour Project Main Developer List." <harbour-pG8skwman+OtlBvVaVFjCkB+***@public.gmane.org>
Data invio: mercoledì 4 novembre 2009 13.08
Oggetto: Re: [Harbour] Multithreading support in Harbour

Many thanks!

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic
Horodyski Marek (PZUZ)
2009-11-04 12:56:23 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 12:29 PM
To: Harbour Project Developers Mailing List
Subject: [Harbour] Multithreading support in Harbour
Dear friends, I'd like to know where to find informations
about the current state of the Harbour support for
multithreading and if it's stable enough to be used in the
applications.
Many thanks in advance.
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).

Regards,
Marek Horodyski
Enrico Maria Giordano
2009-11-04 12:58:30 UTC
Permalink
-----Messaggio Originale-----
Da: "Horodyski Marek (PZUZ)" <M.Horodyski-***@public.gmane.org>
A: "Harbour Project Main Developer List." <harbour-pG8skwman+OtlBvVaVFjCkB+***@public.gmane.org>
Data invio: mercoledì 4 novembre 2009 13.56
Oggetto: RE: [Harbour] Multithreading support in Harbour
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Thank you.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic
Massimo Belgrano
2009-11-04 13:43:31 UTC
Permalink
I not have found any wvt,wvg problem in mt
In my experience In large mt application error is due by my bad code
and not by harbour implementation
Post by Horodyski Marek (PZUZ)
-----Original Message-----
Sent: Wednesday, November 04, 2009 12:29 PM
To: Harbour Project Developers Mailing List
Subject: [Harbour] Multithreading support in Harbour
Dear friends, I'd like to know where to find informations
about the current state of the Harbour support for
multithreading and if it's stable enough to be used in the
applications.
Many thanks in advance.
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Regards,
Marek Horodyski
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
--
Massimo Belgrano
Horodyski Marek (PZUZ)
2009-11-04 14:41:44 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 2:44 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
I not have found any wvt,wvg problem in mt In my experience In
large mt application error is due by my bad code and not by
harbour implementation
Application that is hung, began to change (only) in GT from GTWVG / WVT
to GTWIN.

Regards,
Marek Horodyski
Przemysław Czerpak
2009-11-04 14:45:50 UTC
Permalink
Post by Horodyski Marek (PZUZ)
Application that is hung, began to change (only) in GT from GTWVG / WVT
to GTWIN.
What confirms that it's a problem with your code and it's not Harbour
problem.

best regards,
Przemek
Massimo Belgrano
2009-11-04 15:01:12 UTC
Permalink
try replicate your problem in large program
remove unnecessary part from your program
if give not error add removed part
upload here remain code

Wich error you have
In wich part of your program you receive error

Post follo part
Post by Horodyski Marek (PZUZ)
-----Original Message-----
Sent: Wednesday, November 04, 2009 2:44 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
I not have found any wvt,wvg problem in mt In my experience In
large mt application error is due by my bad code and not by
harbour implementation
Application that is hung, began to change (only) in GT from GTWVG / WVT
to GTWIN.
Regards,
Marek Horodyski
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
--
Massimo Belgrano
Horodyski Marek (PZUZ)
2009-11-04 16:39:58 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 4:01 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
try replicate your problem in large program remove unnecessary
part from your program if give not error add removed part
upload here remain code
I tried - but it is sometimes difficult.
Wich error you have
In wich part of your program you receive error
The application hangs after boot up thread - I call it "corpse cold":)
Post follo part
Small examples go, in real applications to be suspended.
No problem - I wait for GTNET. It will be a good alternative to GTWEB.

Regards,
Marek Horodyski

P.S.
In our company expanded one of the web applications exposed to
customers.
Reaching 50,000 thousand users. Web interface is the future.
Massimo Belgrano
2009-11-04 17:03:56 UTC
Permalink
He Marek
I invite made same research about "corpse cold"
You will have better application or Harbour will have better compiler
Please do this effor for this comunity

regarding GTNET and GTWEB i still remember the post of our Guru
Przemek,
But I'm interesting in sth else. I'd like to have library which I can
use with CUI, GUI and WWW Browsers without source code modification.
IMHO today porting application to GUI only mode is a waste of time.
In few years our programs will have to run in WANs and use many different
output devices like PDA, cellar phones, watches ;-)... We will need
interface which will allow to run application remotely in CUI mode and
when user turn off his terminal in scale register ;-) without closing
application on the server and reconnect from office using desktop computer
he should continue his job in GUI mode in the same instance of application
and finally if he will want then we will have to allow him to finish the
job using PDA and WWW browser when he will return to home.
I plan to work on such library in the future.
i suggest also follow the path of MINIGUI script that promise to be
used for made a web application
http://www.hmgforum.com/viewforum.php?f=17
-----Original Message-----
Sent: Wednesday, November 04, 2009 4:01 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
try replicate your problem in large program remove unnecessary
part from your program if give not error add removed part
upload here remain code
I tried - but it is sometimes difficult.
Wich error you have
In wich part of your program you receive error
The application hangs after boot up thread - I call it "corpse cold":)
Post follo part
Small examples go, in real applications to be suspended.
No problem - I wait for GTNET. It will be a good alternative to GTWEB.
Regards,
Marek Horodyski
P.S.
In our company expanded one of the web applications exposed to
customers.
Reaching 50,000 thousand users. Web interface is the future.
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
--
Massimo Belgrano
Horodyski Marek (PZUZ)
2009-11-05 10:57:50 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 6:04 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
He Marek
[...]
have to allow him to finish the job using PDA and WWW
browser when he will return to home.
I plan to work on such library in the future.
i suggest also follow the path of MINIGUI script that promise
to be used for made a web application
http://www.hmgforum.com/viewforum.php?f=17
Nice. So what?
Any solution that you will not find in the contrib is doomed to fail.
Roberto wants to lead MINIGUI separately - for the year proves that you
can not combine these versions - because it is "disperse".
Prophylactically will avoid problems.

Regards,
Marek Horodyski
Viktor Szakáts
2009-11-05 13:10:10 UTC
Permalink
Post by Horodyski Marek (PZUZ)
-----Original Message-----
Sent: Wednesday, November 04, 2009 6:04 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
He Marek
[...]
have to allow him to finish the job using PDA and WWW
browser when he will return to home.
I plan to work on such library in the future.
i suggest also follow the path of MINIGUI script that promise
to be used for made a web application
http://www.hmgforum.com/viewforum.php?f=17
Nice. So what?
Any solution that you will not find in the contrib is doomed to fail.
Roberto wants to lead MINIGUI separately - for the year proves that you
can not combine these versions - because it is "disperse".
Prophylactically will avoid problems.
It's not true that everything is doomed to fail what is
not in contrib. I think Harbour would be nowhere near it
is now, without active 3rd party projects.

If there is a perceived problem with quality or support,
we may try to help each other. This is also true for our
own contribs.

Brgds,
Viktor
Angel Pais
2009-11-05 12:34:29 UTC
Permalink
An experiment is NOT a promise.
HMGScript was/is a proof of concept, nothing more.
Minigui doesn't sell anything so it doesn`t have to promise anything to
anyone. If you find something missing in minigui or harbour you are
invited to do it yourself.

Regards
Angel
Massimo Belgrano
2009-11-05 12:58:43 UTC
Permalink
Imo is a very good Proof of concept
Harbour MiniGUI Script is a Harbour to JavaScript.
The goal of the project is to allow to developers the creation of web
applications using the same logic and similar syntax as HMG desktop
applications
I strong agree minigui group also if i not use minigui library

IMO here a lot of us need a path for made a web application
strong path are made by harbour\examples terminal or uhttpd2
we need a universal server compoment so hbm not require php
soap server maj be the solution?
Post by Angel Pais
An experiment is NOT a promise.
HMGScript was/is a proof of concept, nothing more.
Minigui doesn't sell anything so it doesn`t have to promise anything to
anyone. If you find something missing in minigui or harbour you are invited
to do it yourself.
Regards
Angel
_______________________________________________
Harbour mailing list
http://lists.harbour-project.org/mailman/listinfo/harbour
--
Massimo Belgrano
Angel Pais
2009-11-05 13:15:30 UTC
Permalink
Everything is possible.
A good friend of mine says this is simply about 5% inspiration and 95%
hard work.

Regards
Angel

Przemysław Czerpak
2009-11-04 13:44:51 UTC
Permalink
On Wed, 04 Nov 2009, Horodyski Marek (PZUZ) wrote:

Hi,
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
As I told you it's expected behavior and the problem is
created by your own code.
In MS-Windows only thread which created window can process
window messages so if you are suing GTWVT or GTWVG the main
thread should not be suspended or it will block other threads
which will execute 'inkey(0)' or sth similar. Just simply
incoming keys can be processed only by thread which created
GTWVT window.
It's documented MS-Windows behavior and programmers have to
know about it because it effects all MS-Windows programs in
all languages using any type of interface. Usually the easiest
solution is leaving thread owner to only process window messages
and create other threads to make real job.
In some situations library author can create hidden thread to
process window messages in the background and hide the problem
at least partially for PRG programmers. GTWVT is type of program
where it can be done though one feature blocks it and it will be
necessary to disable it. It's HB_GTI_NOTIFIERBLOCK which cannot
work when messages are processed by non HVM thread.
When GTWIN is used then such hidden thread to process console
window messages is created by system.

best regards,
Przemek
Horodyski Marek (PZUZ)
2009-11-04 14:52:42 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 2:45 PM
To: Harbour Project Main Developer List.
Subject: Re: RE: [Harbour] Multithreading support in Harbour
Hi,
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
As I told you it's expected behavior and the problem is
created by your own code.
In MS-Windows only thread which created window can process
[...]
which cannot work when messages are processed by non HVM thread.
When GTWIN is used then such hidden thread to process console
window messages is created by system.
I have plans to move app in MT ver. to GTNET and Linux - problems will disappear :)

Regards,
Marek Horodyski
Viktor Szakáts
2009-11-04 15:40:19 UTC
Permalink
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Please don't mix GTWVT and GTWVG together, they are
completely different GTs.

I'd think GTWVT has no problem to handle MT. Just like GTWIN.

Brgds,
Viktor
Pritpal Bedi
2009-11-04 16:39:16 UTC
Permalink
Hi
Post by Viktor Szakáts
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Please don't mix GTWVT and GTWVG together, they are
completely different GTs.
Misconception. This is partially true.
GTWVG is superset of GTWVT with some GUI constructs only.
If you do not call any GUI stuff, GTWVG is exactly like GTWVT.
Both GTs can be used interchangebly untill you call GUI stuff.

AND there is NO MT issue with GTWVG.
My flagship production application "Vouch" ( extremely large )
running on 100s of clients is a pure GTWVG - MT - GUI application
and is running flawlessly. Look at Przemek's message in this context.

Regards
Pritpal Bedi
--
View this message in context: http://old.nabble.com/Multithreading-support-in-Harbour-tp26194616p26199830.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.
Viktor Szakáts
2009-11-04 16:56:02 UTC
Permalink
Post by Pritpal Bedi
Post by Viktor Szakáts
Please don't mix GTWVT and GTWVG together, they are
completely different GTs.
Misconception. This is partially true.
GTWVG is superset of GTWVT with some GUI constructs only.
If you do not call any GUI stuff, GTWVG is exactly like GTWVT.
Both GTs can be used interchangebly untill you call GUI stuff.
It's not exactly the same as it uses a slightly
different codebase, where full GTWVT implementation
is present in a modified form. Syncing is manual.
Plus of course the extra stuff, which doesn't
conform with quite some Harbour core standard.
Post by Pritpal Bedi
AND there is NO MT issue with GTWVG.
My flagship production application "Vouch" ( extremely large )
running on 100s of clients is a pure GTWVG - MT - GUI application
and is running flawlessly. Look at Przemek's message in this context.
My only point was that mentioning "GTWVT/GTWVG"
as one entity is vague and may wash together
a contrib with a core component with different
codebases.

From such reports it's impossible to know whether
poster used both name by mistake, in fact you can't
be sure whether he's just confusing the two, and
which one he's using in reality. It's also impossible
to tell whether user refers to "extended" GTWVG
functionality or plain base GT one.

It turns out in this specific case it doesn't
matter, but generally speaking they are not the
same thing, and such vague reports can just ignite
other misconceptions and wrong ideas about Harbour.

Saying "doesn't support MT" for a core Harbour
component is a heavy claim, so we should avoid
being vague by all means in such case.

Brgds,
Viktor
Horodyski Marek (PZUZ)
2009-11-04 16:45:26 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 4:40 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Please don't mix GTWVT and GTWVG together, they are completely
different GTs.
I'd think GTWVT has no problem to handle MT. Just like GTWIN.
No. The application was launched just as I linked it with GTWIN.
Passed in turn from GTWVG, GTWVT and GTWIN.

Regards,
Marek Horodyski
Viktor Szakáts
2009-11-04 16:59:21 UTC
Permalink
Post by Horodyski Marek (PZUZ)
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the application (small
examples GTWVG work flawlessly).
Please don't mix GTWVT and GTWVG together, they are completely
different GTs.
I'd think GTWVT has no problem to handle MT. Just like GTWIN.
No. The application was launched just as I linked it with GTWIN.
Passed in turn from GTWVG, GTWVT and GTWIN.
Post specific examples which would highlight the problem
instead of spreading such generic claims about Harbour
components on this list, that "GTWVT doesn't support MT".

Such claims only misguide users and give way to false rumors.
This isn't very constructive. A self-contained example is.

Brgds,
Viktor
Horodyski Marek (PZUZ)
2009-11-05 10:28:40 UTC
Permalink
-----Original Message-----
Sent: Wednesday, November 04, 2009 5:59 PM
To: Harbour Project Main Developer List.
Subject: Re: [Harbour] Multithreading support in Harbour
Post by Horodyski Marek (PZUZ)
Post by Horodyski Marek (PZUZ)
From my experience, GTWIN is working in MT without problem.
GTWVT / WVG for larger applications may hang the
application (small
Post by Horodyski Marek (PZUZ)
Post by Horodyski Marek (PZUZ)
examples GTWVG work flawlessly).
Please don't mix GTWVT and GTWVG together, they are completely
different GTs.
I'd think GTWVT has no problem to handle MT. Just like GTWIN.
No. The application was launched just as I linked it with GTWIN.
Passed in turn from GTWVG, GTWVT and GTWIN.
Post specific examples which would highlight the problem
instead of spreading such generic claims about Harbour
components on this list, that "GTWVT doesn't support MT".
Such claims only misguide users and give way to false rumors.
This isn't very constructive. A self-contained example is.
I understand it - and that is why I write that small examples worked correctly.
I tried to prepare such an example - but it does not hangs the application.
An attempt to start the real application was successful only when it linked it with GTWIN.
One thing I can do is send the entire application, with source and linking scripts.
I do not do with this problem - just write what my experiences.

Regards,
Marek Horodyski
Loading...