Download presentation
Presentation is loading. Please wait.
1
Chapter 11: Message Queue Management
2
Functions OSQCreate() OSQDel() OSQFlush() OSQPend() OSQAccept()
Flushing a queue OSQPend() OSQAccept() OSQPost() Sending a message to a queue (FIFO) OSQPostFront() Sending a message to a queue (LIFO) OSQPostOpt() Sending a message to a queue (LIFO or FIFO) OSQQuery()
3
Tasks, ISR, and a Message Queue
4
Data Structures for a Message Queue
5
Queue Control Block (QCB)
6
Fields in the QCB .OSQPtr: links free QCB .OSQStart: point to the start of the queue .OSQEnd: point to the location past the end of the queue .OSQIn: point to location where the next message will be inserted. .OSQOut: point to the next message to be extracted from the queue .OSQSize: Contains the size of the message storage area. .OSQEntries: contains the number of entries in the queue
7
List of Free Queue Control Blocks (QCB)
8
A circular buffer
9
OSQCreate()
10
OSQCreate()
11
OSQDel() Case 1: OS_DEL_NO_PEND Case 2: OS_DEL_ALWAYS
Return queue control block Return event control block Case 2: OS_DEL_ALWAYS Ready all waiting tasks Schedule
12
OSQDel()
13
OSQDel()
14
OSQDel()
15
OSQPend()
16
OSQPend()
17
OSQPost() Case 1: at least one task pending on the queue
Ready the highest priority task Case 2: otherwise The queue is full return (non-blocking) The queue is not full insert the message
18
OSQPost()
19
OSQPostFront() Case 1: at least one task pending on the queue
Ready the highest priority task Case 2: otherwise The queue is full return (non-blocking) The queue is not full insert the message
20
OSQPostFront()
21
OSQPostOpt() pevent: is a pointer to the event control block associated with the desired queue msg: is a pointer to the message to send opt OS_POST_OPT_NONE: identical to OSQPost() OS_POST_OPT_FRONT: identical to OSQPostFront() OS_POST_OPT_BROADCAST: identical to OSQPost() but will broadcast 'msg' to ALL waiting tasks OS_POST_OPT_FRONT + OS_POST_OPT_BROADCAST: is identical to OSQPostFront() except that will broadcast 'msg' to ALL waiting tasks
22
OSQPostOpt()
23
OSQPostOpt()
24
OSQFlush() Reset the variables – .OSQIn, .OSQOut and .OSQEntries
25
OSQFlush()
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.