Re: Programming style (was Accessors) revisited ; de-compiler ???
Re: Programming style (was Accessors) revisited ; de-compiler ???
- Subject: Re: Programming style (was Accessors) revisited ; de-compiler ???
- From: Robert Goldsmith <email@hidden>
- Date: Sat, 17 Aug 2002 13:18:02 +0100
>
"Each thread has a working memory, in which it may keep copies of
>
the values of variables from the main memory that is shared
>
between all threads. To access a shared variable, a thread
>
usually first obtains a lock and flushes its working memory. This
>
guarantees that shared values will thereafter be loaded from the
>
shared main memory to the threads working memory. When a thread
>
unlocks a lock it guarantees the values it holds in its working
>
memory will be written back to the main memory."
This is not all that different from what happens when you have
duel-processor or higher machines because each processor usually
has L1,2 and 3 memory caches. The L3 cache, for instance, in the
new powermacs is 2Mbytes! That's easily enough to fit all of some
of my applications. The co-ordination works something like the
following:
On a memory read, the cache is asked before the main memory. In
fact, the cache and memory are usually asked at the same time but
the cache responds faster. If the value is is cache, the main
memory fetch is cancelled so as not to take up bus time.
On a memory write, a pass-through actually occurs - the value is
written to both main memory and the caches.
On a multiprocessor machine, there is communication between the
caches so, on a basic level, when one processor writes out a
value to main memory, all other caches flush the old value so it
needs to be fetched again next time it is needed.
Most modern systems are significantly more complex than this and
there is a great deal of care gone into the timing of it all but
that's the basics. Of course, this is all done in hardware :)
On a side note, the AltiVec co-processors have their own L1 cache
(separate from the main cpu), I think, and there are cache flow
control commands as part of the AltiVec command set so you can
pre-fetch and force flushes, sync all the caches (the AltiVec has
4 caches which can work independently) and all sorts :)
Robert Goldsmith
---
GnuPG public key:
http://www.Far-Blue.co.uk/RSGoldsmith.asc
[demime 0.98b removed an attachment of type application/pgp-signature which had a name of PGP.sig; charset=US-ASCII]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.