Resource occupation query method, controller and storage medium

By obtaining the task identification and resource occupancy rate of real-time running tasks in the VxWorks operating system, directly obtaining the resource occupancy information of real-time processes, it solves the problem that it is difficult for VxWorks operating system to obtain real-time process resource occupancy information, and meets application scenarios such as real-time vehicle testing. performance evaluation requirements improve data accuracy and flexibility.

CN119311521APending Publication Date: 2025-01-14NIO TECH ANHUI CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411435836.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The VxWorks operating system is difficult to directly obtain resource usage information for each real-time process, and cannot meet the performance evaluation requirements of real-time vehicle tests in actual application scenarios.

Method used

By obtaining the task identification and resource occupancy rate of real-time running tasks, determining the target resource occupancy information of the real-time process, and obtaining query results based on preset requirements, using the interfaces and tools of the VxWorks operating system to directly obtain the CPU and memory resource occupancy rate of the real-time process. .

Benefits of technology

It realizes the direct acquisition of real-time process resource occupation information in the VxWorks operating system where the task is the resource scheduling unit, and does not require special system monitoring tools. It meets the performance testing needs of application scenarios such as real-time vehicle testing, improves data accuracy and flexibility, and saves The cost of computing resources and information acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311521A_ABST
    Figure CN119311521A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, particularly provides a resource occupancy query method, a controller and a storage medium, and aims to solve the problem that an existing VxWorks operating system cannot directly obtain resource occupancy information of a real-time process. In order to achieve the purpose, the method comprises the steps of obtaining a task identifier and a resource occupancy rate of a real-time running task in a VxWorks operating system, obtaining target resource occupancy information of a real-time process according to the task identifier and the resource occupancy rate, and obtaining a target resource occupancy query result of the real-time process according to the target resource occupancy information and a preset demand. According to the method, the target resource occupancy information of the real-time process is obtained through the resource occupancy rate of the real-time running task which can be directly obtained, the query range of the target resource occupancy information is selectively limited according to the preset demand, the resource occupancy query results of the real-time process in different demand scenes are more flexibly obtained, and the query efficiency of the real-time process is improved. And various performance test requirements of application scenes such as actual vehicle test and the like are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and specifically provides a resource occupancy query method, a controller and a storage medium. Background Art

[0002] In the prior art, in order to ensure that applications run normally, stably and efficiently in the VxWorks operating system, it is necessary to monitor the resource usage information of these applications, such as CPU usage and memory usage, and use the resource usage information as a key performance indicator to evaluate the performance of these applications. In particular, in actual application scenarios such as real-vehicle testing, obtaining resource usage information such as the CPU usage of each application, i.e., each real-time process, is critical for timely discovering program problems and completing application performance tuning.

[0003] However, since VxWorks is a real-time operating system that uses tasks as resource scheduling units, the system monitoring tools in the VxWorks operating system can only monitor the resource consumption of a single task. Each task has an independent task control block to store the context information of the task, which can be scheduled and run by the scheduler alone, and can run in the operating system space or in a real-time process. The real-time process is only a container for the task, and the task is still independent of the real-time process to which it belongs. Therefore, the resource consumption of the task obtained by the VxWorks operating system cannot intuitively represent the resource occupancy information of each real-time process. Therefore, the system monitoring tools in the existing VxWorks operating system cannot directly obtain the resource occupancy information of each real-time process, and cannot meet the performance evaluation requirements of application scenarios such as actual vehicle testing.

[0004] Accordingly, a new solution is needed in the art to solve the above problems. Summary of the invention

[0005] In order to overcome the above-mentioned defects, the present application is proposed to provide a solution or at least partially solve the problem that it is difficult for the VxWorks operating system to directly obtain the resource occupancy information of each real-time process.

[0006] In a first aspect, the present application provides a resource occupancy query method, which is applied to a VxWorks operating system, comprising:

[0007] Obtaining a task identifier and resource occupancy rate of a real-time running task, wherein the real-time running task is a task currently running in the VxWorks operating system;

[0008] According to the task identifier and the resource occupancy rate, obtaining target resource occupancy information of a real-time process, wherein the real-time process is a process running in the VxWorks operating system;

[0009] According to the target resource occupancy information and preset requirements, a query result of the target resource occupancy of the real-time process is obtained; the preset requirements are requirements for determining a query range of the target resource occupancy information.

[0010] In a technical solution of the resource occupancy query method, obtaining target resource occupancy information of the real-time process according to the task identifier and the resource occupancy rate includes:

[0011] Determine the real-time process to which the real-time running task belongs according to the task identifier, thereby determining the real-time running tasks belonging to the same real-time process;

[0012] The target resource occupancy information of the real-time process is determined according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process.

[0013] In a technical solution of the resource occupancy query method, the step of determining the real-time process to which the real-time running task belongs according to the task identifier includes:

[0014] Based on the task information interface in the VxWorks operating system, obtaining the process identifier of the real-time process to which the real-time running task belongs according to the task identifier;

[0015] Generate the task data according to the task identifier, the resource occupancy rate and the process identifier;

[0016] Generate a corresponding process data set according to the process identifier, the process data set is used to store relevant data of the real-time process, and the process identifier and the process data set have a one-to-one correspondence;

[0017] The task data belonging to the same real-time process is acquired according to the process identifier, and the task data is saved in the process data set corresponding to the process identifier.

[0018] In a technical solution of the above resource occupancy query method, the method further includes:

[0019] Based on the real-time process mapping relationship of the VxWorks operating system, obtaining the process name corresponding to the process identifier;

[0020] Based on the task information interface, obtaining the process status of the real-time process corresponding to the process identifier;

[0021] And the process name and the process status are saved in the process data set corresponding to the process identifier.

[0022] In a technical solution of the resource occupancy query method, determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes:

[0023] The CPU resource occupancy rate and / or memory occupancy rate of the real-time process is determined according to the resource occupancy rates of the real-time running tasks belonging to the same real-time process.

[0024] In a technical solution of the resource occupancy query method, the memory occupancy includes the allocated memory occupancy and the mapped memory occupancy of the real-time process;

[0025] Obtain the memory usage, including:

[0026] Based on the page manager interface in the VxWorks operating system, obtaining the page management identifier of the real-time process corresponding to the process identifier;

[0027] Based on the virtual page pool information interface in the VxWorks operating system, obtaining the virtual page pool information of the real-time process corresponding to the process identifier;

[0028] The allocated memory occupancy and the mapped memory occupancy of the real-time process are determined according to the paging management identifier and the virtual page pool information of the real-time process.

[0029] In a technical solution of the resource occupancy query method, determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes:

[0030] Based on the address space information interface in the VxWorks operating system, acquiring memory partition information of the VxWorks operating system, the memory partition information including a global memory pool identifier and a kernel virtual memory pool identifier;

[0031] Based on the built-in command line tool of the VxWorks operating system, the memory allocation information is obtained according to the global memory pool identifier and the kernel virtual memory pool identifier, and the memory allocation information includes the size, offset and status information of each address block in the global memory pool and the kernel virtual memory pool.

[0032] In a technical solution of the above resource occupancy query method, the preset requirements include a first requirement, a second requirement and a third requirement;

[0033] The query scope corresponding to the first requirement includes: querying the CPU resource occupancy rate and memory occupancy of the real-time process;

[0034] The query scope corresponding to the second requirement includes: querying the process name and process status of the real-time process;

[0035] The query scope corresponding to the third requirement includes: querying the memory allocation information of the VxWorks operating system when the real-time process is running.

[0036] In a technical solution of the resource occupancy query method, obtaining the target resource occupancy query result of the real-time process according to the target resource occupancy information and preset requirements includes:

[0037] According to the target resource occupancy information and one or more of the first requirement, the second requirement and the third requirement, a query result of the target resource occupancy of the real-time process is obtained.

[0038] In a technical solution of the resource occupancy query method, the step of obtaining the task identifier and resource occupancy rate of the real-time running task includes:

[0039] Based on the system monitoring tool in the VxWorks operating system, obtaining a system monitoring report;

[0040] The system monitoring report is parsed to obtain the task identifier and resource occupancy rate of the real-time running task.

[0041] In a technical solution of the above resource occupancy query method, the method further includes:

[0042] The target resource occupancy query result is displayed visually, and the target resource occupancy query result is saved in a log file.

[0043] In a second aspect, a controller is provided, which includes at least one processor and at least one memory, wherein the memory is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the resource occupancy query method described in any one of the technical solutions of the above-mentioned resource occupancy query method.

[0044] In a third aspect, a computer-readable storage medium is provided, which stores a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the resource occupancy query method described in any one of the technical solutions of the resource occupancy query method.

[0045] Solution 1. A resource occupancy query method, characterized in that the method is applied to a VxWorks operating system, and the method comprises:

[0046] Obtaining a task identifier and resource occupancy rate of a real-time running task, wherein the real-time running task is a task currently running in the VxWorks operating system;

[0047] According to the task identifier and the resource occupancy rate, obtaining target resource occupancy information of a real-time process, wherein the real-time process is a process running in the VxWorks operating system;

[0048] According to the target resource occupancy information and preset requirements, a query result of the target resource occupancy of the real-time process is obtained; the preset requirements are requirements for determining a query range of the target resource occupancy information.

[0049] Solution 2. The resource occupancy query method according to Solution 1 is characterized in that:

[0050] The step of obtaining target resource occupancy information of the real-time process according to the task identifier and the resource occupancy rate includes:

[0051] Determine the real-time process to which the real-time running task belongs according to the task identifier, thereby determining the real-time running tasks belonging to the same real-time process;

[0052] The target resource occupancy information of the real-time process is determined according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process.

[0053] Solution 3. The resource occupancy query method according to Solution 2 is characterized in that:

[0054] The step of determining the real-time process to which the real-time running task belongs according to the task identifier includes:

[0055] Based on the task information interface in the VxWorks operating system, obtaining the process identifier of the real-time process to which the real-time running task belongs according to the task identifier;

[0056] Generate task data according to the task identifier, the resource occupancy rate and the process identifier;

[0057] Generate a corresponding process data set according to the process identifier, the process data set is used to store relevant data of the real-time process, and the process identifier and the process data set have a one-to-one correspondence;

[0058] The task data belonging to the same real-time process is acquired according to the process identifier, and the task data is saved in the process data set corresponding to the process identifier.

[0059] Solution 4. The resource occupancy query method according to Solution 3, characterized in that the method further comprises:

[0060] Based on the real-time process mapping relationship of the VxWorks operating system, obtaining the process name corresponding to the process identifier;

[0061] Based on the task information interface, obtaining the process status of the real-time process corresponding to the process identifier;

[0062] And the process name and the process status are saved in the process data set corresponding to the process identifier.

[0063] Solution 5. The resource occupancy query method according to Solution 2 is characterized in that:

[0064] Determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes:

[0065] The CPU resource occupancy rate and / or memory occupancy rate of the real-time process is determined according to the resource occupancy rates of the real-time running tasks belonging to the same real-time process.

[0066] Solution 6. The resource occupancy query method according to Solution 5 is characterized in that:

[0067] The memory footprint includes the allocated memory footprint and the mapped memory footprint of the real-time process;

[0068] Obtain the memory usage, including:

[0069] Based on the page manager interface in the VxWorks operating system, obtaining the page management identifier of the real-time process corresponding to the process identifier;

[0070] Based on the virtual page pool information interface in the VxWorks operating system, obtaining the virtual page pool information of the real-time process corresponding to the process identifier;

[0071] The allocated memory occupancy and the mapped memory occupancy of the real-time process are determined according to the paging management identifier and the virtual page pool information of the real-time process.

[0072] Solution 7. The resource occupancy query method according to Solution 2 is characterized in that:

[0073] Determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes:

[0074] Based on the address space information interface in the VxWorks operating system, acquiring memory partition information of the VxWorks operating system, the memory partition information including a global memory pool identifier and a kernel virtual memory pool identifier;

[0075] Based on the built-in command line tool of the VxWorks operating system, the memory allocation information is obtained according to the global memory pool identifier and the kernel virtual memory pool identifier, and the memory allocation information includes the size, offset and status information of each address block in the global memory pool and the kernel virtual memory pool.

[0076] Solution 8. The resource occupancy query method according to Solution 1, characterized in that the preset demand includes a first demand, a second demand and a third demand;

[0077] The query scope corresponding to the first requirement includes: querying the CPU resource occupancy rate and memory occupancy of the real-time process;

[0078] The query scope corresponding to the second requirement includes: querying the process name and process status of the real-time process;

[0079] The query scope corresponding to the third requirement includes: querying the memory allocation information of the VxWorks operating system when the real-time process is running.

[0080] Solution 9. The resource occupancy query method according to Solution 8 is characterized in that:

[0081] The step of obtaining a query result of the target resource occupation of the real-time process according to the target resource occupation information and the preset requirement includes:

[0082] According to the target resource occupancy information and one or more of the first requirement, the second requirement and the third requirement, a query result of the target resource occupancy of the real-time process is obtained.

[0083] Solution 10. The resource occupancy query method according to any one of solutions 1 to 9, characterized in that:

[0084] The step of obtaining the task identifier and resource occupancy rate of the real-time running task includes:

[0085] Based on the system monitoring tool in the VxWorks operating system, obtaining a system monitoring report;

[0086] The system monitoring report is parsed to obtain the task identifier and resource occupancy rate of the real-time running task.

[0087] Solution 11. The resource occupancy query method according to any one of Solutions 1 to 9, characterized in that the method further comprises:

[0088] The target resource occupancy query result is displayed visually, and the target resource occupancy query result is saved in a log file.

[0089] Solution 12. A controller comprising at least one processor and at least one memory, wherein the memory is suitable for storing multiple program codes, and wherein the program codes are suitable for being loaded and run by the processor to execute the resource occupancy query method described in any one of Solutions 1 to 11.

[0090] Solution 13. A computer-readable storage medium storing a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the resource occupancy query method described in any one of Solutions 1 to 11.

[0091] The above one or more technical solutions of this application have at least one or more of the following Beneficial effects:

[0092] In the technical solution of implementing the present application, the present application obtains the task identification and resource occupancy rate of the real-time running task in the VxWorks operating system, obtains the target resource occupancy information of the real-time process according to the task identification and resource occupancy rate, and obtains the target resource occupancy query result of the real-time process according to the target resource occupancy information and the preset requirements for determining the query range of the target resource occupancy information. Through the above configuration method, the present application can directly obtain the resource occupancy information of the real-time process to which the real-time running task belongs during operation in the VxWorks operating system with the task as the resource scheduling unit, using the resource occupancy rate of the real-time running task that can be directly obtained, and can realize the target resource occupancy query of the real-time process without a dedicated system monitoring tool, which provides greater convenience for actual application scenarios such as real vehicle testing. In addition, the present application can also selectively limit the scope of the target resource occupancy query result according to the preset requirements, and can more flexibly obtain the resource occupancy information of the real-time process under different demand scenarios, meeting the various performance testing requirements of application scenarios such as actual real vehicle testing.

[0093] Furthermore, the original system monitoring tools in the VxWorks operating system can be used to make the data accuracy of the resource occupancy rate of the obtained task more reliable. When obtaining the target resource occupancy information of the real-time process, the application program interface in the existing VxWorks operating system can also be combined to obtain the required information, without setting up a dedicated monitoring tool for the real-time process, saving computing resources and information acquisition costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] The disclosure of the present application will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present application. In addition, similar numbers in the drawings are used to represent similar components, among which:

[0095] Figure 1This is a schematic flow chart of the main steps of a resource occupancy query method according to an embodiment of the present application;

[0096] Figure 2 It is a flowchart of the main steps of a resource occupancy query method for determining real-time running tasks belonging to the same real-time process according to an embodiment of the present application;

[0097] Figure 3 It is a flowchart of the main steps of a resource occupancy query method for determining memory allocation information of an operating system according to an embodiment of the present application;

[0098] Figure 4 It is a main block diagram of a resource occupancy query method integrated as a DKM component according to an embodiment of the present application. DETAILED DESCRIPTION

[0099] Some embodiments of the present application are described below with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the technical principles of the present application and are not intended to limit the protection scope of the present application.

[0100] In the description of the present application, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, memory, and may also include software parts, such as program code, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program code, such as a disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B" and may include only A, only B or A and B. The singular terms "one" and "the" may also include plural forms.

[0101] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of a resource occupancy query method according to an embodiment of the present application. Figure 1 As shown, the resource occupancy query method in the embodiment of the present application is mainly applied to the VxWorks operating system, and mainly includes the following steps S101-S103.

[0102] Step S101: Obtain the task identifier and resource occupancy rate of the real-time running task.

[0103] In this embodiment, the real-time running task is a task currently running in the VxWorks operating system, and the resource occupancy rate may be a CPU resource occupancy rate when the task is running.

[0104] In one implementation, step S101 may further include step S1011 and step S1012:

[0105] Step S1011: Based on the system monitoring tool in the VxWorks operating system, a system monitoring report is obtained.

[0106] Step S1012: parse the system monitoring report to obtain the task identifier and resource occupancy rate of the real-time running task.

[0107] In this embodiment, the system monitoring tool can be a spy tool provided by the spyLib function library in the VxWorks operating system. The spyLib function library provides a function interface for monitoring task attribute information such as task name, task identifier, priority, and CPU occupancy information of the task. Among them, the spy() function can also save such information to a specified file through task-level output redirection.

[0108] In one implementation, step S1011 may further include:

[0109] Initialize the spy tool in the spyLib library in the VxWorks operating system and start the system auxiliary clock of the spy tool;

[0110] For each system auxiliary clock cycle, the spy tool is used to perform an output printing (report) operation, and the information of the task runtime in the VxWorks operating system is saved in the system monitoring report and output.

[0111] Step S102: Obtain target resource occupancy information of the real-time process according to the task identifier and the resource occupancy rate.

[0112] In this embodiment, the real-time process is a process running in the VxWorks operating system. A real-time process (RTP) is a special type of process in the VxWorks operating system, a dynamic execution process of a program in the VxWorks operating system, and an independent unit for resource allocation and scheduling of the operating system, and can be used to execute real-time tasks in the VxWorks operating system.

[0113] Among them, in the early versions of the VxWorks system, the task is the most basic scheduling unit of the operating system, similar to the concept of threads in other operating systems. A real-time process can execute multiple real-time running tasks at the same time, so the resources occupied by the task are independent of the resources occupied by the process. It is necessary to obtain the resource occupation information of all real-time running tasks through statistics to obtain the resource occupation information of the real-time process.

[0114] In this embodiment, the target resource occupancy information of the real-time process may include the CPU resource occupancy rate and the memory occupancy rate of the real-time process. The task identifier and the resource occupancy rate are the task identifier and the resource occupancy rate of the task belonging to the real-time process.

[0115] In one implementation, step S102 may further include step S1021 and step S1022:

[0116] Step S1021: Determine the real-time process to which the task belongs according to the task identifier, thereby determining the tasks belonging to the same real-time process.

[0117] Step S1022: Determine the target resource occupancy information of the real-time process according to the resource occupancy rates of all tasks belonging to the same real-time process.

[0118] In one embodiment, see the attached Figure 2 , Figure 2 FIG. 1 is a flow chart of the main steps of a resource occupancy query method for determining real-time running tasks belonging to the same real-time process according to an embodiment of the present application. Figure 2 As shown, step S1021 may further include steps S01211 to S10214:

[0119] Step S10211: Based on the task information interface in the VxWorks operating system, the process identifier of the real-time process to which the real-time running task belongs is obtained according to the task identifier.

[0120] Step S10212: Generate task data according to the task identifier, resource occupancy rate and process identifier.

[0121] Step S10213: Generate a corresponding process data set according to the process identifier.

[0122] Step S10214: Acquire task data belonging to the same real-time process according to the process identifier, and save the task data into the process data set corresponding to the process identifier.

[0123] In this implementation, the process data set is used to store relevant data of the real-time process, and the process identifier and the process data set correspond one to one.

[0124] In this embodiment, the process data set may store the process identifier of the real-time process and the task data of the tasks belonging to the real-time process, and may also include other information related to the real-time process, such as the process status and process name of the real-time process, which does not affect the normal implementation of the embodiment of the present application.

[0125] In one implementation, the process name and process status of the real-time process may be further obtained in the following manner, including steps S201 to S203:

[0126] Step S201: Based on the real-time process mapping relationship of the VxWorks operating system, obtain the process name corresponding to the process identifier.

[0127] Step S202: Based on the task information interface, the process status of the real-time process corresponding to the process identifier is obtained.

[0128] Step S203: Save the process name and process status into the process data set corresponding to the process identifier.

[0129] In this implementation, the real-time process mapping relationship may be a list storing the correspondence between process identifiers and process names, and the list may be generated according to the original wind_rtp data structure in the VxWorks operating system.

[0130] In one embodiment, a process data set may be a data container storing data of different data types, and the process data set may be generated according to a preset data structure, such as a data structure that may include an integer type process identifier, a pointer type task data, a string type process name, a Boolean type process status, and the like.

[0131] In this implementation, the task information interface may be a preset rtpStatusStrGet program interface.

[0132] In one implementation, step S1022 may further include:

[0133] The CPU resource occupancy rate and / or memory occupancy rate of the real-time process is determined according to the resource occupancy rates of the real-time running tasks belonging to the same real-time process.

[0134] In this embodiment, the memory usage may include the allocated memory usage and mapped memory usage of the real-time process. The allocated memory usage is the size of the physical memory allocated by the operating system to the real-time process, and the mapped memory usage is the size of the virtual address space of the real-time process mapped by the operating system to the contents of the file or device.

[0135] In one implementation, obtaining the CPU resource occupancy rate of the real-time process may further include:

[0136] The CPU resource usage of the real-time running tasks belonging to the same real-time process is accumulated to determine the CPU resource usage of the real-time process.

[0137] In one implementation, obtaining the memory usage of the real-time process may further include:

[0138] Based on the page manager interface in the VxWorks operating system, obtain the page management identifier of the real-time process corresponding to the process identifier;

[0139] Based on the virtual page pool information interface in the VxWorks operating system, obtain the virtual page pool information of the real-time process corresponding to the process identifier;

[0140] According to the paging management identifier and virtual page pool information of the real-time process, the allocated memory occupancy and the mapped memory occupancy of the real-time process are determined.

[0141] In this embodiment, the paging management identifier is used to determine the allocation and usage status of the physical memory space of the real-time process, and the corresponding paging manager interface can be the RTP_PAGE_MGR_GET interface. The virtual page pool information is used to determine the actual corresponding position of the virtual space of the real-time process in the physical memory, and the corresponding virtual page pool information interface can be the pgPoolInfoGet interface.

[0142] In one embodiment, see the attached Figure 3 , Figure 3 FIG. 1 is a flow chart of the main steps of a resource occupancy query method for determining memory allocation information of an operating system according to an embodiment of the present application. Figure 3 As shown, step S102 may further include step S301 and step S302:

[0143] Step S301: Based on the address space information interface in the VxWorks operating system, the memory partition information of the VxWorks operating system is obtained.

[0144] Step S302: Based on the built-in command line tool of the VxWorks operating system, memory allocation information is obtained according to the global memory pool identifier and the kernel virtual memory pool identifier.

[0145] In this embodiment, the memory partition information includes a global memory pool identifier and a kernel virtual memory pool identifier. The memory allocation information includes the size, offset and status information of each address block in the global memory pool and the kernel virtual memory pool.

[0146] In this implementation, the address space information interface may include one or more interfaces among an adrSpaceInfoGet interface, an adrSpaceRegionInfoShow interface, and a pgPoolBlockListShow interface.

[0147] In this embodiment, the built-in command line tool is used to view the usage of the virtual memory of the real-time process in the VxWorks operating system. For example, the vmStat command can be used to display the virtual memory statistics of the entire VxWorks operating system, including the total allocated memory and the current memory usage; the memShow command can be used to display the detailed information of the memory partitions of the VxWorks operating system, including the starting address, size and usage of each partition, etc.

[0148] Step S103: According to the target resource occupancy information and preset requirements, the target resource occupancy query result of the real-time process is obtained.

[0149] In this embodiment, the preset requirement is a requirement for determining a query scope of target resource occupancy information.

[0150] In one implementation, the preset requirements may include a first requirement, a second requirement, and a third requirement.

[0151] The query scope of the target resource occupancy information corresponding to the first requirement includes: querying the CPU resource occupancy rate and memory occupancy of the real-time process. The query scope corresponding to the second requirement includes: querying the process name and process status of the real-time process. The query scope corresponding to the third requirement includes: querying the memory allocation information of the VxWorks operating system when the real-time process is running.

[0152] In one implementation, step S103 may further include:

[0153] According to the target resource occupation information and one or more requirements among the first requirement, the second requirement and the third requirement, a query result of the target resource occupation of the real-time process is obtained.

[0154] In one implementation manner, this embodiment may further include:

[0155] The query results of the target resource occupancy are displayed visually and saved in a log file.

[0156] In one implementation, the above-mentioned specific steps of obtaining the target resource occupancy information can also be integrated into an application downloadable kernel module (DKM) component, which can be directly linked to the function code of the kernel space in the VxWorks operating system, without repeating the compilation, linking and restarting of the operating system, so as to obtain the target resource occupancy information. When obtaining the target resource occupancy query result of the real-time process, it is only necessary to dynamically load the DKM component and input the preset requirements to obtain the target resource occupancy query result, thereby saving the query cost and query time of the resource occupancy information of the real-time process.

[0157] In one embodiment, see the attached Figure 4 , Figure 4 1 is a schematic diagram of a resource occupancy query method integrated as a DKM component according to an embodiment of the present application. Figure 4 As shown, the DKM component includes the default mode, CPU usage detailed mode (equivalent to Figure 4 "cpuUsage verbose mode" in ) and memory verbose mode (equivalent to Figure 4 There are three demand modes: "memoryverbose mode" in .

[0158] In this embodiment, the demand mode is used to determine the query scope of the resource occupancy information of the real-time process. The "default mode" in this embodiment can be equivalent to the "first demand" in this embodiment, the "CPU occupancy rate detailed mode" can be equivalent to the "second demand" in this embodiment, and the "memory detailed mode" can be equivalent to the "third demand" in this embodiment.

[0159] The DKM component in the default mode is used to obtain the CPU resource usage information and memory usage information of the real-time process in the VxWorks operating system.

[0160] The DKM component in the CPU occupancy detailed mode is used to obtain detailed information of all tasks in the real-time process based on the default mode, that is, to obtain the CPU resource occupancy information, memory occupancy information and detailed information of all tasks contained in the real-time process.

[0161] The DKM component in the detailed memory mode is used to obtain the key address space of the VxWorks operating system, the size and status of each address block based on the default mode, that is, to obtain the CPU resource usage information and memory usage information of the real-time process, as well as the size, offset and status information of each address block of the global memory pool (Global RAM Pool) and kernel virtual memory pool (KernelVirtual Memory Pool) of the VxWorks operating system.

[0162] In this implementation, using the DKM component to obtain the resource occupancy information of the real-time process may further include steps S401 to S403:

[0163] Step S401: dynamically load a DKM component named vtop.

[0164] Step S402: Start the vtop component and enter the demand mode.

[0165] Step S403: Periodically print the resource occupancy query result of the real-time process to the terminal connected to the VxWorks operating system according to the obtained demand pattern.

[0166] Among them, Figure 4 As shown, when the demand mode is the default mode, the vtop component can periodically print the information of RTP (equivalent to the "real-time process" in this embodiment) and key address space, which can specifically include the name, status, CPU occupancy rate and memory occupancy rate of each RTP.

[0167] When the demand mode is cpuUsage Verbose mode, the vtop component can periodically print the information of RTP, all tasks it contains (equivalent to "tasks" in this embodiment), and key address spaces, which can specifically include: the name, status, CPU occupancy, memory occupancy of RTP, and the name and status of the tasks it contains.

[0168] When the demand mode is memory verbose mode, the vtop component can periodically print information about the RTP, key address space, and the size and status of each address block. Specifically, it can include: RTP name, status, CPU usage, memory usage, and the size, offset, and status of each address block in the memory pool of the VxWorks operating system.

[0169] In one implementation, the user can input the required demand mode to the VxWorks operating system by adding different parameters in the command line. For example, using "vtop" as a command to start the DKM component and directly enter the default mode, using the parameter "-v" as a command to enter the cpuUSage Verbose mode, using "-m" as a command to enter the memory verbose mode, and using the parameter "-vm" or the parameter "-mv" as a command to enter the cpuUSage Verbose mode and the memory verbose mode at the same time, all do not affect the normal implementation of the embodiment of the present application.

[0170] In this embodiment, if Figure 4As shown, at the logical level, the DKM component can be further used in steps S501 to S510:

[0171] Step S501: Initialize the spy library of VxWorks.

[0172] The spy library may be a spy tool provided by the spyLib library of VxWorks, which utilizes an auxiliary timer to generate an interrupt and maintains a counter for each task running in the VxWorks operating system. After the auxiliary timer interrupts a task, the interrupted task is recorded and the counter of the task is incremented by one. After a period of time, the counter of each task can reflect the CPU utilization of the task.

[0173] Step S502: Start the spy's system auxiliary clock.

[0174] Step S503: Obtain the content of the spy report.

[0175] In this implementation, for each clock cycle of the system auxiliary clock, the spy tool may perform a report operation to obtain a spy report.

[0176] Step S504: parse the contents of the spy report to obtain Task ID and cpuUsage.

[0177] Step S505: For each Task, obtain the task description (equivalent to Figure 4 in TASK_DESC).

[0178] The task description includes the RTP ID to which the task belongs and the task status (Task STATUS).

[0179] In one implementation, the task description corresponding to the Task ID may be obtained through the taskInfoGet interface.

[0180] Step S506: Read the RTP ID to which the TASK belongs from the task description, and then obtain the RTP Name.

[0181] In this implementation manner, the method of obtaining the RTP Name according to the RTP ID is similar to the method of obtaining the process name corresponding to the process identifier in the above-mentioned embodiment, and is not described in detail here.

[0182] Step S507: Accumulate the cpuUSage of the RTP, and store the Task ID and task description into RtpData.

[0183] In this embodiment, RtpData is a pre-set data set storing information of the real-time process.

[0184] Step S508: Obtain the process status of RTP and store it in RtpData.

[0185] In this implementation manner, the manner of obtaining the process status of RTP is similar to the manner of obtaining the process status corresponding to the process identifier in the above-mentioned embodiment, and will not be described in detail here.

[0186] Step S509: Acquire the virtual memory pool information of RTP, calculate the allocated memory and mapped memory, and store them in RtpData.

[0187] In this embodiment, the virtual memory pool information of RTP may include the page manager ID and virtual page pool information of RTP. The method of obtaining the occupied amount of allocated memory and mapped memory is similar to the method of obtaining the memory occupied amount in this embodiment, which is not repeated here.

[0188] Step S510: Obtain usage and status information of the system's overall physical memory and virtual memory.

[0189] In this embodiment, the usage and status information of the physical memory and the virtual memory includes the size, offset and status information of each address block in the global memory pool and the kernel virtual memory pool in the operating system.

[0190] Based on the above steps S101 to S103, the present application can directly obtain the resource occupancy information of the real-time process to which the task belongs during operation by using the resource occupancy rate of the task that can be directly obtained in the VxWorks operating system that uses the task as the resource scheduling unit. Compared with the prior art, there is no need for dedicated system monitoring tools, which provides greater convenience for actual application scenarios such as real vehicle testing. In addition, the present application selectively limits the scope of the target resource occupancy information according to preset requirements, and can more flexibly obtain the resource occupancy information of the real-time process under different demand scenarios, meeting the various performance testing requirements of application scenarios such as actual real vehicle testing.

[0191] Furthermore, the original system monitoring tools in the VxWorks operating system can be used to make the data accuracy of the resource occupancy rate of the obtained task more reliable. When obtaining the target resource occupancy information of the real-time process, the application program interface in the existing VxWorks operating system can also be combined to obtain the required information, without setting up a dedicated monitoring tool for the real-time process, saving computing resources and information acquisition costs.

[0192] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effect of the present application, different steps do not have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present application.

[0193] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above-mentioned embodiment of the present application can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0194] Furthermore, the present application also provides a controller. In a controller embodiment according to the present application, the controller includes a processor and a memory, the memory can be configured to store a program for executing the resource occupancy query method of the above method embodiment, and the processor can be configured to execute the program in the memory, which includes but is not limited to the program for executing the resource occupancy query method of the above method embodiment. For ease of explanation, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The controller can be a controller device formed by various electronic devices.

[0195] In the embodiment of the present application, the controller may be a controller device formed by various electronic devices. In some possible implementations, the controller may include multiple memories and multiple processors. The program for executing the resource occupancy query method of the above method embodiment may be divided into multiple subprograms, each of which may be loaded and run by a processor to execute different steps of the resource occupancy query method of the above method embodiment. Specifically, each subprogram may be stored in different memories, and each processor may be configured to execute programs in one or more memories to jointly implement the resource occupancy query method of the above method embodiment, that is, each processor executes different steps of the resource occupancy query method of the above method embodiment, to jointly implement the resource occupancy query method of the above method embodiment.

[0196] The above-mentioned multiple processors may be processors deployed on the same device. For example, the above-mentioned controller may be a high-performance device composed of multiple processors, and the above-mentioned multiple processors may be processors configured on the high-performance device. In addition, the above-mentioned multiple processors may also be processors deployed on different devices. For example, the above-mentioned controller may be a server cluster, and the above-mentioned multiple processors may be processors on different servers in the server cluster.

[0197] Furthermore, the present application also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present application, the computer-readable storage medium can be configured to store a program for executing the resource occupancy query method of the above-mentioned method embodiment, and the program can be loaded and run by the processor to implement the above-mentioned resource occupancy query method. For ease of explanation, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The computer-readable storage medium can be a memory device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present application is a non-temporary computer-readable storage medium.

[0198] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present application, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0199] It is understood by those skilled in the art that each module in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present application, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present application.

[0200] So far, the technical solutions of the present application have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present application is obviously not limited to these specific embodiments. Without departing from the principles of the present application, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present application.

Claims

1. A resource occupancy query method, characterized in that: The method is applied to a VxWorks operating system, and the method comprises: Obtaining a task identifier and resource occupancy rate of a real-time running task, wherein the real-time running task is a task currently running in the VxWorks operating system; According to the task identifier and the resource occupancy rate, obtaining target resource occupancy information of a real-time process, wherein the real-time process is a process running in the VxWorks operating system; According to the target resource occupancy information and preset requirements, a query result of the target resource occupancy of the real-time process is obtained; the preset requirements are requirements for determining a query range of the target resource occupancy information.

2. The resource occupancy query method according to claim 1, characterized in that: The step of obtaining target resource occupancy information of the real-time process according to the task identifier and the resource occupancy rate includes: Determine the real-time process to which the real-time running task belongs according to the task identifier, thereby determining the real-time running tasks belonging to the same real-time process; The target resource occupancy information of the real-time process is determined according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process.

3. The resource occupancy query method according to claim 2, characterized in that: The step of determining the real-time process to which the real-time running task belongs according to the task identifier includes: Based on the task information interface in the VxWorks operating system, obtaining the process identifier of the real-time process to which the real-time running task belongs according to the task identifier; Generate task data according to the task identifier, the resource occupancy rate and the process identifier; Generate a corresponding process data set according to the process identifier, the process data set is used to store relevant data of the real-time process, and the process identifier and the process data set have a one-to-one correspondence; The task data belonging to the same real-time process is acquired according to the process identifier, and the task data is saved in the process data set corresponding to the process identifier.

4. The resource occupancy query method according to claim 3, characterized in that: The method further comprises: Based on the real-time process mapping relationship of the VxWorks operating system, obtaining the process name corresponding to the process identifier; Based on the task information interface, obtaining the process status of the real-time process corresponding to the process identifier; And the process name and the process status are saved in the process data set corresponding to the process identifier.

5. The resource occupancy query method according to claim 2, characterized in that: Determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes: The CPU resource occupancy rate and / or memory occupancy rate of the real-time process is determined according to the resource occupancy rates of the real-time running tasks belonging to the same real-time process.

6. The resource occupancy query method according to claim 5, characterized in that: The memory footprint includes the allocated memory footprint and the mapped memory footprint of the real-time process; Obtain the memory usage, including: Based on the page manager interface in the VxWorks operating system, obtaining the page management identifier of the real-time process corresponding to the process identifier; Based on the virtual page pool information interface in the VxWorks operating system, obtaining the virtual page pool information of the real-time process corresponding to the process identifier; The allocated memory occupancy and the mapped memory occupancy of the real-time process are determined according to the paging management identifier and the virtual page pool information of the real-time process.

7. The resource occupancy query method according to claim 2, characterized in that: Determining the target resource occupancy information of the real-time process according to the resource occupancy rates of all the real-time running tasks belonging to the same real-time process includes: Based on the address space information interface in the VxWorks operating system, acquiring memory partition information of the VxWorks operating system, the memory partition information including a global memory pool identifier and a kernel virtual memory pool identifier; Based on the built-in command line tool of the VxWorks operating system, the memory allocation information is obtained according to the global memory pool identifier and the kernel virtual memory pool identifier, and the memory allocation information includes the size, offset and status information of each address block in the global memory pool and the kernel virtual memory pool.

8. The resource occupancy query method according to claim 1, characterized in that: The preset requirements include a first requirement, a second requirement and a third requirement; The query scope corresponding to the first requirement includes: querying the CPU resource occupancy rate and memory occupancy of the real-time process; The query scope corresponding to the second requirement includes: querying the process name and process status of the real-time process; The query scope corresponding to the third requirement includes: querying the memory allocation information of the VxWorks operating system when the real-time process is running.

9. The resource occupancy query method according to claim 8, characterized in that: The step of obtaining a query result of the target resource occupation of the real-time process according to the target resource occupation information and the preset requirement includes: According to the target resource occupancy information and one or more of the first requirement, the second requirement and the third requirement, a query result of the target resource occupancy of the real-time process is obtained.

10. The resource occupancy query method according to any one of claims 1 to 9, characterized in that: The step of obtaining the task identifier and resource occupancy rate of the real-time running task includes: Based on the system monitoring tool in the VxWorks operating system, obtaining a system monitoring report; The system monitoring report is parsed to obtain the task identifier and resource occupancy rate of the real-time running task.

Citation Information

Cited By

  • Real-time monitoring system and method based on server state

    CN121301130A