The Osqpostfront () function and osqpost () are basically the same, but are used only when inserting new messages into the message queue. Osqout as a pointer to the next cell that inserts the message, not the. Osqin. The program manifest L6.24 is its source code. It is worth noting that the. The osqout pointer points to a cell that already has a message pointer inserted, so you must first insert the new message pointer before inserting it. The osqout pointer moves forward one cell in the message queue. If. The current cell that the Osqout pointer points to is the first cell in the queue [L6.24 (1)], where the forward is crossed out, and you need to specifically point the pointer to the end of the queue [L6.24 (2)]. Because. Osqend points to the next cell in the last cell in the message queue, so. The osqout must be adjusted to a valid range of points to the queue [L6.24 (3)].
The Osqpostfront () function implements a LIFO queue because the message taken by the Qsqpend () function was just inserted by the osqpend () function.
Program manifest L6.24 sends a message to Message Queuing (LIFO) int8u Osqpostfront (os_event *pevent, void *msg) {os_q *pq;
Os_enter_critical ();
if (pevent->oseventtype! = os_event_type_q) {os_exit_critical ();
return (Os_err_event_type);
} if (PEVENT->OSEVENTGRP) {Oseventtaskrdy (pevent, MSG, os_stat_q);
Os_exit_critical ();
Ossched ();
return (OS_NO_ERR);
} else {PQ = pevent->oseventptr;
if (pq->osqentries >= pq->osqsize) {os_exit_critical ();
return (Os_q_full); } else {if (pq->Osqout = = Pq->osqstart) {(1) pq->osqout = pq->osqend; (2)} pq->osqout--; (3) *pq->osqout = msg;
pq->osqentries++;
Os_exit_critical ();
} return (OS_NO_ERR); }
}