+ All Categories
Home > Documents > Chap 7Lesson12EmsysNewIPC

Chap 7Lesson12EmsysNewIPC

Date post: 07-Nov-2014
Category:
Upload: sayali-shivarkar
View: 28 times
Download: 1 times
Share this document with a friend
Popular Tags:
21
2008 Chapter-7 L12: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 INTER-PROCESS COMMUNICATION AND SYNCHRONISATION: Lesson-12: Inter process communication
Transcript
Page 1: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

1

INTER-PROCESS COMMUNICATION AND SYNCHRONISATION:

Lesson-12:Inter process communication

Page 2: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

2

1. 1. Inter Process Communication

Page 3: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

3

Inter Processor Communication� Inter processor communication in a

multiprocessor system─ used to generate information about certain sets of computations finishing on one processor and to let the other processors waiting for finishing the computations take note of the information

� Similarly, there is inter process communication from a process (task or thread to another)

Page 4: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

4

Need of Inter Process Communication• Assume that there is need to send through the

kernel an output data (a message of a known size with or without a header or a flag to notify an event) for processing or taking note of by another task

• Global variables problems ─ shared data and no encapsulation of the data or message accessibility by other tasks

• Inter Process Communication (IPC) functions in the OS provide the solutions

Page 5: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

5

• means that a process (scheduler, task or ISR) generates some information by signal (for other process start) or value (for example of semaphore) or generates an output so that it lets another process take note or use it through the kernel functions for the IPCs

Inter Process Communication (IPC)

Page 6: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

6

• Used to signal for other process to start or

• post a token or flag or • generate message from the certain sets

of computations finishing on one task and to let the other tasks take note of signal or get the message

Inter Process Communication (IPC) in Multitasking System

Page 7: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

7

• Signal for other process to start

• Semaphore (as token, mutex) or counting semaphores for the inter task communication between tasks sharing a common buffer

Operating System Provisioning for the Operating System Provisioning for the IPC functionsIPC functions

Page 8: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

8

• Queue, • Mailbox • Pipe device• Socket device• Remote procedure call (RPC) for

distributed processes .

Operating System Provisioning for the Operating System Provisioning for the IPC functionsIPC functions

Page 9: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

9

2. Example of mutex 2. Example of mutex Inter Process Communication for print

Page 10: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

10

• print task can be shared among the multiple tasks, which use the mutex semaphore IPC in their critical sections

• When the buffer becomes available for new data, an IPC from the print task is generated and the kernel first takes note of it.

• Other tasks then take note of the IPC.

Inter Process Communication for printInter Process Communication for print

Page 11: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

11

• A task take note of IPC by OSSemPend( ) function─ used at the beginning of the critical section

• The task gets mutually exclusive access to the section to send messages into the print-buffer by using the OSSemPost ( ) function of the kernel at the end of the section

Inter Process Communication for Inter Process Communication for printprint

Page 12: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

12

3. Example of semaphore and mailbox 3. Example of semaphore and mailbox Inter Process Communication for display

of date and time

Page 13: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

13

• A mobile phone device Update_Timetask

• A task, Task_Display for a multi-line display of outputs which displays current time on last line

Processes for display of updated date Processes for display of updated date and timeand time

Page 14: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

14

• When the multi-line display task finishes the display of the last but one line, an IPC semaphore supdateTD from the display task is posted and the kernel takes note of it.

• The task — continuously updating time — then takes the supdateTD

Semaphore Inter Process Communication Semaphore Inter Process Communication for display of date and timefor display of date and time

Page 15: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

15

static void Task_Display (void *taskPointer) {

.while (1) {

.

. /* IPC for requesting TimeDate */ OSSemPost (supdateTD) /* Post for the semaphore supdateTD.

Coding Example of posting semaphore Coding Example of posting semaphore

Page 16: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

16

. /* IPC for waiting time and date in the mailbox */ TimeDateMsg = OSMboxPend (timeDate) /* Wait for the mailbox message timeDate. The timeDate becomes null after the TimeDateMsg equals the updated time and date */

/* Code for display TimeDateMsg Time: hr:mmDate: month:date */

.};

Coding Example of waiting for mailbox Coding Example of waiting for mailbox message message

Page 17: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

17

static void Task_ Update_Time (void *taskPointer) {

.while (1) {OSSemPend (supdateTD) /* Wait the

semaphore supdateTD. supdateT becomes 0 after taking the semaphore */

. /* Codes for updating time and date as per the number of clock interrupts received so far */

Coding Example of waiting for the Coding Example of waiting for the semaphore semaphore

Page 18: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

18

/* Codes for writing into the mailbox */ OSMboxPost (timeDate) /* Post for the

mailbox message and timeDate, which equaled null earlier, now equals new updated time and date*/

.};

Coding Example for posting the mailbox Coding Example for posting the mailbox message message

Page 19: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

19

SummarySummary

Page 20: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

20

We learnt� Inter process communication (IPC) means

that a process (scheduler or task or ISR) generates some information by setting or resetting a Token or value, or generates an output so that it lets another process take note or to signal to OS for starting a process or use it under the control of an OS

Page 21: Chap 7Lesson12EmsysNewIPC

2008Chapter-7 L12: "Embedded Systems - Architecture,

Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

21

End of End of Lesson12 of Chapter 7 onLesson12 of Chapter 7 onInter Process Communication Inter Process Communication


Recommended