 Wind River Systems, Inc. 1997 Chapter - 7 Intertask Communication.

Slides:



Advertisements
Similar presentations
Inter-Process Communication: Message Passing Tore Larsen Slides by T. Plagemann, Pål Halvorsen, Kai Li, and Andrew S. Tanenbaum.
Advertisements

Remote Procedure Call (RPC)
Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection.
 Wind River Systems, Inc Chapter - 8 Memory.
 Wind River Systems, Inc Chapter - 6 Semaphores.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Threads© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
T.B. Skaali, Department of Physics, University of Oslo) FYS 4220 – 2012 / #5 Real Time and Embedded Data Systems and Computing Message based Process-Process.
FreeRTOS.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Inter-Process Communication Mechanisms CSE331 Operating Systems Design.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
 Wind River Systems, Inc Chapter - 13 Network Programming.
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Devices in VxWorks. §VxWorks device drivers follow the basic conventions, but differ in specifics.
® 7-2 Semaphores 7.1Overview Binary Semaphores and Synchronization Mutual Exclusion.
Chapter 71 Deadlock Detection revisited. Chapter 72 Message Passing (see Section 4.5 in Processes Chapter)  A general method used for interprocess communication.
Nguy ễ n Hoàng Tâm Nguy ễ n Văn Tr ọ ng
Advanced Sockets API-II Vinayak Jagtap
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
Operating Systems Yasir Kiani. 13-Sep Agenda for Today Review of previous lecture Interprocess communication (IPC) and process synchronization UNIX/Linux.
Consider Letting inetd Launch Your Application. inetd daemon  Problems starting with /etc/rc(without inet daemon)  All the servers contains nearly identical.
Threads Chapter 26. Threads Light-weight processes Each process can have multiple threads of concurrent control. What’s wrong with processes? fork() is.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
® 14-2 Optional Products 14.1Overview Shared Memory Objects (VxMP) Virtual Memory (VxVMI)
Process Synchronization Azzam Mourad COEN 346.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Chapter 7 - Interprocess Communication Patterns
Threads-Process Interaction. CONTENTS  Threads  Process interaction.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Message Passing Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
 Wind River Systems, Inc Chapter - 15 Optional Products.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Lecture 8 Task Utilization. Theoretical Analysis.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Chapter 3: Windows7 Part 5.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 3: Process Concept
Topics Covered What is Real Time Operating System (RTOS)
Protection of System Resources
Threads Threads.
Applied Operating System Concepts
Interprocess Communication (IPC)
I/O Systems I/O Hardware Application I/O Interface
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Chapter 1 Introduction to Operating System Part 5
Operating Systems Lecture 8.
Computer Science & Engineering Electrical Engineering
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Intertask Communication
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

 Wind River Systems, Inc Chapter - 7 Intertask Communication

7-2 Intertask Communication Introduction Shared Memory Message Queues Pipes

7-3 Overview Multitasking systems need communication between tasks. Data / information being shared. Mechanism to inform task that data is available to read or write. Mechanism to prevent tasks from interfering with each other (e.g., if there are two writers). Two common methods : Intertask communication made up of three components : Shared memory. Message passing.

7-4 Shared Memory tTaskAtTaskB fooLib.c LOCAL SEM_ID fooSem; LOCAL FOO_BUF fooBuffer; fooSet ( ) …… fooGet ( ) …...

7-5 Message Passing Queues VxWorks pipes and message queues are used for passing messages between tasks. FIFO buffer of messages Synchronization More robust than shared data. Both pipes and message queues provide : taskAtaskB Can be used from task to task, or from ISR to task. Mutual Exclusion

7-6 Intertask Communication Introduction Shared Memory Message Queues Pipes

7-7 Overview All tasks reside in a common address space. Write a library of routines to access these global or static data-structures. All tasks which use these routines manipulate the same physical memory. VxWorks provides libraries to manipulate common data structures such as linked lists and ring buffers. User-defined data structures may be used for Intertask communication : Semaphores may be used to provide mutual exclusion and synchronization.

7-8 Linked Lists lstLib contains routines to manipulate doubly linked lists. Mutual exclusion and synchronization are not built-in. NULL List DescriptorUser node 1User node 2 NODE User specific data head tail count = 2

7-9 Ring Buffers rngLib contains routines to manipulate ring buffers (FIFO data streams) Mutual exclusion is not required if there is only one reader and one writer. Otherwise, user must provide. readerwriter Synchronization is not built-in.

7-10 Intertask Communication Introduction Shared Memory Message Queues Pipes

7-11 Message Queues Used for intertask communication within one CPU. Synchronization. Task control is built-in : FIFO buffer of variable length messages. Mutual Exclusion.

7-12 Creating a Message Queue Returns an id used to reference this message queue or NULL on error. MSG_Q_ID msgQCreate (maxMsgs, maxMsgLength, options) maxMsgs Maximum number of messages on the queue. maxMsgLength Maximum size in bytes of a message on the queue. options Queue type for pended tasks (MSG_Q_FIFO or MSG_Q_PRIORITY)

7-13 Sending Messages STATUS msgQSend (msgQId, buffer, nBytes, timeout, priority) msgQIdMSG_Q_ID returned by msgQCreate( ). buffer Address of data to put on queue. nBytes Number of bytes to put on queue. timeout Maximum time to wait (if queue is full). Values can be tick count, WAIT_FOREVER or NO_WAIT. priority“Priority“ of message to put on queue. If MSG_PRI_URGENT, message put at head of queue. If MSG_PRI_NORMAL message put at end of queue.

7-14 Message Sending Examples char buf[BUFSIZE]; status = msgQSend (msgQId, buf, sizeof(buf), WAIT_FOREVER, MSG_PRI_NORMAL); status = msgQSend (msgQId, buf, sizeof(buf), NO_WAIT, MSG_PRI_URGENT);

7-15 Receiving Messages int msgQReceive (msgQId, buffer, maxNBytes,timeout) msgQId Returned from msgQCreate( ). buffer Address to store message. MaxNBytes Maximum size of message to read from queue. timeout Maximum time to wait (if no message available). Values can be clock ticks, WAIT_FOREVER or NO_WAIT. Returns number of bytes read on success, ERROR on timeout or invalid msgQId. Unread bytes in a message are lost.

7-16 Deleting a Message Queue STATUS msgQDelete (msgQId) Deletes message queue. Tasks pended on queue will be unpended; their msgQSend( ) or msgQReceive( ) calls return ERROR. These tasks’ errno values will be set to S_objLib_OBJ_DELETED.

7-17 Gathering Data with Message Queues To capture data quickly for future examination : poll task or ISR consumer Have a poll task or ISR place device data in a message queue. Input devic e devic data device data devic data device data Have a lower priority task read data from this queue for processing.

7-18 Client-Server model with Message Queues Server Task this is a mes this is a mess this is a mes this is a message Client

7-19 Client-Server Variations The client needs a reply from the server ? How would the previous code example change if : We wish to simultaneously service several requests ? (we may wish to do this if there are multiple clients, and this service requires blocking while I / O completes).

7-20 Message - Queue Browser To examine a message queue, enter the message queue ID in the Browser’s Show box, and click on Show. Mempart Ox3ff988 Attributes options =PRIORITY maxMsgs =10 maxLength=100 sendTimeouts=0 recvTimeouts=0 Receivers Blocked Senders Blocked Messages Queued 0 address=0x3ffdb4 length=0x7 value= f 0a *hello.. 1 address=0x3ffd48 length=0x4 value= a 0d*hi..

7-21 Intertask Communication Introduction Shared Memory Message Queues Pipes

7-22 Pipes this is a mes this is a mess this is a mes this is a message Virtual I/O device managed by pipeDrv. Built on top of message queues. Standard I/O system interface (read / write). Similar to named pipes in UNIX. (UNIX Host)

7-23 Creating a Pipe STATUS pipeDevCreate (name, nMessages, nBytes) nameName of pipe device, by convention use “/pipe/yourName”. nMessagesMaximum number of messages in the pipe. nBytes Maximum size in bytes of each message. Returns OK on success, otherwise ERROR.

7-24 Example Pipe Creation -->pipeDevCreate (“/pipe/myPipe”,10,100) value = 0 = 0x0 -->devs drvname 0/null 1/tyCo/0 1/tyCo/1 4columbia: 2/pipe/myPipe

7-25 Reading and Writing to a Pipe this is a mes this is a mess this is a mes this is a message To access an existing pipe, first open it with open( ). To read from the pipe use read( ). To write to the pipe use write( ). fd = open (“/pipe/myPipe”, O_RDWR, 0); write (fd, msg, len); read (fd, msg, len);

7-26 UNIX: Differences from UNIX “Named Pipes” Message-oriented : preserves message boundaries Faster ( no system call overhead ). File descriptor table is global in VxWorks. A pipe opened by one task can be read / written by another task.

7-27 Message Queues vs. Pipes Message Queue advantages : Timeouts capability. Message prioritization. Faster. Pipe advantages : Use standard I / O interface i.e., open ( ), close ( ), read ( ), write( ), etc. Can perform redirection via ioTaskStdSet( ) (see I/O chapter) show( ). Can be deleted. File descriptor can be used in select ( ).

7-28 Summary Shared Memory Often used in conjunction with semaphores. lstLib and rngLib can help. Message queues : msgQCreate( ) msgQSend( ) msgQReceive( ) Pipes pipeDevCreate( ) Access pipe via file descriptor returned from open( ). Use write( ) / read( ) to send / receive messages from a pipe.