The difference between logmsg and printf in VxWorks

Source: Internet
Author: User

printf ()-Write a formatted string to the standard output stream (ANSI).

Logmsg () does not actually perform the output directly to the logging streams, but instead queues the message to the Logg ing task, logmsg () can be called from interrupt service routines.

printf () is the output of information to a standard output device (stdin/stdout), which can block if the device is working at this time.

Logmsg () is a way of using Message Queuing, which sends an information address to a queue that is printed out by a dedicated task.

About the working mechanism of logmsg. LOGMSG uses Message Queuing to pass messages sent by the user to Logtask, which is then displayed by Logtask on the screen or on other output devices. The VxWorks default Logtask task priority is high, which leads directly to the task switching.
The switchover happens, assuming that the user task Usrtask priority is level 51 (usually lower than the network task level 50, generally after 100), and my memory of Logtask is a 1-level task, second only to the interrupt response.
When Usrtask calls Logmsg, Logtask unblocked, gets CPU resources, and usrtask queues up to the Ready task queue. Logtask the first task in the ready queue starts executing after releasing the CPU resources, Usrtask continues to wait in the ready queue, hehe.

===========================

Logmsg can be used in interrupts, as if calling this function simply outputs the relevant MSG to the buffer, and it has a waiting task that is ultimately responsible for the output so that it can be used in the interrupt. (printf cannot be used in interrupts!)

The logmsg () routine takes a char * rather than a const char * and requires a fixed number of arguments (6).
The arguments in the logmsg () routine are char* instead of const char* and require a fixed number of arguments (Logmsg can accept up to 6 parameters, and printf can accept a variable number of arguments)

Logmsg () checks to see whether or not it's running in interupt context. If It is, it won't block. However, if invoked from a task, it can cause the task to block.

Logmsg () checks whether it runs in the context of the interrupt. If so, it does not block (because of the priority of the logtask); however, if it is called by a task, it will block the corresponding task (until the MSG output is complete)

The difference between logmsg and printf in VxWorks

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.