3-Chapter - 10 - RTOS - Task Communication

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Designing with RTOS

Task Communication
In a multitasking system, multiple tasks/processes run concurrently (in pseudo parallelism)
and each process may or may not interact between. Based on the degree of interaction,
the processes /tasks running on an OS are classified as

• Co-operating Processes: In the co-operating interaction model one process requires the
inputs from other processes to complete its execution.
• Competing Processes: The competing processes do not share anything among
themselves but they share the system resources. The competing processes compete for
the system resources such as file, display device etc

The co-operating processes exchanges information and communicate through


• Co-operation through sharing: Exchange data through some shared resources.
• Co-operation through Communication: No data is shared between the processes. But
they communicate for execution synchronization.
Designing with RTOS
Inter Process (Task) Communication (IPC)
✔ IPC refers to the mechanism through which tasks/processes communicate each other
✔ IPC is essential for task /process execution co-ordination and synchronization
✔ Implementation of IPC mechanism is OS kernel dependent
✔ Some important IPC mechanisms adopted by OS kernels are:
✔ Shared Memory
✔ Global Variables
✔ Pipes
✔ Message Passing
✔ Message Queues
✔ Mailbox
✔ Remote Procedure Calls (RPC)
Designing with RTOS
IPC – Shared Memory
✔ Processes share some area of the memory to communicate among them
✔ Information to be communicated by the process is written to the shared
memory area
✔ Processes which require this information can read the same from the shared
memory area
✔ Same as the real world concept where a ‘Notice Board’ is used by the college
to publish the information for students (The only exception is; only college has
the right to modify the information published on the Notice board and students
are given ‘Read’ only access. Meaning it is only a one way channel)

Concept of Shared Memory


Designing with RTOS
IPC – Shared Memory: Pipes
• Pipe is used as a shared memory for inter processes communication.
• 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 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 implementation of ‘Pipes’ is OS dependent.. Namely:


•Anonymous Pipes: The anonymous pipes are unnamed, unidirectional pipes used for data transfer between
two processes.
•Named Pipes: Named pipe is a named, unidirectional or bi-directional pipe for data exchange between
processes. With named pipes, any process can act as both client and server allowing point-to-point
communication either on the same machine or between processes running on different machines connected to
a network

Concept of Shared Memory


Designing with RTOS
IPC – Message Passing: Message Queues

✔ Process which needs to communicate with


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.

Concept of Message Queue


Designing with RTOS
IPC – Message Passing: Mailbox

✔ A special implementation of message queue for


single message transfer.
✔ Usually used for one way communication
✔ One task/process creates the mailbox and other
tasks/process can subscribe to this mailbox for
getting message notification
✔ The implementation of the mailbox is OS kernel
dependent
✔ The MicroC/OS-II RTOS implements mailbox as a
mechanism for inter task communication

Concept of Message Queue


Designing with RTOS
IPC – Remote Procedure Call (RPC)
✔ The IPC mechanism used by a process to call a procedure of another process running
either on the same CPU or on a different CPU which is interconnected in a network
✔ RPC is mainly used for distributed applications like client-server applications. The
Process which needs to be invoked remotely is known as server and the Process which
initiates an RPC request is known as client.
✔ With RPC it is possible to communicate over a heterogeneous network.
✔ RPC uses sockets for implementing 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 sockets etc.
✔ The INET Socket works on Internet Communication protocol:TCP/IP, UDP etc.
Designing with RTOS
IPC – Remote Procedure Call (RPC)

Concept of Remote Procedure Call (RPC) for IPC


Multitasking and Task Communication
Learning Summary
✔ Processes in a multitasking system can be either Co-operating or Competing
✔ The co-operating processes share data for communicating among the processes
through Inter Process Communication (IPC), whereas competing processes do not
share anything among themselves but they share the system resources like display
devices, keyboard etc
✔ Shared memory, message passing and Remote Procedure Calls (RPC) are the
important IPC mechanisms through which co-operating processes communicate in
an Operating system environment
✔ Pipes, shared buffers, memory mapped objects etc are examples of shared memory
✔ Message queues, mailbox, signals etc are examples of message passing technique
✔ The implementation of the IPC mechanism is OS kernel dependent

You might also like