Example: biology

Chapter-8 L15: Embedded Systems - Architecture ...

INTER-PROCESS COMMUNICATION. AND SYNCHRONISATION OF. PROCESSES, THREADS and TASKS: Lesson-16: Mailbox Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 1. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. 1. IPC Mailbox functions Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 2. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Queue and Mailbox Some OSes provide the mailbox and queue both IPC functions When the IPC functions for mailbox are not provided by an OS, then the OS. employs queue for the same purpose. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 3. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox Mailbox (for message) is an IPC. through a message-block at an OS. that can be used only by a single destined task. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 4.

2008 Chapter-8 L15: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 3 • Some OSes provide the mailbox and

Tags:

  Architecture, Programming, System, Quot, Embedded, Embedded systems, Quot embedded systems architecture, Programming and

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Chapter-8 L15: Embedded Systems - Architecture ...

1 INTER-PROCESS COMMUNICATION. AND SYNCHRONISATION OF. PROCESSES, THREADS and TASKS: Lesson-16: Mailbox Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 1. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. 1. IPC Mailbox functions Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 2. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Queue and Mailbox Some OSes provide the mailbox and queue both IPC functions When the IPC functions for mailbox are not provided by an OS, then the OS. employs queue for the same purpose. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 3. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox Mailbox (for message) is an IPC. through a message-block at an OS. that can be used only by a single destined task. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 4.

2 Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox . A task on an OS function call puts (means post and also send) into the mailbox only a pointer to a mailbox message Mailbox message may also include a header to identify the message-type specification.]. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 5. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC features OS provides for inserting and deleting message into the mailbox message- pointer. Deleting means message-pointer pointing to Null. Each mailbox for a message need initialization (creation) before using the functions in the scheduler for the message queue and message pointer pointing to Null. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 6. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC features.

3 There may be a provision for multiple mailboxes for the multiple types or destinations of messages. Each mailbox has an ID. Each mailbox usually has one message pointer only, which can point to message. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 7. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox Types Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 8. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC features . When an OS call is to post into the mailbox, the message bytes are as per the pointed number of bytes by the mailbox message pointer. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 9. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. 2. Mailbox Related Functions at the OS. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 10.

4 Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 11. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Tasks j sending a message-pointer into a mailbox and task k receiving that Mailbox mb1. Task j *mb1 Task k Task C. Pend mb1. Post OS Mailbox functions mb1, *mj Create, Query, Post, Pend, Accept, Delete Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 12. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Section of codes in the tasks B, C, and D waiting for messages m1, m2 and m3 into mailboxes Task A Task B Task C Task D. Pend m1 Pend m2 Pend m3. Post m2 Post m3. Post m1. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 13. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task i sending message pointer *mi to initiate a task section waiting to take a message i before it could run *mi = NULL.

5 OS Task j signal *mi =. Task i mask j NULL. Wait Start *mi Not Send mi Null mi Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 14. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC functions 1. OSMBoxCreate creates a box and initializes the mailbox contents with a NULL pointer at *msg . 2. OSMBoxPost sends at *msg, which now does not point to Null. An ISR can also post into mailbox for a task Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 15. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC functions . 3. OSMBoxWait (Pend) waits for *msg not Null, which is read when not Null and again *msg points to Null. The time out and error handling function can be provided with Pend function argument. ISR not permitted to wait for message into mailbox. Only the task can wait Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 16.

6 Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Mailbox IPC functions . 4. OSMBoxAccept reads the message at *msg after checking the presence yes or no [No wait.] Deletes (reads) the mailbox message when read and *msg again points to Null An ISR can also accept mailbox message for a task 5. OSMBoxQuery queries the mailbox *msg. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 17. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. 3. IPC Queue functions Application Example Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 18. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_j sending an integer value mj int *m_j; A global variable integer pointer ..; ..; ..;. static void Task_j (void *taskPointer) {.. while (1) {..; ..; ..;..; ..; ..;. OSMboxPost (m_j);. /* after this instruction executes the next task section can operate on the m_j */.}}

7 ; ..; ..;}; }. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 19. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_k waiting for the mi static void Task_k (void *taskPointer) {.. while (1) {..; ..; ..;. OSMboxPend (m_j); /* OSMboxPend waits for mailbox message m_i and when available m_i, reset *m_i = NULL and proceed to next statement */..; ..; ..;};}. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 20. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task Read_Amount in ACVM. static void Task Read-Amount (void *taskPointer) {.. while (1) {.. /* Codes for reading the coins inserted into the machine */. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 21. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task Read_Amount posting amount information in ACVM.

8 /* Codes for writing into the mailbox full amount message if cost of chocolate is received*/. OSMboxPost (mboxAmt, fullAmount) /* Post for the mailbox message and fullAmount, which equaled null now equals fullAmount message pointer*/.. };. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 22. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Chocolate delivery task in ACVM. static void Chocolate delivery task (void *taskPointer) {.. while (1) {.. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 23. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Chocolate delivery task waiting for message in ACVM. /* IPC for requesting full amount message */. fullAmountMsg = OSMboxPend (mboxAmt, 20, *err) /* Wait for the mailbox mboxAmt message for 20 clock ticks and error if message not found. mboxAmt becomes null after message is read.}

9 };. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 24. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_User_Keypad_Input in ACVM. static void Task_User_Keypad_Input (void *taskPointer) {.. while (1) {.. /* Codes for reading keys pressed by the user before the enter key */. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 25. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_User_Keypad_Input posting amount information in ACVM. /* Codes for writing into the mailbox */. OSMboxPost (mboxUser, userInput) /* Post for the mailbox message and userInput, which equaled null now equals userInput message pointer*/.. };. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 26. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_Display in ACVM. static void Task_Display (void *taskPointer).

10 {.. while (1) {.. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 27. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_Display waiting for a message in ACVM. /* IPC for waiting for User input message */. UserInputMsg = OSMboxPend (mboxUser, 20, *err) /* Wait for the mailbox mboxUser message for 20 clock ticks and error if message not found. mboxUser becomes null after message is read.. /* Code for display of user Input */. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 28. Design& quot ; , Raj Kamal, Publs.: McGraw-Hill, Inc. Task_Display waiting for another message in ACVM. TimeDateMsg = OSMboxPend (timeDate, 20, err) /* Wait for the mailbox message timeDate. /* Code for display TimeDateMsg Time: hr:mm Date: month:date */.. };. Chapter-8 L15: & quot ; Embedded Systems - Architecture , programming and 2008 29.}


Related search queries