Thread View: comp.lang.pascal.delphi.misc
4 messages
4 total messages
Started by Martin Harvey
Fri, 21 Apr 2000 00:00
Thread safe classes. Advice required.
Author: Martin Harvey
Date: Fri, 21 Apr 2000 00:00
Date: Fri, 21 Apr 2000 00:00
49 lines
2663 bytes
2663 bytes
Hi folks,
Well the Delphi primer on Multithreaded programmings is going very well.
I have 8 chapters done, covering just about all the basic issues.
Having covered critical sections and mutexes in excruciating detail, I'm
moving on to discuss more advanced synchronisation mechanisms, and in
particular, a review of Delphi thread safe classes. As far as I can see,
the main offerings are:
TThreadList,
TCriticalSection,
TSynchroObject,
TEvent,
TSimpleEvent,
TMultiReadExclusiveWriteSynchroniser.
Here comes my problem. I'm currently developing with Delphi 4 standard,
and hence I don't have the source (or even the help) on some of these
objects!
The list and the critical section are no problem, my tutorial has
already discussed all the quirks involved with them.
The multiple read fancy synchroniser is also trivial. I have the help
files for this, and although I don't have the source, this particular
synchronisation mechanism is such a classic textbook case, that I will
have no problem explaining its internal workings without the source.
I do have plenty of the standard literature on eventcounts and
sequencers, and some far more esoteric synchronisation primitives, but
the remaining classes are tricky, because I have no documentation on the
Delphi implementation of them at the moment.
Could anyone provide me with some basic info about the methods,
properties and events of these three remaining classes, and the
semantics of these? Once I have that, and I know what "spin" the Delphi
programmers have put on these primitives, then there is no problem,
because I can explain the internal workings of these synchronisation
mechanisms from the standard literature on the subject.
many thanks,
Martin H.
--
Martin Harvey. martin@pergolesi.demon.co.uk
http://www.pergolesi.demon.co.uk
Re: Thread safe classes. Advice required.
Author: Bj�rge S�ther
Date: Fri, 21 Apr 2000 00:00
Date: Fri, 21 Apr 2000 00:00
42 lines
2656 bytes
2656 bytes
"Martin Harvey" <martin@pergolesi.demon.co.uk> skrev i melding news:39009953.2D1D2901@pergolesi.demon.co.uk... > Here comes my problem. I'm currently developing with Delphi 4 standard, > and hence I don't have the source (or even the help) on some of these > objects! > > The list and the critical section are no problem, my tutorial has > already discussed all the quirks involved with them. > > The multiple read fancy synchroniser is also trivial. I have the help > files for this, and although I don't have the source, this particular > synchronisation mechanism is such a classic textbook case, that I will > have no problem explaining its internal workings without the source. Hi ! The classes found in syncobjs unit; TCriticalSection, TSynchroObject, TEvent, TSimpleEvent; are somewhat silly, if you ask me. The only thing they do, is adding more lines to your code, and exchange WinAPI datatypes with Delphi classes. And - the most impoortant: They obscure the reality of thread programming: You need to understand the core of Windows OS somewhat better to succeed. I would advice programmers to dive into the WinAPI instead. The same may be said about TThread: The fact that this class exists, lead programmers to believe that this is some basic pattern for threads. It took me quite a while to understand that you would normally need to redesign the TThread class both for startup, termination, execution *and* synchronization. If they had provided a basic exception handling mechanism, it would be worth something...I'm sure I would get there faster without the prewritten class, at least. Good luck with your book ! -- Bjoerge Saether Consultant / Developer Asker, Norway bsaether.removethis@online.no (remove the obvious)
Re: Thread safe classes. Advice required.
Author: Sundial Services
Date: Fri, 21 Apr 2000 00:00
Date: Fri, 21 Apr 2000 00:00
23 lines
1787 bytes
1787 bytes
Martin Harvey wrote:
[...]
> Here comes my problem. I'm currently developing with Delphi 4 standard,
> and hence I don't have the source (or even the help) on some of these
> objects!
Martin, I say to you quite sincerely that you have just encountered
=the= reason why Standard is "no good," and that you should forthwith
invest in Professional so that you have access to the VCL source code.
You are at precisely the point in your "education" when nothing but the
actual source-code will "do."
You can infer and extrapolate and reason all you want to -- but here is
precisely where you really need THE code. . . .
------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:info@sundialservices.com (PGP public key available.)
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R): "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep
Re: Thread safe classes. Advice required.
Author: Martin Harvey
Date: Sat, 22 Apr 2000 00:00
Date: Sat, 22 Apr 2000 00:00
64 lines
3347 bytes
3347 bytes
"Bj�rge S�ther" wrote:
>
You need
> to understand the core of Windows OS somewhat better to succeed. I would
> advice programmers to dive into the WinAPI instead.
> The same may be said about TThread: The fact that this class exists, lead
> programmers to believe that this is some basic pattern for threads. It took
> me quite a while to understand that you would normally need to redesign the
> TThread class both for startup, termination, execution *and* synchronization.
> If they had provided a basic exception handling mechanism, it would be worth
> something...I'm sure I would get there faster without the prewritten class,
> at least.
I'd mainly agree with that. The problem is that TThread, especially
synchronise, is an attemt to make things *easy*. Unfortunately, it's a
situation where you *have* to understand the entire situation:
half-assed attempts won't do.
> Good luck with your book !
It's going very nicely actually. My basic premise has been
- To introduce threads with TThread.
- Introduce the various approaches useful with thread creation and
destruction.
- Introduce synchronise, and explain why it is such a heap of crap.
Show how mutexes or critical sections do a much nicer job.
- Show a million and one ways to cause deadlock, both with mutexes and
synchronise, and ways of getting around it.
All of that I've done.
I'm now working on:
- Producer / consumer relationships : buffers with flow control by
implementing blocking read and write operations.
- Converting blocking I/O to asynchronous I/O and back: how to make an
asynchronous VCL thread live nicely with blocking worker threads.
- More interesting synchronisation primitives.
- An introduction to monitors.
If I get the chance, I'll also do some more advanced topics such as:
- Equivalency of synchronisation primitives.
- Various forms of IPC and converting one to another.
- An introduction to transaction processing.
Various subjects in transaction processing:
- Atomicity of composite operations, commit, abort & multi stage
rollback.
- Individuality of multiple operations and optimistic concurrency
control
- Persistence and crash resilience.
And perhaps throw in a bit on deadlock detection and avoidance as well.
It's turning out to be quite hard work, but I'm sure I'll be able to
cope.
MH.
--
Martin Harvey. martin@pergolesi.demon.co.uk
http://www.pergolesi.demon.co.uk
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads