Processes and Interprocess Communication: Shared Memory and Message Passing, Slides of Computer Networks

An overview of processes and interprocess communication (ipc). It discusses the concept of a process and the difference between independent and cooperating processes. The document then introduces two fundamental models of ipc: shared memory and message passing. How shared memory works, including the process of establishing a shared memory region and accessing it. It also explains how message passing works, including the use of mailboxes and sockets for communication. The document concludes with a discussion of socket communication and an algorithm for a client. Recommended resources for further learning include books and tutorials on operating systems and network programming.

Typology: Slides

2011/2012

Uploaded on 07/17/2012

ashau_2000
ashau_2000 🇮🇳

31 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Contact Process & Interprocess Communication Development Books WebPage & Mailing List
Outline of the Course
1Contact
2Process & Interprocess Communication
3Development
4Books
5
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Processes and Interprocess Communication: Shared Memory and Message Passing and more Slides Computer Networks in PDF only on Docsity!

Outline of the Course

1 Contact

(^2) Process & Interprocess Communication

(^3) Development

4 Books

5

Contact

Interprocess Communication

Cooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data and information. There are two fundamental models of interprocess communication.

Shared memory Message passing

Shared memory

Interprocess communication using shared memory requires communicating processes to establish a region of shared memory. Typically, a shared-memory region resides in the address space of the process creating the shared-memory segment. Other processes that wish to communicate using this shared-memory segment must attach it to their address space. The code for accessing and manipulating the shared memory be written explicitly by the application programmer.

Communications models

Figure: Communications models, (a) Message passing, (b) Shared memory.

Message Passing

Message Passing via Direct Communication Message Passing via 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 Operations Create a new mailbox Send and receive messages through mailbox Destroy a mailbox Primitives are defined as: send(A, message) - send a message to mailbox A receive(A, message) - receive a message from mailbox A

Sockets

A socket is defined as an endpoint for communication Concatenation of IP address and port The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19. Communication consists between a pair of sockets

Algorithm for Client

Socket Functions

int socket(int family,int type,int proto); bind(mysock, (sockaddr ) &myaddr, sizeof(myaddr)); int listen(int sockfd, int backlog); int accept(int sockfd, struct sockaddr cliaddr, socklen_t *addrlen); int connect(int sockfd, const struct sockaddr *server, socklen_t addrlen); int read(int fd, char *buf, int max); int write(int fd, char *buf, int num);

Development

Server program should be able to receive and store a text file in its local directory. Server program should be able to respond with an HTML based welcome message. Server program should be able to log its activity. Server should display "Waiting for a client, current time is hh:mm:ss, dd/mm/yyyy" after every five minutes.

Books

Silberschatz, Galvin and Gagne, Operating System Concepts, 7/E, 2005, John Wiley & Sons, Inc. Stevens, UNIX Network Programming, Volume 2 : Interprocess Communications, 2/E, 1999, Prentice Hall.