Re: Multitasking and containers



On Tue, 28 Nov 2006 02:19:55 GMT, Matthew Heaney wrote:

"Dr. Adrian Wrigley" <amtw@xxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

Actually, I think Dmitry's view is largely valid in practice, if
somewhat extreme.

But we were talking specifically about using a protected object to implement a
multiple readers schema vs. using a protected object to implement a Hoare-style
monitor. Because reads must by synchronized, the standard container library
requires a monitor-style synchronization scheme.

The OP made the argument that this isn't very efficient, and Dmitry responded
by saying, "well of course systems require custom hand-made solutions." But the
premise is all wrong, so what Dmitry said is irrelevant. The OP (not Dmitry)
seems to be confused (he was asking the question, after all) about the
difference between a mutex and a monitor. He (the OP) probably doesn't
understand that monitor-type synchronization executes on the current thread, so
there's no context switch, and so there's no efficiency loss.

I read OP question very differently. He said (let Maciej correct me):

1. That accessing a mutable operation disguised as a protected object's
function were wrong.

2. Using a protected object's procedure/entry would kill concurrency by
serialization of the action to undertake.

Both statements are evidently true.

My comments considered possible solutions *provided* that 2 were really a
problem, because as Jeffrey rightly pointed out, the loss of performance
could be actually minor. But that depends. It is easy to imagine a
situation (massively parallel computing with shared memory) where the loss
could be huge.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.