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 delete tasks in VxWorks system

2025-01-30 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 delete tasks in the VxWorks system, I believe 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!

The task-related API is provided by the system library taskLib.

Normally, after the task executes its last statement, it exits voluntarily. No extra operation is required.

However, tasks can also be deleted dynamically. The related API are

TaskExit () terminates the current task and removes the task's Stack and TCB. In fact, taskExit () is called automatically when the last statement is executed. That is, in general, there is no need to explicitly call taskExit () in your code.

Exit () has the same effect as taskExit () in Kernel mode. In user mode, however, exit () is more powerful, deleting the entire current process and freeing up the process's memory space. In fact, RTP's main () function automatically calls exit () when it finishes executing the last statement. Again, exit () is rarely explicitly called in the code.

When the parameter of taskDelete () is 0, the task itself is deleted, which is equivalent to taskExit (0). In other words, taskDelete () is different in that it can delete other tasks.

As you can see, whether the task exits voluntarily or is deleted, it only deletes Stack and TCB (because the task is made up of them), and there is a big risk that other system resources that the task takes up while it is working are not released. There are three main types of system resources: dynamically requested memory, IO resources, and mutex semaphores. So when a task exits or deletes, be sure to recycle its resources (better in RTP, dynamic memory and private semaphores are automatically reclaimed as RTP exits).

In addition, other tasks will not be notified if the task is exited or deleted. And if the task is deleted by other tasks, it does not know the exact location of the deletion. This does not guarantee the recycling of relational resources and may even destroy the data being accessed.

Typically, however, these delete functions are called only during the development and debugging phase of the project or in the exception handling code of the software.

In normal code flow, to prevent tasks from being accidentally deleted during execution, you can use taskSafe () and taskUnsafe () to protect the task. For example, if the task A that is accessing the shared resource x is suddenly deleted, the data consistency of x cannot be guaranteed. After A calls taskSafe (), when other tasks try to delete A, it is blocked until A calls taskUnsafe () to unprotect it. This protection also supports nested use, that is, you can call taskSafe () multiple times before calling taskUnsafe (), but you need to call taskUnsafe () the same number of times later.

As you can see, the files fd, critical region, and semaphores are all protected. But there is a risk that dynamic memory buf will not be released.

The above is all the contents of the article "how to delete tasks in the VxWorks system". 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

  • How to turn on SpringBoot hot deployment in IDEA

    This article shows you how to turn on SpringBoot hot deployment in IDEA. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article. New dependency on pom.xml:

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

    12
    Report