0% found this document useful (0 votes)
50 views

Chapter 11

This document discusses message queue management functions in an operating system kernel. It describes functions for creating, deleting, flushing, pending on, posting to, and querying message queues. It also discusses how tasks, interrupts, and message queues interact using data structures like the Queue Control Block and lists of free QCBs. Circular buffers are described as one method of implementing message queues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Chapter 11

This document discusses message queue management functions in an operating system kernel. It describes functions for creating, deleting, flushing, pending on, posting to, and querying message queues. It also discusses how tasks, interrupts, and message queues interact using data structures like the Queue Control Block and lists of free QCBs. Circular buffers are described as one method of implementing message queues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Chapter 11:

Message Queue Management

1
Functions
• OSQCreate()
• OSQDel()
• OSQFlush()
– 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()

2
Tasks, ISR, and
a Message Queue

3
Data Structures for
a Message Queue

4
Queue Control Block (QCB)

5
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 6
List of Free Queue Control Blocks (QCB)

7
A circular buffer

8
OSQCreate()

9
OSQCreate()

10
OSQDel()
• Case 1: OS_DEL_NO_PEND
– Return queue control block
– Return event control block

• Case 2: OS_DEL_ALWAYS
– Ready all waiting tasks
– Return queue control block
– Return event control block
– Schedule

11
OSQDel()

12
OSQDel()

13
OSQDel()

14
OSQPend()

15
OSQPend()

16
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

17
OSQPost()

18
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

19
OSQPostFront()

20
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

21
OSQPostOpt()

22
OSQPostOpt()

23
OSQFlush()
• Reset the variables – .OSQIn, .OSQOut
and .OSQEntries

24
OSQFlush()

25

You might also like