Module 22: Multi-core Computing Security
  Lecture 43: Multiprocessor Techniques
 


Producer and Consumer Code

BUF_Data consume(void) {
while (buffer.outptr == buffer.inptr) ;
buffer.items[buffer.outptr];
buffer.outptr = (buffer.outptr +1)%BUF_SZ;
return (buffer.items[buffer.outptr-1]%BUF_SZ;);
}
  • What is wrong with this code?

Message Passing

  • Communication channel
    • How to name the channel between two processes?
  • Direct Communication
    • The sender process (P) must know the receiver process (Q) and vice versa
      P: send(Q, msg) ♦ Q: receive(P, msg);
    • Some versions may have receive(ANY, msg);
  • Indirect Communication
    • Mailboxes must be named rather than the processes.
    • Sender: Create_mailbox(Name, Properties);
    • Sender: Send(Name, msg);
    • Sender: Distroy_mailbox(Name);
    • Receiver: Open_mailbox(Name);
    • Receiver: Receive(mailbox, msg);