Why multi-threading ?
Why multi-threading ?
- Subject: Why multi-threading ?
- From: publiclook <email@hidden>
- Date: Mon, 26 May 2003 20:48:31 -0400
In my experience with multi-threading going back to Ada 83 and most
recently with Java and C++ systems, why does anybody bother ?
Let me clarify: In my experience, multi-threading makes writing correct
code many times harder. It is nearly impossible to document your
intentions in the source code because almost by definition, someone
reading your code will be unaware of other things happening
concurrently when the code they are looking at executes.
Multi-threading adds a huge overhead to common operations due to system
calls for mutexes/semaphores and in a true multi-processor system plays
havoc with processor caches etc. For example, if two processors are
simultaneously using data in the same cache line then typically neither
processor can cache the data and memory accesses go from being a few
cycles to a massive number of cycles. Doesn't the memory access
impairment cancel any benefit of multi-threading in the common cases?
If there are long running background "tasks" to perform, why not run
them as separate tasks with separate protected memory ? Why not use
message queues, signals, distributed messaging, mach messaging or
whatever as the communication between tasks if you are going to end up
using them between threads anyway ? Protected memory is a GOOD thing
that was a long time coming to Mac OS and it seem the first thing
people want to do is deliberately bypass it with multi-threading
instead of multi-tasking.
So why does anybody bother with multi-threading ? What am I missing ?
_______________________________________________
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.