Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can you please answer 2a,2b and 3a,3b please a. Describe how the two major class

ID: 3849329 • Letter: C

Question

can you please answer 2a,2b and 3a,3b please

a. Describe how the two major classes of inter-process communication use memory. In your answer, describe (i) what types of data or data structures are used to exchange information, and (ii) in which address space these data are stored. b. Explain why indirect communication is often favored over direct communication for message passing inter-process communication. a. Explain why each thread in a multithreaded process needs its own (i) program counter, (ii) register copies, and (ii) stack. b. Given the two threads below, is it possible for x to be equal to 4 and y to be to 2 when both threads are done? If so, explain how, explain why not. Thread 1 x = 4 x = y + 2 Thread 2 y = 5 y = x - 2

Explanation / Answer

Answer for Question 2a:

there are few inter-process communication mechanisms. Each of
these uses a different method to achieve communication amongst the processes. The first
mechanism we study employs pipes. Pipes, as used in commands like ls|more, direct the
output stream of one process to feed the input of another process. So for IPC, we need to
create a pipe and identify the direction of feeding the pipe. Another way to communicate
would be to use memory locations. We can have one process write into a memory
location and expect the other process to read from it. In this case the memory location is a
shared memory location

Answer for Question 2B:

In Direct message passing, The process which want to communicate must explicitly name the recipient or sender of communication.
e.g. send(p1, message) means send the message to p1.
similarly, receive(p2, message) means receive the message from p2.
In this method of communication, the communication link get established automatically, which can be either unidirectional or bidirectional, but one link can be used between one pair of the sender and receiver and one pair of sender and receiver should not possess more than one pair of link. Symmetry and asymmetry between the sending and receiving can also be implemented i.e. either both process will name each other for sending and receiving the messages or only sender will name receiver for sending the message and there is no need for receiver for naming the sender for receiving the message.The problem with this method of communication is that if the name of one process changes, this method will not work.

In Indirect message passing, processes uses mailboxes (also referred to as ports) for sending and receiving messages. Each mailbox has a unique id and processes can communicate only if they share a mailbox. Link established only if processes share a common mailbox and a single link can be associated with many processes. Each pair of processes can share several communication links and these link may be unidirectional or bi-directional. Suppose two process want to communicate though Indirect message passing, the required operations are: create a mail box, use this mail box for sending and receiving messages, destroy the mail box. The standard primitives used are : send(A, message) which means send the message to mailbox A. The primitive for the receiving the message also works in the same way e.g. received (A, message). There is a problem in this mailbox implementation. Suppose there are more than two processes sharing the same mailbox and suppose the process p1 sends a message to the mailbox, which process will be the receiver? This can be solved by either forcing that only two processes can share a single mailbox or enforcing that only one process is allowed to execute the receive at a given time or select any process randomly and notify the sender about the receiver. A mailbox can be made private to a single sender/receiver pair and can also be shared between multiple sender/receiver pairs. Port is an implementation of such mailbox which can have multiple sender and single receiver. It is used in client/server application (Here server is the receiver). The port is owned by the receiving process and created by OS on the request of the receiver process and can be destroyed either on request of the same receiver process or when the receiver terminates itself. Enforcing that only one process is allowed to execute the receive can be done using the concept of mutual exclusion. Mutex mailbox is create which is shared by n process. Sender is non-blocking and sends the message. The first process which executes the receive will enter in the critical section and all other processes will be blocking and will wait.

Answer for Question 3a:

thread is light weight process, and every thread have its own, stack , register, and PC(one of the register in CPU contain address of
next instruction to be executed), so only address space that is shared by all thread for a single process.

what type of data structures are used to exchange information and which address space these date are stored in inter process communication

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote