Item item bufferbuffersize int in 0 int out 0

Info icon This preview shows pages 25–34. Sign up to view the full content.

View Full Document Right Arrow Icon
} item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; Solution is correct, but can only use BUFFER_SIZE-1 elements
Image of page 25

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3.26 Bounded-Buffer – Insert() Method Bounded-Buffer – Insert() Method while (true) {    /* Produce an item */         while (((in = (in + 1) % BUFFER SIZE  count)  == out)      ;   /* do nothing -- no free buffers */     buffer[in] = item;     in = (in + 1) % BUFFER SIZE;      }
Image of page 26
3.27 Bounded Buffer – Remove() Method Bounded Buffer – Remove() Method while (true) {           while (in == out)                  ; // do nothing -- nothing  to consume      // remove an item from the buffer      item = buffer[out];      out = (out + 1) % BUFFER SIZE; return item;       }
Image of page 27

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3.28 Interprocess Communication (IPC) Interprocess Communication (IPC) Mechanism for processes to communicate and to synchronize their actions Message system – processes communicate with each other without resorting to shared variables IPC facility provides two operations: send ( message ) – message size fixed or variable receive ( message ) If P and Q wish to communicate, they need to: establish a communication link between them exchange messages via send/receive Implementation of communication link physical (e.g., shared memory, hardware bus) logical (e.g., logical properties)
Image of page 28
3.29 Implementation Questions Implementation Questions How are links established? Can a link be associated with more than two processes? How many links can there be between every pair of communicating processes? What is the capacity of a link? Is the size of a message that the link can accommodate fixed or variable? Is a link unidirectional or bi-directional?
Image of page 29

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3.30 Communications Models Communications Models
Image of page 30
3.31 Direct Communication Direct Communication Processes must name each other explicitly: send ( P, message ) – send a message to process P receive ( Q, message ) – receive a message from process Q Properties of communication link Links are established automatically A link is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi-directional
Image of page 31

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3.32 Indirect Communication Indirect Communication Messages are directed and received from mailboxes (also referred to as ports) Each mailbox has a unique id Processes can communicate only if they share a mailbox Properties of communication link Link established only if processes share a common mailbox A link may be associated with many processes Each pair of processes may share several communication links Link may be unidirectional or bi-directional
Image of page 32
3.33 Indirect Communication Indirect Communication Operations create a new mailbox send and receive messages through mailbox
Image of page 33

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 34
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern