Threaded Qs for document based app
Threaded Qs for document based app
- Subject: Threaded Qs for document based app
- From: Ken Tabb <email@hidden>
- Date: Mon, 4 Jun 2001 16:27:41 +0100
Hi,
I'm moving some Solaris C/C++ and 'Classic' mac C/C++ code to
Cocoa/Obj-C, and have a few questions about thread design.
The app is a document based app which opens QuickTime movies, steps
through each frame (that's another story!) and analyses them. 'Analyses'
in this sense involves a sequence of preprocessing algorithms which
generally need to happen in succession, so aren't themselves suitable for
splitting into different threads (as they'll all be waiting for each
other all the time, so may as well be in the same thread in the first
place). The app itself only needs to run on G4s, but needs to be MP
savvy, so I was aiming on having multiple threads with AltiVec code in
(to use both AltiVec units).
What I was envisaging was the following threads per document:
[1] Main parent GUI thread for controlling Document1's preprocessing
threads
[1a] Child thread for processing the top left quarter of Document1
[1b] Ditto for the top right
[1c] Ditto for the bottom left
[1d] Ditto for the bottom right
Questions on this design:
Does it make sense to have a GUI thread for each open document? If not
(i.e. if it should be 1 app-level GUI thread) how do you go about doing
that in a document-based app?
Are there any utilities for thread analysis in Cocoa / OS X? For
instance is there a tool which tells you how much processor time each of
an app's threads used when running it? Kind of like 'top' but for threads
not processes. Or how much time one thread spent waiting for another to
finish (if it required one to finish before it could proceed) etc.? Does
the fact that there'll be AltiVec code in threads [1a - 1d] make it more
difficult to analyse processor time for threads?
Are there any docs for multithreading in OS X / Cocoa / Obj-C (besides
the NSThread etc. docs) which explain the overheads for threads, and when
using a separate thread is a good / bad idea etc.? I'm awaiting Learning
Cocoa's arrival in the UK, so maybe that'll tell me?
By the way I've split the image into quarters rather than halves (even
though there's only two processors of course) in case Apple release a
quad G4. Wishful thinking I know!
Thanks in advance for any info / insights you can give,
the boy Ken
---------
Ken Tabb.
Mac & UNIX C/C++/Java developer (Health & Human Sciences),
Machine Vision researcher/programmer (Computer Science),
University of Hertfordshire, England
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider