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

What does Task mean in vxworks

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

Share

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

This article mainly shows you "what is the meaning of Task in vxworks", the content is simple and clear, hoping to help you solve your doubts, let the editor lead you to study and learn "what is the meaning of Task in vxworks" this article.

What is Task?

The Task of VxWorks, that is, task, is the most basic execution unit in the system, similar to the Thread (thread) of other operating systems. Modern RTOS basically supports upper-level applications by providing a multitasking environment. The upper-level applications use different tasks to simulate a variety of separate events in the real world. Each task is an execution thread, using its own system resources.

What if multitasking is not used? That is, how does a single-task system work? Let's take a look at this case: suppose you need to implement a program that controls multiple robotic arms.

In a single-task environment, the usual code implementation is an infinite loop in which the status of each section is polled. The pseudo code is as follows:

The code structure is relatively simple and easy to understand, which is its advantage. In addition, because there is only one task, there is no need to switch tasks, so CPU can focus on that task.

However, the disadvantages of single task are also obvious. From a code point of view, each section is equal and has no concept of priorities, while in the real world, the importance of each section may be different. In other words, this code structure does not have the ability to preempt, and each section can not be executed until it is polled. Moreover, the execution frequency of each section is not easy to control, many conditional statements often have false value judgment, this kind of code is a waste of CPU.

If you are in a multitasking environment, the code is roughly as follows:

You need to create a task for each section, and each task waits for a notification before it can be executed, which means that each task is always switching between Waiting and Ready. Waiting indicates that it is waiting for notification; Ready says it waits for notification and is ready to execute, at which point the operating system can decide whether to assign CPU to it.

As you can see, this implementation has higher requirements for the operating system. The operating system is required to provide a notification mechanism to make different tasks wait for different notifications. In addition, if multiple tasks are waiting for notification, the operating system has to provide a queuing mechanism to arrange which tasks can be executed using CPU.

There are many advantages to this multitasking:

1 any frequency, the frequency of each task depends on the frequency at which it is notified, and has little to do with other tasks

2 you can queue up and assign different priorities to each task, so that the high-priority tasks can preempt the low-priority tasks that are being executed

(3) it is easy to expand, the coupling between different task codes is relatively small, and when adding new tasks, the impact on existing tasks is relatively small.

As the saying goes, spring orchid and autumn chrysanthemum are good at winning the game. And our real world, itself is a parallel world, many events are happening at the same time. In the software world that simulates the real world, a large number of scenarios are also more suitable for multitasking, such as the following figure:

VxWorks also adopts this kind of multitasking method to ensure its real-time performance. Use multi-task to decompose complex problems, provide a variety of multi-task communication mechanisms to ensure the cooperation between tasks, and provide efficient scheduling strategies to ensure the timely response of important tasks. These tasks can independently wait for system resources (including CPU, Imax O devices, memory space, etc.), or use resources to run concurrently macroscopically. Of course, at the micro level, the number of tasks running concurrently depends on the number of kernels in CPU. However, this does not affect our understanding of the task. With regard to multicore content, we will have a special chapter on SMP in the future. For now, we assume that CPU is single-core.

The task of VxWorks consists of two parts: Stack and TCB.

The Stack (stack) is used to store the dynamic variables and function call relationships of the task.

The full name of TCB is task control block (Task Control Block), which is represented by a large structure in the code, windTcb, whose complete definition can be seen in target/h/taskLib.h. The information recorded in TCB is the Context (context) of the task:

PC pointer to the task

CPU register

Register of the coprocessor (optional)

Distribution of standard IO

Delay counter

Time slice counter

Kernel control structure

Semaphore callback function

Private environment variables for the task

Errno statu

Debugging and performance monitoring information

Virtual memory context (when RTP is supported)

And Stack information, so it is also possible to think of Stack as part of Context.

VxWorks's scheduling strategy for task scheduling is to stop the task being executed using CPU, and then assign CPU to another task to execute. This process is called context switching.

As you can see, context switching is a read and write operation to two task Context. In order to ensure real-time performance, the switching process must be accurate and fast.

The above is all the content of this article "what is the meaning of Task 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