Download pseudo source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
procedure main:
  declare constant message_capacity = 512
  declare message as an array of message_capacity of char initialized with \
    "Hello from main thread of process " + process_number \
    + " of " + process_count + " on " + process_hostname

  if process_number != 0 then
    send(message, length(message), 0)
  else
    print(process_number, " sent ", message)
    for source := 1 to process_count do
      receive(&message, message_capacity, source)
      print(source, " sent ", message)
    end
  end if
end procedure