Re: Is there a way to simulate multi-threading?

Tech-Archive recommends: Speed Up your PC by fixing your registry



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
.



Relevant Pages

  • Re: Comparing Lisp conditions to Java Exceptions
    ... All the ISO standards in the world will not make the world ... Nothing keeps you from annotating your program with exceptions based on what ... language should adhere to your theory. ... Curiously, although you don't say it, Java has the opposite problem. ...
    (comp.lang.lisp)
  • Re: casts
    ... This is why most shit programmers refuse to learn languages including ... C Sharp and Java. ... compiler in a later edition of Visual Basic, ... language for processing data. ...
    (comp.lang.c)
  • Re: C, really portable?
    ... > Wait, is Java a modern language superior to C, or is it still ... It is a much better OO language than C++, ... It depends what you are doing, Java aims for rigorous portability - the same ... regardless of platform. ...
    (comp.lang.c)
  • Re: Is anybodys favorite computer programming language not included here?
    ... to talk about getting me some paying work writing Java classes. ... and could be copied to a script (as in Java BeanShell or Lisp PROG). ... >> please post a followup saying what language it is, ... Server: "Mother, ...
    (comp.programming)
  • Re: Basic inheritance question
    ... used 'this' in C++ and Java. ... but in Python it doesn't. ... language, they would write a lot of ten liners that is changed a LOT ... Add three levels of inheritence and a couple globals and you'll find out ...
    (comp.lang.python)