Difference between revisions of "Synchronous"
m |
m (5 revisions imported) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== Examples == | == Examples == | ||
− | var a:Int::allocated[single[on[1]]]; | + | function void main() { |
− | + | var a:Int::allocated[single[on[1]]]; | |
− | + | var b:Int::allocated[single[on[2]]] :: synchronous[] :: blocking[]; | |
− | + | var c:Int::allocated[single[on[2]]] :: synchronous[] :: nonblocking[]; | |
− | + | a:=b; | |
+ | a:=c; | ||
+ | }; | ||
The send of assignment ''a:=b'' (and program execution on process 2) will only complete once process 1 has received the value of ''b''. The send involved with the second assignment is synchronous [[nonblocking]] where program execution can continue between the start and finish state, the finish state only reached once process 1 has received the message (value of ''c''.) Incidentally, as already mentioned, the [[blocking]] type of variable ''b'' would have been chosen by default if omitted (as in previous examples.) | The send of assignment ''a:=b'' (and program execution on process 2) will only complete once process 1 has received the value of ''b''. The send involved with the second assignment is synchronous [[nonblocking]] where program execution can continue between the start and finish state, the finish state only reached once process 1 has received the message (value of ''c''.) Incidentally, as already mentioned, the [[blocking]] type of variable ''b'' would have been chosen by default if omitted (as in previous examples.) | ||
Line 24: | Line 26: | ||
The code example above demonstrates the programmer's ability to change the communication send mode just for a specific assignment. In the first assignment, process 1 issues a [[blocking]] [[standard]] send, however in the second assignment the communication mode type ''synchronous'' is coerced with the type of ''b'' to provide a [[blocking]] synchronous send just for this assignment only. | The code example above demonstrates the programmer's ability to change the communication send mode just for a specific assignment. In the first assignment, process 1 issues a [[blocking]] [[standard]] send, however in the second assignment the communication mode type ''synchronous'' is coerced with the type of ''b'' to provide a [[blocking]] synchronous send just for this assignment only. | ||
− | ''Since: Version 0. | + | ''Since: Version 0.5'' |
[[Category:Type Library]] | [[Category:Type Library]] | ||
[[Category:Compound Types]] | [[Category:Compound Types]] | ||
[[Category:Communication Mode Types]] | [[Category:Communication Mode Types]] |
Latest revision as of 15:44, 15 April 2019
Syntax
synchronous[]
Semantics
By using this type, the send of P2P communication will only reach the finish state once the message has been received by the target processor.
Examples
function void main() { var a:Int::allocated[single[on[1]]]; var b:Int::allocated[single[on[2]]] :: synchronous[] :: blocking[]; var c:Int::allocated[single[on[2]]] :: synchronous[] :: nonblocking[]; a:=b; a:=c; };
The send of assignment a:=b (and program execution on process 2) will only complete once process 1 has received the value of b. The send involved with the second assignment is synchronous nonblocking where program execution can continue between the start and finish state, the finish state only reached once process 1 has received the message (value of c.) Incidentally, as already mentioned, the blocking type of variable b would have been chosen by default if omitted (as in previous examples.)
var a:Int :: allocated[single[on[0]]; var b:Int :: allocated[single[on[1]]; a:=b; a:=(b :: synchronous[]);
The code example above demonstrates the programmer's ability to change the communication send mode just for a specific assignment. In the first assignment, process 1 issues a blocking standard send, however in the second assignment the communication mode type synchronous is coerced with the type of b to provide a blocking synchronous send just for this assignment only.
Since: Version 0.5