In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the Hook of Task in vxworks. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Task can be registered with 6 kinds of Hook in VxWorks, which are used for Create, Delete, Stop, Continue, Switch and Swap respectively.
Create
Its parameter createHook is a function, and the prototype is as follows
The purpose of this taskCreateHookAdd () is that every time Task creates a new Task, it automatically calls the registered function createHook ().
TaskCreateHookDelete () is responsible for deleting the previously registered Hook
The number of Hook that taskCreateHookAdd () can register is 40 by default
Delete
Similar to Create, the function deleteHook () is called automatically every time Task deletes another Task.
Stop
Every time there is Task in Stop other Task, the function stopHook () is called automatically.
A maximum of 4 Hook can be registered
Continue
Every time there is Task in Continue other Task, the function contHook () is called automatically.
Switch
Every time a Task switch is performed, the function switchHook () is called. For example, if Task B preempts the executing Task A, switchHook () will be called. When Task A resumes execution, switchHook () is called again.
The maximum number of Hook that can be registered is 16
Swap
Similar to Switch, the corresponding Hook is called when Task is switched.
The difference is that Switch calls the corresponding Hook; for each Task switch, while after Swap registers Hook, it is only valid for tasks connected to taskSwapHookAttach (). And when taskSwapHookAttach () is attached, you can also specify whether the cut-in or cut-out is valid. For example, taskSwapHookAttach ((FUNCPTR) swapHook,TaskA,1,0) means that swapHook () will only be called when TaskA is executed by CPU, that is, cut-in is valid; while TaskA is preempted by other Task, swapHook () will not be triggered, that is, cut-out is invalid.
In addition, the Hook registered by Switch and Swap is executed in the context of Kernel, so not all system functions can be called in their Hook. Functions that can be called are as follows
Let's take a look at a complete example of Hook
Declare a few Hook functions first: the Hook of Create, Delete, Stop and Continue are all printed Task names; Switch and Stop Hook only record the number of switches because of the limited number of functions they can call
Then register these Hook separately. When registering Swap, we register only one direction in the example, such as a cut-in direction.
And start a test Task, which loops to print its own number of execution times, and then suspends itself.
Try this example in VxWorks
Execute testHook (), and you can see that createHook () prompts Shell to create T1. Then test () prints and executes it once.
Check the number of switches to see if they are in line with expectations. SwapOut is 0 because we didn't record it.
Look at the status of test.
Then let it run one more lap to see if the switching times are still correct. The swapOut remains the same, and the other counters become larger.
Try Stop and Continue, no problem
And finally, Delete.
Isn't that interesting?
Finally, I remembered that if you want to check Task Name, you can directly use taskName (). There is no need to visit ☹, a member of TCB.
Thank you for reading! This is the end of the article on "how to use the Hook of Task in vxworks". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.