A message processing method, device and equipment

By combining multiple subtasks into one task in the microcontroller system and sharing a stack space, the problem of memory resource shortage is solved, and the dual effects of system stability and function expansion are achieved.

CN114064268BActive Publication Date: 2025-02-11HANGZHOU HAXING NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111246190.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2025-02-11
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

In the microcontroller system, memory resources are scarce, resulting in the inability to realize more functions and ensure system stability.

Method used

By combining multiple subtasks that meet preset conditions into one task, sharing a stack space, and freeing up the stack space of atomic tasks, more functions are achieved and system stability is improved in the case of shortage of memory resources.

Benefits of technology

This method not only saves memory resources, but also ensures the stability of the system in the case of shortage of memory resources, realizes more functions and saves costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064268B_ABST
    Figure CN114064268B_ABST
Patent Text Reader

Abstract

The embodiments of this specification provide a message processing method, device and equipment. The method includes: the single-chip microcomputer operating system merges multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the functions corresponding to each subtask; allocate new stack space for the merged task, and release the stack space of each subtask corresponding to the merged task; receive a target message; wherein the target message carries a task identifier for processing the target message; when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, run the merged task to obtain the message processing result. By using the embodiments of this specification, when memory resources are scarce, memory can be saved to realize more functions and improve the stability of the system, thereby improving resource utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of control technology, and in particular to a message processing method, device and equipment. Background Art

[0002] With the rapid development of science and technology in recent years, the application of single-chip microcomputers is becoming more and more in-depth. Since single-chip microcomputers are often used as a core component in single-chip microcomputer application systems, the single-chip microcomputer system memory will be easily used up, making the system unstable. Therefore, the requirements for single-chip microcomputer system memory in practical applications are getting higher and higher.

[0003] In the prior art, when a single-chip microcomputer uses a single-chip microcomputer operating system such as Freertos or RT-Thread, stack space is allocated to each task. This method cannot realize more functions and cannot guarantee the stability of the system when memory resources are scarce, thereby reducing resource utilization.

[0004] Therefore, the industry is in urgent need of a technical solution that can solve the above technical problems. Summary of the invention

[0005] The embodiments of the present specification provide a message processing method, apparatus and device, which can save memory to implement more functions and improve system stability when memory resources are scarce, thereby improving resource utilization.

[0006] The message processing method, device and equipment provided in this specification are implemented in the following manner.

[0007] A message processing method is applied to a single-chip microcomputer operating system, wherein the single-chip microcomputer operating system includes multiple subtasks, each subtask is pre-allocated with stack space, and the method includes: merging multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the function corresponding to each subtask; allocating new stack space to the merged task, and releasing the stack space of each subtask corresponding to the merged task; receiving a target message; wherein the target message carries a task identifier for processing the target message; and when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, running the merged task to obtain a message processing result.

[0008] A message processing device includes: a merging module, used to merge multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the function corresponding to each subtask; an allocation module, used to allocate new stack space for the merged task and release the stack space of each subtask corresponding to the merged task; a receiving module, used to receive a target message; wherein the target message carries a task identifier for processing the target message; and an obtaining module, used to run the merged task to obtain a message processing result when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task.

[0009] A message processing device includes at least one processor and a memory storing computer executable instructions, wherein when the processor executes the instructions, the steps of any method embodiment in the embodiments of this specification are implemented.

[0010] A computer-readable storage medium stores computer instructions, which, when executed, implement the steps of any method embodiment in the embodiments of this specification.

[0011] This specification provides a message processing method, device and equipment. In some embodiments, the single-chip microcomputer operating system can merge multiple subtasks that meet preset conditions to obtain a merged task, allocate new stack space for the merged task, and release the stack space of each subtask corresponding to the merged task, wherein the merged task can realize the function corresponding to each subtask. It is also possible to receive a target message carrying a task identifier for processing a target message, and when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, run the merged task to obtain a message processing result. Since there is no need to operate the code corresponding to the subtask when merging several subtasks into one task, the processing efficiency can be improved. Since the merged tasks share a stack and can realize the functions of the subtasks before merging, this can not only achieve the purpose of saving memory, but also ensure the stability of the system, realize more functions and save costs when system memory resources are scarce. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings described herein are used to provide a further understanding of this specification, constitute a part of this specification, and do not constitute a limitation of this specification. In the drawings:

[0013] Figure 1 It is a flowchart of an embodiment of a message processing method provided in this specification;

[0014] Figure 2 It is a schematic diagram of merging subtasks provided in this specification;

[0015] Figure 3It is a schematic diagram of the module structure of an embodiment of a message processing device provided in this specification;

[0016] Figure 4 This is a hardware structure block diagram of an embodiment of a message processing server provided in this specification. DETAILED DESCRIPTION

[0017] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments in this specification, not all of the embodiments. Based on one or more embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the embodiments of this specification.

[0018] The following is an example of a specific application scenario to illustrate the implementation plan of this specification. Specifically, Figure 1 It is a flowchart of an embodiment of a message processing method provided in this specification. Although this specification provides the method operation steps or device structure shown in the following embodiments or drawings, the method or device may include more or fewer operation steps or module units after partial combination based on routine or no creative labor.

[0019] An implementation scheme provided in this specification can be applied to single-chip microcomputer operating systems, such as Freertos, RT-Thread, etc. Among them, Freertos is a real-time operating system kernel. As a lightweight operating system, Freertos mainly includes the following functions: task management, time management, semaphore, message queue, memory management, recording function, software timer, coroutine, etc., which can basically meet the needs of smaller systems. RT-Thread is a technical platform integrating real-time operating system (RTOS) kernel, middleware components and developer community, with the characteristics of extremely small kernel, stable and reliable, simple and easy to use, highly scalable, and rich components. Of course, the implementation scheme provided in this specification can also be applied to devices including single-chip microcomputer operating systems, such as clients, servers, etc. The client may include terminal devices, such as smart phones, tablet computers, etc. The server may include a single computer device, or may include a server cluster consisting of multiple servers, or a server structure of a distributed system, etc. Among them, the single-chip microcomputer operating system may include multiple subtasks, each of which may be pre-allocated with stack space.

[0020] It should be noted that the following embodiment description does not limit the technical solutions in other application scenarios that can be extended based on this specification. Figure 1 As shown, in an embodiment of a message processing method provided in this specification, the method may include the following steps.

[0021] S0: merging multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the function corresponding to each subtask.

[0022] Among them, the single-chip microcomputer operating system can include multiple subtasks (also called tasks), and the single-chip microcomputer operating system can dynamically allocate stack space for each task in advance. The stack space can be used to open stack frames for functions and store local variables. The size of the data in the stack space can be determined at compile time, and the allocation and release of data are also completed by the compiler inserting instructions when entering and exiting the function. The data life cycle is the same as that of the function. Each subtask corresponds to task information. Among them, the task information may include a handler, an initialization function, a message processing function, etc.

[0023] In some embodiments, before merging the multiple subtasks that meet the preset condition, the steps may include: determining the priority of each subtask; and determining the subtasks that meet the preset condition based on the priority of each subtask.

[0024] In some implementation scenarios, the single-chip microcomputer operating system can set a priority for each subtask according to the function, execution frequency, impact, etc. of each task. Among them, the priority can be level 1, level 2, level 3, etc., with level 1 having the highest priority, level 2 being the second, and so on. Of course, the above is only an exemplary description, and the priority can also be expressed in other ways, which is not limited in this specification.

[0025] In some embodiments, the subtasks that meet the preset conditions may include: subtasks with the same priority; and / or subtasks with a priority difference of a preset number of levels. The preset number of levels may be set according to the actual scenario, for example, it may be 1, 3, etc., and this specification does not limit this. In some implementation scenarios, subtasks with a priority difference of a preset number of levels may include subtasks with a priority difference of 1 level based on actual performance, and may also include subtasks with the same (or similar) functions and a priority difference of within 2 levels (including 2 levels), etc.

[0026] For example, in some implementation scenarios, the single-chip microcomputer operating system includes subtask 1, subtask 2, subtask 3, subtask 4, and subtask 5, and the priorities of each subtask are 1, 3, 5, 1, and 2, respectively, and subtask 1, subtask 2, and subtask 5 have the same function. At this time, if the preset condition is the same priority, the subtasks that meet the preset condition are subtask 1 and subtask 4; if the preset condition is subtasks with the same function and a priority difference within 2 levels (including 2 levels), the subtasks that meet the preset condition are subtask 1, subtask 2, subtask 3, and subtask 5. It should be noted that when determining the subtask that meets the preset condition, the subtask with a high priority (such as subtask 1 or subtask 4) is used as a reference for judgment, that is, subtask 1 (or subtask 4) is used as a reference to judge whether other subtasks meet the preset condition with subtask 1. After judging subtask 1, it is judged in turn whether the subtasks of other priorities meet the preset condition with the remaining subtasks, until all subtasks are judged and the subtask that meets the preset condition is determined.

[0027] In some implementation scenarios, the subtasks determined to meet the preset conditions may include one or more groups, each group including at least two subtasks. It should be noted that the embodiments of this specification are illustrated by taking the example of the subtasks determined to meet the preset conditions including one group, and other implementation scenarios are similar and can be referenced to each other, so no further description is given.

[0028] In some embodiments, after the subtasks satisfying the preset conditions are determined, the subtasks satisfying the preset conditions may be combined into one task.

[0029] In some embodiments, merging multiple subtasks that meet preset conditions may include: creating a target task and a merge space; obtaining task information of each subtask that meets the preset conditions; recording the task information of each subtask in the merge space; associating the target task with the merge space to obtain a merged task. The target task can be understood as a task created in advance before merging. The merge space can be used to record the task information of subtasks that meet the preset conditions. The task information may include at least: a handler, an initialization function, a message processing function, etc.

[0030] In the embodiment of the present specification, the target task is associated with the merged space, so that the function of merging the previous multiple subtasks can be realized by merging the task later.

[0031] S2: Allocate new stack space for the merged task, and release the stack space of each subtask corresponding to the merged task.

[0032] In some embodiments, after the merged task is obtained, new stack space may be allocated for the merged task, and the stack space of each subtask corresponding to the merged task may be released.

[0033] In some implementation scenarios, when allocating new stack space for a merged task, the maximum space value can be selected from the pre-allocated stack space of each subtask corresponding to the merged task, and then the stack space corresponding to the maximum space value is allocated to the merged task, and the stack space of each subtask corresponding to the merged task is released. For example, if the merged task corresponds to 3 subtasks, and the pre-allocated stack space of the 3 subtasks is 500 bytes, 1000 bytes, and 2000 bytes respectively, then 2000 bytes of stack space can be allocated to the merged task, thereby saving 500+1000 bytes.

[0034] In some implementation scenarios, when allocating new stack space for the merged task, the new stack space can also be allocated for the merged task from the current remaining memory of the microcontroller operating system, and the stack space of each subtask corresponding to the merged task can be released.

[0035] In some implementation scenarios, when allocating new stack space for the merged task, the current remaining memory of the MCU operating system can be obtained first to determine whether the release of the current remaining memory can meet the running requirements of the merged task. If it is determined that the current remaining memory can meet the running requirements of the merged task, new stack space can be allocated for the merged task from the current remaining memory of the MCU operating system, and the stack space of each subtask corresponding to the merged task can be released; if it is determined that the current remaining content cannot meet the running requirements of the merged task, the maximum space value can be selected from the pre-allocated stack space of each subtask corresponding to the merged task, and then the stack space corresponding to the maximum space value can be allocated to the merged task, and the stack space of each subtask corresponding to the merged task can be released.

[0036] Of course, the above is only an exemplary explanation, and the method of allocating new stack space for merging tasks is not limited to the above example. Technical personnel in the relevant field may make other changes inspired by the technical essence of this application, but as long as the functions and effects achieved are the same or similar to those of this application, they should be covered within the scope of protection of this application.

[0037] like Figure 2 The figure shows a schematic diagram of merging subtasks provided in this specification. The single-chip operating system includes three subtasks, namely task1, task2, and task3, and the pre-allocated stack spaces are stack 1, stack 2, and stack 3. Task1 and task2 have the same priority. At this time, task1 and task2 can be merged to obtain a merged task (i.e., a new Task), and a new stack space (i.e., a new stack) is allocated for the new Task. At the same time, the stack space of task1 and task2 is released.

[0038] In the embodiments of this specification, by flexibly configuring several subtasks to be combined into one task to share a stack space, not only can memory be saved, but also when memory resources are scarce, the saved memory can be used to implement more functions and improve system stability.

[0039] S4: Receive a target message; wherein the target message carries a task identifier for processing the target message.

[0040] In some embodiments, after allocating new stack space for the merged task and releasing the stack space of each subtask corresponding to the merged task, the single-chip microcomputer operating system can receive the target message. The target message can carry a task identifier for processing the target message. The target message can be a message to be processed. The task identifier can be used to indicate which subtask processes the target message, or to indicate which subtask the target message is sent to. The task identifier can be composed of one or more of numbers, letters, characters, etc., which is not limited in this specification.

[0041] S6: When it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, the merged task is executed to obtain a message processing result.

[0042] In some embodiments, after receiving the target message, the single-chip microcomputer operating system can determine which subtask is to process the target message based on the task identifier carried in the target message.

[0043] In some embodiments, when it is determined based on the task identifier that the task processing the target message is the first subtask corresponding to the merged task, the merged task may be run to obtain the message processing result, wherein the first subtask may be any one of the multiple subtasks corresponding to the merged task.

[0044] In some embodiments, running the merged task may include: initializing the merged task. In some implementation scenarios, initializing the merged task may include: executing an initialization function of each subtask corresponding to the merged task.

[0045] In the embodiment of the present specification, since the task information corresponding to each subtask is recorded in the merged task, when the merged task is run, the merged task can be initialized by executing the initialization functions corresponding to each subtask corresponding to the merged task.

[0046] In some embodiments, when it is determined based on the task identifier that the task processing the target message is the first subtask corresponding to the merged task, running the merged task to obtain a message processing result may include: when it is determined based on the task identifier that the task processing the target message is the first subtask corresponding to the merged task, sending the target message to the merged task; obtaining a processor corresponding to the first subtask from the stack space corresponding to the merged task; using the processor corresponding to the first subtask to send the target message to the message processing function corresponding to the first subtask; and obtaining a message processing result based on the message processing function.

[0047] For example, in some implementation scenarios, when the microcontroller operating system determines, based on the task identifier carried in the received message, that the task executing the message is one of the multiple subtasks corresponding to the merged task, the microcontroller operating system can send the message to the merged task, then retrieve the handler of the subtask in the merged task, and then distribute the message to the message processing function of the subtask for processing based on the handler to obtain the message processing result.

[0048] It should be noted that in some implementation scenarios, when multiple subtasks are merged and the merged task is running, if the event processing of the original subtasks is within one time slice polling, the functions of the corresponding subtasks in the merged task are usually also within one time slice polling.

[0049] The embodiments of the present specification record the task information corresponding to each subtask in the code space and then associate it with the created target task, so that tasks can be merged and split flexibly and quickly without modifying or deleting the codes corresponding to the subtasks, thereby saving memory and improving processing efficiency.

[0050] The embodiments of this specification flexibly configure several subtasks to be combined into one task to share a stack, which can not only reduce the use of stack space and save memory, but also ensure the stability of the system when the memory resources of the microcontroller operating system are scarce, realize more functions and save costs.

[0051] From the above description, it can be seen that in the embodiment of the present application, the single-chip microcomputer operating system can merge multiple subtasks that meet the preset conditions to obtain a merged task, allocate new stack space for the merged task, and release the stack space of each subtask corresponding to the merged task, wherein the merged task can realize the function corresponding to each subtask. It is also possible to receive a target message carrying a task identifier for processing a target message, and in the case where the task for processing the target message is determined to be the first subtask corresponding to the merged task based on the task identifier, run the merged task to obtain the message processing result. Since when merging several subtasks into one task, there is no need to operate the code corresponding to the subtask, thereby improving processing efficiency. Since the merged tasks share a stack and can realize the functions of the subtasks before merging, this can not only achieve the purpose of saving memory, but also ensure the stability of the system, realize more functions, and save costs when system memory resources are scarce.

[0052] Of course, the above is only an exemplary description, and the embodiments of this specification are not limited to the above examples. Technical personnel in the relevant field may make other changes based on the technical essence of this application. However, as long as the functions and effects achieved are the same or similar to those of this application, they should be included in the scope of protection of this application.

[0053] In this specification, each embodiment of the above method is described in a progressive manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments. For relevant parts, refer to the partial description of the method embodiment.

[0054] Based on the above-mentioned message processing method, one or more embodiments of this specification also provide a message processing device. The device may include a system (including a distributed system), software (application), module, component, server, client, etc. using the method described in the embodiment of this specification and a device combined with necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided in the embodiment of this specification is as described in the following embodiments. Since the implementation scheme and method of the device to solve the problem are similar, the implementation of the specific device in the embodiment of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can implement a combination of software and / or hardware of predetermined functions. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0055] Specifically, Figure 3 is a schematic diagram of a module structure of an embodiment of a message processing device provided in this specification, such as Figure 3As shown, a message processing device provided in this specification may include: a merging module 210, an allocating module 212, a receiving module 214, and an obtaining module 216.

[0056] The merging module 210 may be used to merge multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task may realize the function corresponding to each subtask;

[0057] The allocation module 212 may be used to allocate new stack space for the merged task and release the stack space of each subtask corresponding to the merged task;

[0058] The receiving module 214 may be used to receive a target message; wherein the target message carries a task identifier for processing the target message;

[0059] The obtaining module 216 may be configured to execute the merged task and obtain a message processing result when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task.

[0060] The embodiments of this specification can save memory to implement more functions and improve system stability when memory resources are scarce, and can also flexibly configure task merging to reduce the use of stack space and achieve the purpose of saving memory.

[0061] It should be noted that the above-mentioned device may also include other implementation modes according to the description of the method embodiment. The specific implementation mode may refer to the description of the relevant method embodiment, which will not be described one by one here.

[0062] This specification also provides an embodiment of a message processing device, including a processor and a memory for storing processor executable instructions, and the processor can implement any of the above method embodiments when executing the instructions. For example, when the instructions are executed by the processor, the following steps are implemented: merging multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can implement the functions corresponding to each subtask; allocating new stack space for the merged task, and releasing the stack space of each subtask corresponding to the merged task; receiving a target message; wherein the target message carries a task identifier for processing the target message; when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, running the merged task to obtain a message processing result.

[0063] It should be noted that the above-mentioned device may also include other implementations according to the description of the method or device embodiment. The specific implementation methods can refer to the description of the relevant method embodiments, which will not be described one by one here.

[0064] The method embodiments provided in this specification can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Figure 4 1 is a hardware structure block diagram of an embodiment of a message processing server provided in this specification. The server may be a message processing device or a message processing apparatus in the above embodiment. Figure 4 As shown, the server 10 may include one or more (only one is shown in the figure) processors 100 (the processor 100 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 200 for storing data, and a transmission module 300 for communication functions. A person skilled in the art can understand that Figure 4 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 4 More or fewer components shown in the figure may also include other processing hardware, such as a database or multi-level cache, GPU, or other hardware with Figure 4 Different configurations are shown.

[0065] The memory 200 can be used to store software programs and modules of application software, such as program instructions / modules corresponding to the message processing method in the embodiment of this specification. The processor 100 executes various functional applications and data processing by running the software programs and modules stored in the memory 200. The memory 200 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 200 may further include a memory remotely arranged relative to the processor 100, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0066] The transmission module 300 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission module 300 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 300 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0067] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0068] The methods or devices described in the above embodiments provided in this specification can implement business logic through computer programs and record them on storage media, and the storage media can be read and executed by computers to achieve the effects of the solutions described in the embodiments of this specification. The storage medium may include a physical device for storing information, which is usually to digitize the information and then store it in a medium using electrical, magnetic or optical methods. The storage medium may include: devices that use electrical energy to store information, such as various types of memories, such as RAM, ROM, etc.; devices that use magnetic energy to store information, such as hard disks, floppy disks, magnetic tapes, magnetic core memories, bubble memories, and U disks; devices that use optical methods to store information, such as CDs or DVDs. Of course, there are other types of readable storage media, such as quantum memories, graphene memories, and so on.

[0069] The above-mentioned message processing method or device embodiments provided in this specification can be implemented by a processor in a computer executing corresponding program instructions, such as using the C++ language of the Windows operating system to implement it on a PC, on a Linux system, or other methods such as using Android or iOS system programming languages ​​to implement it on a smart terminal, as well as based on the processing logic of a quantum computer.

[0070] It should be noted that the devices, equipment, and systems described in the specification may also include other implementation methods according to the description of the relevant method embodiments. The specific implementation methods can refer to the description of the corresponding method embodiments, which will not be described one by one here.

[0071] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0072] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of some modules can be implemented in the same or more software and / or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units.

[0073] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices, equipment, and systems according to the embodiments of the present invention. It should be understood that it can be implemented by computer program instructions, and these computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the specified function. These computer program instructions can also be stored in a computer-readable memory that can guide the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, and the instruction device is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0074] Those skilled in the art will appreciate that one or more embodiments of the present specification may be provided as methods, systems or computer program products. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware.

[0075] The above is only an example of one or more embodiments of this specification, and is not intended to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application should be included in the scope of the claims.

Claims

1. A message processing method, characterized in that: Applied to a single-chip microcomputer operating system, the single-chip microcomputer operating system includes a plurality of subtasks, each subtask is pre-allocated with a stack space, and the method includes: Merging multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the functions corresponding to each subtask; Allocating new stack space for the merged task and releasing the stack space of each subtask corresponding to the merged task; Receive a target message; wherein the target message carries a task identifier for processing the target message; In a case where it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, running the merged task to obtain a message processing result; The merging of multiple subtasks that meet preset conditions includes: Create target tasks and merge spaces; Get the task information of each subtask that meets the preset conditions; Recording the task information of each subtask into the merged space; The target task is associated with the merged space to obtain a merged task.

2. The method according to claim 1, characterized in that Before merging the multiple subtasks that meet the preset conditions, the steps include: Determine the priority of each subtask; Based on the priority of each subtask, subtasks that meet preset conditions are determined.

3. The method according to claim 1, characterized in that: The subtasks that meet the preset conditions include: Subtasks with the same priority; and / or, Subtasks with priorities that differ by a preset number of levels.

4. The method according to claim 1, characterized in that: The task information at least includes: a processor, an initialization function, and a message processing function.

5. The method according to claim 4, characterized in that The running of the merging task includes: Initializing the merged task; wherein, initializing the merged task includes: executing an initialization function of each subtask corresponding to the merged task.

6. The method according to claim 1, characterized in that In the case where it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, running the merged task to obtain a message processing result includes: In a case where it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, sending the target message to the merged task; Acquire a processor corresponding to the first subtask from a stack space corresponding to the merged task; Using the processor corresponding to the first subtask to send the target message to the message processing function corresponding to the first subtask; Based on the message processing function, a message processing result is obtained.

7. A message processing device, characterized in that: include: A merging module, used to merge multiple subtasks that meet preset conditions to obtain a merged task; wherein the merged task can realize the function corresponding to each subtask; An allocation module, used to allocate new stack space for the merged task and release the stack space of each subtask corresponding to the merged task; A receiving module, used for receiving a target message; wherein the target message carries a task identifier for processing the target message; An obtaining module, configured to, when it is determined based on the task identifier that the task for processing the target message is the first subtask corresponding to the merged task, run the merged task and obtain a message processing result; The merging module is specifically used to: create a target task and a merged space; obtain task information of each subtask that meets preset conditions; record the task information of each subtask into the merged space; associate the target task with the merged space to obtain a merged task.

8. A message processing device, characterized in that: The invention comprises a processor and a memory for storing processor executable instructions, wherein the processor implements the steps of the method according to any one of claims 1 to 6 when executing the instructions.

9. A computer-readable storage medium, characterized in that: Computer instructions are stored thereon, and when the instructions are executed, the steps of the method described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Multi-job merging and optimizing system and method in Gaia system

    CN110908796A

  • Data processing method and device, electronic equipment and storage medium

    CN112860750A