CHAP-5 Task - Communication
CHAP-5 Task - Communication
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 1 / 33
Task Communication Task Synchronization
Chapter Outline
1 Task Communication
2 Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 2 / 33
Task Communication Task Synchronization
Chapter Outline
1 Task Communication
2 Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 3 / 33
Task Communication Task Synchronization
Outline:
Task Communication
Shared Memory
Message Passing
Remote Procedure Call (RPC) and Socket
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 4 / 33
Task Communication Task Synchronization
Task Communication
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 5 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 6 / 33
Task Communication Task Synchronization
Shared Memory
1 Pipes
2 Memory Mapped Objects
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 7 / 33
Task Communication Task Synchronization
Cont’d ...
1 Pipes:
Pipes follow the client-server architecture.
A process which creates a pipe is known as pipe server and a process which
connects to a pipe is known as pipe client.
A pipe can be considered as a medium for information flow and has two
conceptual ends. It can be unidirectional, allowing information flow in one
direction or bidirectional allowing bi-directional information flow.
A unidirectional pipe allows the process connecting at one end of the pipe
to write to the pipe and the process connected at the other end of the pipe to
read the data, whereas a bi-directional pipe allows both reading and writing
at one end. The unidirectional pipe can be visualized as
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 8 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 9 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 10 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 11 / 33
Task Communication Task Synchronization
Message Passing
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 12 / 33
Task Communication Task Synchronization
Cont’d ...
1 Message Queues:
Process which wants to talk to another process posts the message to a
First-In-First-Out (FIFO) queue called “Message queue”, which stores the
messages temporarily in a system defined memory object, to pass it to the
desired process.
The implementation of the message queue, send and receive methods are
OS kernel dependent. Eg.msgget(),msgsnd(),msgrcv().
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 13 / 33
Task Communication Task Synchronization
Cont’d...
1 Mailbox:
Mailbox is a special implementation of message queue.
Usually used for one way communication,
Only a single message is exchanged through mailbox whereas “message
queue” can be used for exchanging multiple messages. One task/process
creates the mailbox and other tasks/process can subscribe to this mailbox
for getting message notification.
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 14 / 33
Task Communication Task Synchronization
Cont’d ...
1 Signaling:
Signals are used for an asynchronous notification mechanism. The signal
mainly used for the execution synchronization of tasks process/ tasks.
Signals do not carry any data and are not queued.
The implementation of signals is OS kernel dependent and VxWorks RTOS
kernel implements “signals” for inter process communication.
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 15 / 33
Task Communication Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 16 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 17 / 33
Task Communication Task Synchronization
Cont’d...
Socket:
Sockets are used for RPC communication.
Socket is a logical endpoint in a two-way communication link between two
applications running on a network.
A port number is associated with a socket so that the network layer of the
communication channel can deliver the data to the designated application.
Sockets are of different types namely; Internet sockets (INET), UNIX sock-
ets, etc.
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 18 / 33
Task Communication Task Synchronization
Chapter Outline
1 Task Communication
2 Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 19 / 33
Task Communication Task Synchronization
Outline:
Task Synchronization
Task Communication/Synchronization Issues
Conditions Favoring Deadlock
Task Synchronization Techniques
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 20 / 33
Task Communication Task Synchronization
Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 21 / 33
Task Communication Task Synchronization
Cont’d ...
The code memory area which holds the program instructions (piece of
code) for accessing a shared resource is known as “Critical Section”. In
order to synchronize the access to shared resources, the access to the
critical section should be exclusive.
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 22 / 33
Task Communication Task Synchronization
Cont’d...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 23 / 33
Task Communication Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 24 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 25 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 26 / 33
Task Communication Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 27 / 33
Task Communication Task Synchronization
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 28 / 33
Task Communication Task Synchronization
Cont’d...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 29 / 33
Task Communication Task Synchronization
Cont’d ...
“Only one process/ thread” can own the binary semaphore at a time.
The state of a “binary semaphore” object is set to signaled when it is not
ownedby any process/ thread, and set to non-signaled when it is owned by
any process/thread.
The implementation of binary semaphore is OS kernel dependent. Under
certain OS kernel it is referred as mutex.
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 30 / 33
Task Communication Task Synchronization
Cont’d...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 31 / 33
Task Communication Task Synchronization
Cont’d ...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 32 / 33
Task Communication Task Synchronization
Cont’d...
By: Awet Kidane (MSc) Introduction to Embedded System Mekelle Institute of Technology 33 / 33