Re: Is there a way to simulate multi-threading?
- From: Thomas Ganss <tganss_at_t_dash_online_dot_de-remove-all-after-first-real-dash@xxxxxxxxx>
- Date: Mon, 31 Dec 2007 12:06:51 +0100
Hi Olaf,
But if you define "threading" as parallel/multitasking within the same process ("coroutines"), there are languages implementing it inside the language (java comes to mind first, and Modula-2 Coroutines were alternatively called "threads" as well AFAIR) and at leat Modula-2 supported "in-process parallel programming" running under old MS-Dos.
Dunno about the java running under MS-Dos, but would guess so as well.
Okay, I guess most of these native threading support is based on
API calls you can also use from vfp. But then of course a language
might also act on it's own supporting CPU features for multithreading
and/or multiprocessing.
OS should have some priviliged access to the CPU and administers
processes and threads. I wonder, if any language can really spawn
it's own threads without help of some OS functions in nowadays archi-
tectures both in Windows and Linux.
As said, it depends on the definition of thread. Some make a distinction between system-level and user-level threads, which probably mirrors the above.
I once read that newer java runtimes start "knowing" the no. of available cores / processors and already have a few (system-level) lightweight threads running to make use of multiple cpu's just in case. Might have been a false description, as there are API calls to add threads, but in stuck in my mind even if I did not verify it.
It's true that the CreateThread API call as it is used by Calvin Hsia
is not the only key which might be usable and as vfp is not meant to
use this feature you have at least to test behaviour of different threads
accessing the same things, eg. public vars or tables or objects, for
example forms and their controls. But I think examples like the multi-
threaded web crawler show it has no serious problems or side effects
and works.
There's of course one major difference regarding mutithreading
and multiprocessing. In multiprocessing you can't have access to
even public vars. As long as you don't use some techniques like
Shared Memory, Pipes, DDE or COM you are seperated, but
thats also an advantage regarding stability, as a new process which
crashes does not crash the main process.
I lean more to the latter: I think asynchronous behaviour (which is mostly my target) is better served with an RPC-type of work, and something as simple as a semaphore table should be fast enough for interprocess communication if the table is on the same machine.
If the task is coarse grained (not much chat between them, mostly startup, perhaps reading a chunk of data and signalling finish, perhaps also with some data) the isolation is welcome. I use DDE (as it *supports* asynch callbacks!) whenever interrupt-like behaviour is asked for - had to do it twice, but the interrupt like behaviour gained comparatively little speed, as the "surrounding" programming was extremely wasteful and table based RPC with optimized "surrounding" would have been satisfactory. But changing the predefined specs would have been more costly than implementing the DDE <bg>.
The example printing in background I'ld say should be delegated to another vfp process (ok, you have to build and probably cleanup the report table) and I had multiprocessing webcrawlers filling the same result tables in vfp back in the last century<g>.
Working on the speed of form creation, which sometimes is a burden, I shy away from MT as data session isolation, lock strategy, buffering settings, transactions, framework and user level code can be problematic enough without interweaving threads<bg>. Safer IMHO to squeeze performance out of more traditional optimization, which in one case even included building other often needed objects/forms via timer one ..addobject at a time when no user interaction had happened for a sizable chunk of seconds. As each object had sub-second start up there was no longlasting lag if the user decided to start working while the "background building" was in progress. A similar timer-based design was used to precalculate and -cache the result of data intensive a summaries for a customers insureance contracts. Worked great, but when explaining the code to the maintainance programmers I had to add code to optically signify what was happening via timer in background via developer backdoor. Took a bit of time...
But my attitude might partly be a sour grapes reaction on my side, as I was testing threaded behaviour (mostly the Remus' code) way back as well and I was not even thinking of creating such a thing myself like Calvin easily did.
happy new year to you
thomas
.
- References:
- Re: Is there a way to simulate multi-threading?
- From: Olaf Doschke
- Re: Is there a way to simulate multi-threading?
- From: Thomas Ganss
- Re: Is there a way to simulate multi-threading?
- From: Olaf Doschke
- Re: Is there a way to simulate multi-threading?
- Prev by Date: Re: VFP3 Insufficient Memory
- Next by Date: Re: Failed to update Windows XP Home Edition 2002 Service Pack 2
- Previous by thread: Re: Is there a way to simulate multi-threading?
- Next by thread: Re: QuickTime symbol displays instead of video
- Index(es):
Relevant Pages
|