Send a message to Message Queuing (LIFO), Osqpostfront ()

Source: Internet
Author: User
Tags message queue
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); }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.