Communication Trough Message Passing or Shared Memory: a Formal Comparison