• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision1d3db89e375b1c39ce8db2fcd8f4ce61795cce5f (tree)
Time2022-09-04 21:15:48
AuthorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

asis

Change Summary

Incremental Difference

diff -r 582949d0d56c -r 1d3db89e375b CCastle/2.Analyse/8.ConcurrentComputingConcepts.rst
--- a/CCastle/2.Analyse/8.ConcurrentComputingConcepts.rst Tue Aug 30 18:44:03 2022 +0200
+++ b/CCastle/2.Analyse/8.ConcurrentComputingConcepts.rst Sun Sep 04 14:15:48 2022 +0200
@@ -133,6 +133,7 @@
133133 |BR|
134134 Notice: As the compiler will insert the (low level) Semaphores_, the risk that a developer forgets one is gone!
135135
136+
136137 Messaging Aspects
137138 -----------------
138139
@@ -160,14 +161,35 @@
160161 (Un)Buffered
161162 ~~~~~~~~~~~~
162163
163-Despide it’s is not truly a characteristic of the messages itself, messages can be *buffered*, or not. This about the
164-channel that transports the messages: How many messages can be stored ‘in’ the channel (often depicted a a queue). When
165-there is no storage at all, the writer and reader needs to rendezvous: send and receive at the same (wall) time.
164+Despide it’s is not truly a characteristic of the messages itself, messages can be *buffered*, or not. It is about
165+piping, transporting the message: can this “connection” (see below) *contain/save/store* messages? When there is no
166+storage at all the writer and reader needs to rendezvous: send and receive at the same (wall) time.
167+|BR|
168+With a buffer (often depicted as a queue) multiple messages may be sent, before they need to be picked-up by the
169+receiver; the number depends on the size of the buffer.
166170
167-This is not needed when a buffer is available. Depending on the size of the buffer, some messages can be send before
168-the are picked-up by the receiver.
171+Note: this is always asymmetric; messages need to be send before the can be read.
172+
173+Connected Channels (or not)
174+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175+
176+Messages can be send over (pre-) *connected channels* or to freely addressable end-points. Some people use the term “connection
177+oriented” for those connected-channels, others use the term “channel” more generic and for any medium that is
178+transporting messages. I try to use “*connected-channel”* when is a *pre connected* channel.
179+
180+When using connected-channels, one writes the message to the channel; there is no need to add the receiver to the
181+message. Also when reading, the sender is clear.
169182 |BR|
170-Note: this is always asymmetric; messages need to be send before the can be read.
183+Clearly, the channel has to be set-up before it can be used.
184+
185+Without connected-channels, each message needs a recipient; often that receiver is added (“carried”) to the message
186+itself.
187+|BR|
188+A big advantage is, that one does not need to create channels and end-points first -- which especially count when a low
189+number (possible one) of messages are send to the same receiver, and/or many receivers exist (which would lead to a huge
190+number of channels).
191+
192+
171193
172194 (Non-) Blocking
173195 ~~~~~~~~~~~~~~~
@@ -182,22 +204,26 @@
182204 Then, the developer will commonly “cycle” to poll for a profitable call; and let the task do some other/background work
183205 as well.
184206
207+
208+
185209 Uni/Bi-Directional, Broadcast
186210 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
187211
188-Messages --or actually the channel that transport them-- can be *unidirectional*: from sender to receiver only;
212+Messages --or actually the channel [#channelDir]_ that transport them-- can be *unidirectional*: from sender to receiver only;
189213 *bidirectional*: both sides can send and receive; or *broadcasted*: one message is send to many receivers [#anycast]_.
190214
215+
191216 Reliability & Order
192217 ~~~~~~~~~~~~~~~~~~~
193218
194219 Especially when studying “network messages”, we have to consider Reliability_ too. Many developers assume that a send
195-message is always received and that when multiple messages are sent, they are received in the same order. In most,
196-traditional --single-core-- applications this is always true. With networking applications, this is not always
197-the case. Messages can get lost, received out of order, or even read twice. Although it is always possible to add a
220+message is always received and that when multiple messages are sent, they are received in the same order. In most
221+traditional --single-core-- applications this is always the chase. With networking applications, this is not always
222+true. Messages can get lost, received out of order, or even read twice. Although it is always possible to add a
198223 “reliability layer”.
199224 |BR|
200-Such a layer makes writing the application easier but introduces overhead. And therefore not always the right solution.
225+Such a layer makes writing the application easier but introduces overhead too. And therefore not always the right
226+solution.
201227
202228 In Castle, we have “active components”: many cores are running parallel, all doing a part of the overall (concurrent)
203229 program. This resembles a networking application -- even while there is no real network -- where at least three nodes
@@ -211,9 +237,7 @@
211237 receiving a message from ``A`` -- send a short message to the other one (`m3` and `m4`). And that message triggers
212238 (again both in ``B1`` and ``B2``) to send an answer to ``A``; so `m5` and `m6`.
213239
214-Now the question is: in which order those answers (in ``A``) are received?
215-|BR|
216-The real answer is: you don’t know!
240+Now the question is: in which order those answers (in ``A``) are received? The real answer is: **You don’t know!**
217241 |BR|
218242 It’s clear that ``A`` will get `m5` and `m6` -- given that all messages (aka channels) are reliable. But there are many
219243 ways those messages may receive in the opposite order. Presumably, even in more ways, than you can imagine. For example,
@@ -235,13 +259,16 @@
235259 connection, that is not 100% reliable.
236260 |BR|
237261 When we use it “as is”, there will be a bit of noise, and even some hick-ups. For most people this is acceptable,
238- when needed they will use phrases as “can you repeat that?”.
262+ when needed they will use phrases as *“Can you repeat that?”*.
239263
240- To make that connection reliable, we need checksums, low-level conformation message, and once in a while send a
241- message again. To make it an audio-stream all messages will be delayed a bit --so that an automatically resend
242- messages can be inserted. This is common in a (unidirectional) POD-cast kind of connection.
264+ To make that connection reliable, we need checksums, low-level conformation message, and once in a while have to sent
265+ a message again. This implies some buffering (at both sides), and so the audio-stream will have a bit of delay.
266+ This is a common solution for unidirectional POD-casts, and such.
243267
244- For a (bidirectional) conversation, this buffering is often not satisfactory. As it makes the connection *slow*.
268+ For a bidirectional conversation however this buffering is not satisfactory. It makes the *slow*, people have to wait
269+ on each-other and will interrupted one-other.
270+ |BR|
271+ Then, a *faster* conversation with a bit of noise is commonly preferred.a
245272
246273
247274 Some examples
@@ -324,6 +351,10 @@
324351 that the number of communications will grow with the number of cores too. As described in the :ref:`sidebar
325352 <Threads-in-CPython>` in :ref:`BusyCores`, solving this can give more overhead then the speed we are aiming for.
326353
354+.. [#channelDir]
355+ Strictly speaking, one should not use “channel” here. Non the less, the “direction of a medium”, that is not a
356+ (connected) channel sounds void. Although we do not exclude it, we use a pragmatic way of writing.
357+
327358 .. [#anycast]
328359 Broadcasting_ is primarily know from “network messages”; where is has many variants -- mostly related to the
329360 physical network abilities, and the need to save bandwith. As an abstraction, they can be used in “software messages”