Operating System: Inter Process Communication: Message Passing Shared Memory

saurabhschool
6 May 201408:04

Summary

TLDRThis lecture explores interprocess communication, where processes, similar to tasks performed by individuals, interact to complete work. It discusses two types of processes: independent and cooperating. Cooperating processes can affect each other and communicate through shared memory or message passing. The lecture also covers synchronization methods, including blocking and non-blocking calls, using relatable analogies to explain how processes wait for or send messages. Overall, it provides a comprehensive understanding of how processes communicate and synchronize within an operating system.

Takeaways

  • 🤝 Interprocess Communication (IPC) is the exchange of information between multiple processes, akin to people working together on a task.
  • 🔍 Processes can be independent or cooperating; cooperating processes affect or are affected by each other, while independent processes do not communicate.
  • 👥 Cooperation between processes can enhance information sharing, computation speed, modularity, and convenience in task division.
  • 📬 Two primary methods of IPC are shared memory and message passing, which allow processes to interact as if they are leaving notes or sending direct messages.
  • 📝 Shared memory is a common area where processes can read from or write to, like a notice board used by two friends working different shifts.
  • 💌 Message passing involves one process sending a message to another, similar to friends making plans to meet, requiring a receiver to acknowledge the message.
  • 🔄 The operating system facilitates IPC much like how humans interact, with processes communicating through shared resources or direct messaging.
  • 🔄 The communication model involves processes sending and receiving messages, sometimes through an intermediary, which can be likened to a 'colonel' in the analogy.
  • 📦 The producer-consumer problem is an example of IPC where one process produces data and another consumes it, often managed by a buffer with potential bounded or unbounded sizes.
  • 🚫 Synchronization in IPC includes blocking or synchronous calls where the sender waits for the receiver to accept the message, like knocking on a door until it's opened.
  • 🔄 Non-blocking or asynchronous calls allow the sender to leave a message without waiting, similar to putting a letter in a mailbox and returning to other tasks.

Q & A

  • What is interprocess communication?

    -Interprocess communication (IPC) is a mechanism that allows different processes to exchange data or signals, enabling them to coordinate and synchronize their actions.

  • Why do processes need to communicate with each other?

    -Processes need to communicate to share information, speed up computation by working in parallel, increase modularity by dividing tasks, and for convenience in combining different tasks performed by separate processes.

  • Can you provide an example of how two people working together in a kitchen illustrate interprocess communication?

    -In the kitchen example, one person cuts vegetables while the other cooks them. They need to communicate to coordinate their tasks, such as waiting for the vegetables to be cut before cooking, which is similar to how processes need to communicate to synchronize their actions.

  • What are the two main methods of IPC mentioned in the script?

    -The two main methods of IPC mentioned are shared memory and message passing.

  • How does shared memory IPC work?

    -Shared memory IPC involves a common memory space that multiple processes can access to exchange data. It's like a notice board where one person leaves a message for another to read and act upon.

  • Can you explain the concept of message passing IPC?

    -Message passing IPC involves sending messages between processes. One process sends a message, and another receives it. It's similar to two friends making plans to meet by sending messages to each other.

  • What is the difference between blocking and non-blocking send in IPC?

    -A blocking send means the sender process will wait until the message is received by the recipient before it can continue execution. Non-blocking send allows the sender to leave the message and continue its work without waiting for the message to be received.

  • What is the producer-consumer problem in the context of IPC?

    -The producer-consumer problem is a classic synchronization issue where one process (the producer) generates data, and another process (the consumer) consumes it. The problem is to coordinate the production and consumption so that the producer does not overflow the buffer and the consumer does not read from an empty buffer.

  • What is a bounded buffer in IPC?

    -A bounded buffer is a fixed-size buffer used in IPC. It assumes a limited capacity for storing data, unlike an unbounded buffer which theoretically has no limit to how much data it can hold.

  • Why is synchronization important in IPC?

    -Synchronization is important in IPC to ensure that processes coordinate their actions properly. It prevents issues such as race conditions and ensures that data is accessed in a controlled manner to avoid conflicts.

  • How does the operating system facilitate IPC between processes?

    -The operating system provides mechanisms and resources for processes to communicate, such as shared memory spaces and message queues. It also manages synchronization to ensure orderly communication between processes.

Outlines

00:00

🤝 Understanding Interprocess Communication

This paragraph introduces the concept of interprocess communication (IPC), explaining it as a method for processes to interact and share information. The analogy of two people cooking together is used to illustrate how processes can be dependent and cooperate, needing to communicate with each other. The paragraph also contrasts this with independent processes that do not require communication. It outlines the reasons for processes to cooperate, such as information sharing, computation speed up, modularity, and convenience. Two primary methods of IPC are discussed: shared memory, where processes access the same memory space, and message passing, where processes send messages to each other. The paragraph concludes with an analogy of a notice board for night and day shift workers to communicate, emphasizing the importance of IPC in coordinating tasks.

05:01

🔄 Synchronization and Communication Models in IPC

The second paragraph delves into the producer-consumer problem as an example of cooperating processes in IPC, highlighting the use of buffers for message passing. It distinguishes between unbounded and bounded buffers, with the latter being more common due to fixed size limitations. The paragraph then discusses synchronization issues in IPC, such as blocking or synchronous calls, where the sender waits for the message to be received, compared to non-blocking or asynchronous calls, where the sender does not wait and the receiver may poll for messages. The summary also touches on the concepts of blocking send and receive, and non-blocking send and receive, providing relatable examples to clarify these technical terms. The paragraph concludes by emphasizing the importance of understanding IPC and synchronization for effective process communication.

Mindmap

Keywords

💡Interprocess Communication

Interprocess Communication (IPC) refers to the mechanisms and methods allowing different processes to exchange information. In the video, IPC is likened to two people working together on a task, such as cooking, where one person cuts vegetables while the other cooks, requiring them to communicate and coordinate their actions. IPC is essential for processes to cooperate and share data.

💡Process

A process is an instance of a program in execution, with its own memory space and resources. The video script uses the analogy of a person performing a task to explain a process. For example, one person might be cutting vegetables, which represents a single process with its own specific job to do within a larger system.

💡Cooperating Processes

Cooperating processes are those that need to communicate and work together to accomplish a task. In the script, this is illustrated by two people making food together, where one's task depends on the other's actions. These processes affect and are affected by each other, necessitating IPC.

💡Independent Processes

Independent processes do not require communication with other processes to perform their tasks. The video uses the example of a person studying in a different room, who does not need to interact with the people cooking, thus not requiring IPC.

💡Shared Memory

Shared memory is a method of IPC where multiple processes have access to the same memory space, allowing them to exchange information directly. The script describes a notice board used by two friends working different shifts as an example of shared memory, where one leaves a message for the other to see later.

💡Message Passing

Message passing is another IPC method where processes communicate by sending and receiving messages. The video script uses the example of friends Bob and Sally making plans to meet, which represents the process of one process sending a message that another process must receive.

💡Synchronization

Synchronization in the context of IPC refers to the coordination of processes to manage access to shared resources or to ensure that messages are sent and received in the correct order. The script mentions blocking and non-blocking calls as forms of synchronization, where processes may wait for a message to be received or continue without waiting.

💡Blocking Send

A blocking send is a type of IPC operation where the sender process waits until the message is received by the intended recipient process. The video uses the analogy of knocking on someone's door and waiting for them to open it, emphasizing that the sender does not proceed until the message is acknowledged.

💡Blocking Receive

Blocking receive is when a process waits for a message to arrive before it can continue its execution. The script likens this to waiting for a Valentine's Day message, where the receiver waits for the message to arrive before reacting.

💡Non-Blocking Calls

Non-blocking calls, also known as asynchronous calls, allow a process to send a message without waiting for it to be received. The sender can continue with other tasks, and the message will be delivered independently. The script compares this to leaving a message in a mailbox without waiting for the recipient to retrieve it.

💡Producer-Consumer Problem

The producer-consumer problem is a classic synchronization issue in IPC where one process (the producer) generates data, and another process (the consumer) consumes it. The video script touches on this concept in the context of message passing, where one process sends messages that another process receives and processes.

Highlights

Interprocess communication (IPC) is the exchange of data or information between multiple processes.

Processes can be independent or cooperating, with cooperating processes affecting or being affected by each other.

Cooperating processes require IPC for tasks like information sharing, computation speedup, and modularity.

IPC can be achieved through shared memory, where processes access a common memory space, or message passing.

In shared memory IPC, processes communicate by reading from and writing to a shared memory segment.

Message passing involves sending and receiving messages between processes, like sending a note to a friend.

The operating system plays a role in facilitating IPC, similar to how humans interact in real life.

IPC models include message passing with a mailman (kernel) delivering messages, and shared memory where processes access a common memory space.

The producer-consumer problem is an example of cooperating processes, where one sends data and the other receives it.

Buffers can be unbounded, allowing unlimited data writing, or bounded, with a fixed size which is more common.

Synchronization is important in IPC to coordinate the execution of processes, avoiding issues like race conditions.

Blocking or synchronous calls involve processes waiting for IPC operations to complete before proceeding.

Non-blocking or asynchronous calls allow processes to continue executing without waiting for IPC operations.

Blocking send means the sender process waits until the message is received before continuing.

Blocking receive means the receiver process waits for a message to arrive before proceeding.

Non-blocking send allows the sender to leave a message and return without waiting for the receiver.

Non-blocking receive involves the receiver periodically checking for messages, without halting other tasks.

Understanding IPC is crucial for designing systems where multiple processes need to interact and share data efficiently.

Transcripts

play00:00

in this lecture we are going to learn

play00:02

about what is known as interprocess

play00:06

communication so what is interprocess

play00:09

communication so first to understand

play00:11

this let's try to dissect this

play00:14

interprocess so

play00:17

process communicating with each other

play00:20

okay so processes are basically some

play00:22

tasks that are being performed and they

play00:25

want to communicate so what will happen

play00:28

with that so it's basically something

play00:30

like two people are working on something

play00:33

okay so let's say I'm working with my

play00:36

friend and I'm making

play00:38

some dish okay so two people are there

play00:42

okay so both of them are working and

play00:46

he's cutting basically some vegetable

play00:48

and I'm cooking it on a frying pan okay

play00:51

so both of us are basically interacting

play00:54

with each other and I will be waiting

play00:56

for him to supply me with the cut

play00:59

vegetable and then I will cook and so on

play01:01

so these are basically some interrelated

play01:04

task okay so but some person if you one

play01:07

friend is studying here so mostly he

play01:09

will have no interaction because his

play01:12

work is different so the processes might

play01:14

be independent or they might be

play01:17

cooperating person in the kitchen and

play01:19

person in the study room they might not

play01:21

be communicating they are independent

play01:23

processes but if two people are

play01:25

simultaneously making food and

play01:27

cooperating with each other then they

play01:30

are dependent so cooperating process can

play01:33

affect or be affected by other processes

play01:36

okay if he is busy and he has not cut

play01:38

all the vegetables he will be waiting

play01:40

for him okay and then let's say his next

play01:43

task is to provide some oil to him so

play01:46

again he will have they have some kind

play01:48

of

play01:49

communication but he is just studying

play01:51

and he doesn't need them right now okay

play01:55

reasons for cooperating process of

play01:57

course so one is information Shar ing so

play02:00

if he needs let's say salt okay so he

play02:05

will ask this person that okay he will

play02:08

somehow needs to communicate that please

play02:10

bring me some salt and pepper okay so

play02:12

they have to communicate computation

play02:15

speed up let's say both of them now they

play02:17

have a stove two stoves so they both

play02:20

will be making two dishes and it will

play02:23

become faster modularity also he will be

play02:26

handling all the work of

play02:28

cleaning

play02:30

let's say and then something like

play02:32

cutting vegetables and he will be frying

play02:34

them he will be on the store convenience

play02:37

okay so it is convenient people are

play02:39

doing different works and then they are

play02:42

combining so cooperating processes need

play02:45

interprocess communication so similarly

play02:47

if you are doing some process so two

play02:50

processes they are trying to do some

play02:53

work okay they need to communicate and

play02:55

how do they communicate they use shared

play02:58

memory and and then they use message

play03:01

passing so they are the two different

play03:03

ways of so let's try to see shared

play03:05

memory so we two are friends okay and in

play03:09

fact so they have a notice board so one

play03:12

is working in a BP a call center and he

play03:15

okay so he what he does he works at

play03:18

night and the other one works in the day

play03:20

shift okay two people are there so they

play03:23

are they need to communicate okay so how

play03:26

do they communicate they have a notice

play03:27

board there and he says that okay okay

play03:31

please cook for me okay something like

play03:34

that so that other person when he goes

play03:38

in the morning and then the other person

play03:40

wakes up he will know that okay what he

play03:42

needs to do so this is a shared memory

play03:44

kind of process where two processes they

play03:47

have a shared memory and that's how they

play03:49

interact message

play03:51

passing two people so let's say Bob and

play03:56

Sally okay so they are friends and they

play03:58

say that okay they can send a message

play04:01

saying that okay let's meet at 4:00 okay

play04:04

we will have some fun time so Bob and

play04:06

Sally so they can interact so this is

play04:09

message passing I can send some message

play04:12

and Sally has to receive that message so

play04:15

this is how they interact so this is

play04:17

another way of communicating so this is

play04:19

how the processes interact and operating

play04:22

system is very much similar to how

play04:24

humans interact okay so how everything

play04:27

is related to person

play04:30

so this happens then communication model

play04:33

so process a process B so that's how

play04:35

they're showing so in terms of processes

play04:38

so they have a message passing so the

play04:41

processing M sends a message to the

play04:43

colonel and from there it goes to

play04:46

process B okay so Colonel is the person

play04:48

here who has the messages can

play04:51

communicate through him so that's there

play04:53

otherwise they have a shared memory here

play04:56

and process a can write something into

play04:58

the shared memory memory process we can

play05:00

read that thing so This Is How They

play05:05

communicate and then you have producer

play05:08

consumer problem so cooperating process

play05:12

someone is sending message and the other

play05:14

one is receiving message so your buffer

play05:17

where you write something that can be

play05:18

unbounded buffer there is practically no

play05:21

limit how much you can write but bounded

play05:23

buffer assumes that there is a fixed

play05:25

buffer size and which is the normal case

play05:28

so let let's try to

play05:31

see some more thing

play05:35

okay and that

play05:38

is basically synchronization okay so how

play05:42

you synchronize so there is a blocking

play05:45

or synchronous call where what happens

play05:47

if you send if let's say I'm sending

play05:50

something so that sender will block

play05:53

until that message is received so it's

play05:55

some kind of I'm going to some person's

play05:58

house and I will be knocking okay so I

play06:01

will be knocking at his door till that

play06:04

person opens I cannot just leave that

play06:06

message outside or in some mailbox I

play06:09

will wait okay some there is very some

play06:12

costly thing and I will wait till that

play06:15

person or someone opens the door and I

play06:17

give him I give him that costly gift or

play06:21

something okay that is blocking send

play06:24

another thing is blocking receive okay

play06:26

so that happens I'm waiting for on

play06:30

Valentine's Day some girl is waiting

play06:32

that his boyfriend should send some

play06:34

message okay so he is wait she's waiting

play06:37

and waiting waiting till he gets the

play06:39

message and then a smile comes on her

play06:41

face so this is blocking receive so

play06:44

something similar in the processes also

play06:47

so process is waiting for some message

play06:49

so like on a server so it always keep on

play06:52

waiting for some request web request to

play06:55

come so it's blocking

play06:57

receive blocking send what example you

play07:00

can think of so you can tell me in terms

play07:03

of computers so non-blocking calls or

play07:06

asynchronous calls or what a sender

play07:08

sends a message he doesn't care if

play07:11

someone is there or not he will put it

play07:13

in the door at the door and then he'll

play07:15

come back or in the mailbox so that is

play07:18

it work and that somehow is in fact good

play07:21

also that he doesn't have to wait but

play07:23

what kind of thing you want that you

play07:26

have to design based on your problem

play07:27

non-blocking receive

play07:30

I will keep on polling I'm not that much

play07:32

concerned okay so I will keep sometimes

play07:35

I check the door and see if some message

play07:38

is there if there is I take it otherwise

play07:41

I again go and do my work so that is

play07:44

nonblocking receive so I hope you

play07:46

understand this interprocess

play07:48

communication till now what I said so

play07:50

synchronization issue and how they

play07:52

communicate so using message passing and

play07:57

sending me uh sharing

play07:59

memory a shared memory through that the

play08:01

exchange I hope you understand this

play08:03

thanks a lot

Rate This

5.0 / 5 (0 votes)

Связанные теги
Interprocess CommunicationShared MemoryMessage PassingCooperating ProcessesSynchronizationBlocking CallsNon-blocking CallsComputer ScienceOperating SystemsReal-world Analogies
Вам нужно краткое изложение на английском?