Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to control tasks in vxworks

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to control tasks in vxworks, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

After the task is created by taskSpawn () or activated by taskActivate (), it goes directly to the Ready queue. But in actual operation, the task is in other state most of the time, not in read state, otherwise the occupancy rate of CPU will be very high and the power consumption will go up, which must be something wrong with the design of the software architecture.

Some functions for controlling the status of tasks in VxWorks's taskLib library

TaskSuspend () puts the task on the Suspend queue, and taskResume () puts the task on the Ready queue, and these two API are usually used only when debugging. TaskSuspend (0) is to suspend the task itself, as we did when we looked at tRootTask in "Common system tasks for Task." But taskResume (0) is an invalid operation. Think about why?

The main purpose of taskRestart () is to restart the task where a serious error occurred. Since it has only one parameter, it means that the restart task uses the original properties, including ID, priority, options, entry address, and stack size. Where priorities and options may be changed dynamically, use the latest values.

TaskDelay (), which is commonly used in polling operations, places the current task in the Delay queue and returns to the tail of the same priority task in the Ready queue when the deadline expires. Its parameter unit is tick, that is, the frequency of the system clock. For example, delay for two seconds, it usually reads:

The purpose of sysClkRateGet () is to return the number of tick per second of the system clock. The system clock rate for each VxWorks version is 60 by default, but taskDelay (120), not necessarily Delay for two seconds. Because the clock rate can be modified through sysClkRateSet ()

It is important to note that the system clock interrupt is triggered when each tick arrives, so it is not recommended to set the system clock rate too fast, otherwise it will degrade system performance.

The argument of taskDelay () is an integer value, so you should pay attention to the problem of integer division when using it. For example, when using the default system clock rate, it is not possible to delay exactly 1pm to 7s.

SysClkRateGet () / 7 = 60 tick 7 = 8 tick, only 8 beat for 60 seconds.

When the parameter of taskDelay () is 0, the task does not enter the Delay state, but directly gives the CPU to the task of the same priority (if any) and ranks itself at the end of the task of the same priority, which is equivalent to the sched_yield () operation of the Linux system.

We mentioned in "the creation of Task tasks" that using taskPriorityGet () / taskPrioritySet (), you can query / adjust the priority of the task. There are also several API that can query the status information of a task

From the name, you can see that taskInfoGet () is the most powerful, and it can get most of the information in TCB.

The above is all the contents of the article "how to Control tasks in vxworks". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report