Article View: comp.lang.pascal.delphi.misc
Article #486Re: Thread safe classes. Advice required.
From: 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
Technical Details
Message-ID:
<3900E4BD.53EE0217@pergolesi.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<39009953.2D1D2901@pergolesi.demon.co.uk> <6W3M4.8172$By1.151274@news1.online.no>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: fb0ea,a11e9ce613315ab7 X-Google-Attributes: gidfb0ea,public X-Google-Thread: 10baee,a11e9ce613315ab7 X-Google-Attributes: gid10baee,public From: Martin Harvey <martin@pergolesi.demon.co.uk> Subject: Re: Thread safe classes. Advice required. Date: 2000/04/22 Message-ID: <3900E4BD.53EE0217@pergolesi.demon.co.uk> X-Deja-AN: 614288192 Content-Transfer-Encoding: 8bit X-NNTP-Posting-Host: pergolesi.demon.co.uk:158.152.20.186 References: <39009953.2D1D2901@pergolesi.demon.co.uk> <6W3M4.8172$By1.151274@news1.online.no> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 956408088 nnrp-02:25479 NO-IDENT pergolesi.demon.co.uk:158.152.20.186 MIME-Version: 1.0 Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.vcl.components.using