CN110147247B - Method for realizing management software multitask based on C language - Google Patents
Method for realizing management software multitask based on C language Download PDFInfo
- Publication number
- CN110147247B CN110147247B CN201910445168.6A CN201910445168A CN110147247B CN 110147247 B CN110147247 B CN 110147247B CN 201910445168 A CN201910445168 A CN 201910445168A CN 110147247 B CN110147247 B CN 110147247B
- Authority
- CN
- China
- Prior art keywords
- task
- language
- processing
- function
- tcb
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/10—Requirements analysis; Specification techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method for realizing management software multitask based on C language, which comprises the following steps: (a) Determining task ID, task type, initialization entry function and exit function according to requirements, and creating a collection (TCB) task of a single task; (b) Registering a command set of task IDs into the TCB to adapt different task processing flows according to different ID commands; (c) Registering different processing functions connected with the server according to different ID commands; (d) Adding the task of the TCB which finishes the registration of the processing function to a task management linked list, and setting the running state of the task ID; (e) Finding a processing function corresponding to the task ID in the TCB task management linked list through the task ID, setting an operation marking bit, and starting operation; and (f) repeating the steps (a) to (e) to create the next task. The method of the invention can be compatible with the previous codes to carry out rapid iterative development, thereby improving the debugging efficiency.
Description
Technical Field
The invention relates to an intelligent management method for realizing multiple tasks, in particular to a method for realizing management of software multiple tasks based on C language.
Background
The software functions are realized by programs, and in the actual programming process, the functions are developed according to the overall design or the requirements of users. However, since multi-task development is performed many times, in the development process or after the development is completed, when previous planning is not comprehensive enough or users increase the needs, developers can perform iterative development on original codes, the size of a single function is larger and larger, various bugs appear, old bugs are not solved, newly written codes introduce various uncertain bug hidden dangers, the debugging process is rather perplexity, developers who take over later often need to read codes written by previous development to continue development, the development efficiency of the developers is seriously influenced, the development progress is influenced, and uncertainty is also increased for product stability.
When a program is developed based on the existing functions, new task processing is added to the software development when the requirement is changed, so that the following defects exist:
1. the function of a single function is more and more, and the code quantity is larger and larger.
2. The new and old bugs are interwoven together, and debugging needs to distinguish whether the bug is left before or added with the bug newly introduced by the code, so that the debugging difficulty is increased.
3. Later personnel who take over development need read through the code that develops before, because programming style and custom problem, often take over time smoothly, influence development efficiency.
4. The code encapsulation is not good and the portability is poor.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
Disclosure of Invention
The invention aims to provide a method for realizing management software multitask based on C language, which can be compatible with previous codes to carry out rapid iterative development and improve debugging efficiency.
In order to achieve the above object, the present invention provides a method for implementing multitask management software based on C language, which comprises the following steps: (a) Determining a task ID, a task type, an initialization entry function and an exit function according to requirements, and creating a collection (TCB) task of a single task; (b) Registering a command set of task IDs into the TCB so as to adapt different task processing flows according to different ID commands; (c) Registering different processing functions connected with the server according to different ID commands; (d) Adding the task of TCB which finishes the registration of the processing function to a task management linked list, and setting the running state of the task ID; (e) Finding a processing function corresponding to the task ID in the TCB task management linked list through the task ID, setting an operation marking bit, and starting operation; and (f) repeating the steps (a) to (e) to create the next task.
In a preferred embodiment, the method for implementing the multitask of the management software based on the C language further comprises the following steps: and receiving data through the registered ID task, scheduling and dispatching the task according to different task IDs by the task manager, and copying and processing corresponding data according to different task types by the scheduling function.
In a preferred embodiment, the method for implementing the multitask of the management software based on the C language further comprises the following steps: and if the task processing process is abnormal, calling a corresponding error processing function according to a corresponding error code in the task ID.
In a preferred embodiment, the task types include snoop, short processing, long processing.
In a preferred embodiment, a thread is established in a processing function connected to the server to process data communicated with the server, and the task IDs correspond to the processing functions one to one.
In a preferred embodiment, the method encapsulates all information used in a single task in the same data structure, and the information includes: task command ID, running state, task type identification, received data buffer, received data length, thread ID, mutex lock, initialization function pointer, exit function pointer, thread service processing function, private data pointer, running error code, user running error processing function pointer, packet command set.
In a preferred embodiment, the method for implementing the management of software multitasks based on the C language defines tasks as nodes of a structure type, each node is a task, and the nodes are managed through a task management linked list.
In a preferred embodiment, the main functions of the task manager are adding a new node function, deleting a specified node function, searching a node function, traversing nodes, calling a task function and a core scheduling function.
In a preferred embodiment, the method for managing software multitask based on C language controls the start, pause and exit of tasks by controlling the running flag bits of the tasks, and realizes the information synchronization between threads by mutual exclusion locks.
Compared with the prior art, the method for realizing the multitask of the management software based on the C language has the following advantages that: the invention realizes multi-task management based on C language, all information used in a task is encapsulated in a data structure, the task is defined into a node of a structure type, and the node is managed through a linked list, thereby achieving the purpose of managing all tasks. And the method can be compatible with the previous codes for rapid iterative development, new bugs are not easy to generate, the debugging efficiency is high, the novice intervention development is rapid, and the project progress is convenient to advance more rapidly. Meanwhile, the code has good encapsulation, clear structure, strong reproducibility and portability.
Drawings
FIG. 1 is a flow chart of a method for managing software multitasking based on C language implementation according to an embodiment of the invention.
Detailed Description
The following detailed description of the present invention is provided in conjunction with the accompanying drawings, but it should be understood that the scope of the present invention is not limited to the specific embodiments.
Throughout the specification and claims, unless explicitly stated otherwise, the term "comprise" or variations such as "comprises" or "comprising", etc., will be understood to imply the inclusion of a stated element or component but not the exclusion of any other element or component.
As shown in fig. 1, the method for managing software multitasking based on C language according to the preferred embodiment of the present invention comprises the following steps: (a) Determining a task ID, a task type, an initialization entry function and an exit function according to requirements, and creating a collection TCB task of a single task; (b) Registering a command set of task IDs into the TCB so as to adapt different task processing flows according to different ID commands; (c) Registering different processing functions connected with the server according to different ID commands; (d) Adding the task of the TCB which finishes the registration of the processing function to a task management linked list, and setting the running state of the task ID; (e) Finding a processing function corresponding to the task ID in the TCB task management linked list through the task ID, setting an operation marking bit, and starting operation; and (f) repeating the steps (a) to (e) to create the next task.
In the above solution, the method for implementing multitasking of management software based on C language further includes: and receiving data through the registered ID task, scheduling and dispatching the task according to different task IDs by the task manager, and copying and processing corresponding data according to the task type by the scheduling function.
In a preferred embodiment, the method for implementing the multitask of the management software based on the C language further comprises the following steps: and if the exception occurs in the processing process, calling a corresponding error processing function according to a corresponding error code in the task ID.
In a preferred embodiment, the task types include snoop, short processing, long processing.
In a preferred embodiment, the method encapsulates all information used in a single task in the same data structure, and the information includes: task command ID, running state, task type identification, received data buffer, received data length, thread ID, mutex lock, initialization function pointer, exit function pointer, thread service processing function, private data pointer, running error code, user running error processing function pointer, packet command set.
In a preferred embodiment, the method for realizing management of software multitask based on C language defines tasks as nodes of a structure type, manages the nodes through a task management linked list, and achieves the purpose of managing all tasks, wherein main functions comprise adding a new node function, deleting a specified node function, searching the node function, traversing the nodes, calling the task function and a core scheduling function.
In a preferred embodiment, the method for managing software multitask based on C language controls the start, pause and exit of tasks by controlling the running flag bits of the tasks, and realizes the information synchronization between threads by mutual exclusion locks.
One embodiment of the present invention is described below:
the method for realizing management software multitask based on the C language comprises the following steps:
1. as mentioned above, each task in the TCB is defined as a node, the purpose of task management is achieved through the management of the nodes, firstly, the management function functions of the TCB need to be defined, including task scheduling and dispatching functions of the TCB, traversing TCB task chain table functions, adding node functions to a TCB management chain table, deleting specified nodes from the TCB management chain table, deleting the whole TCB management chain table, searching the specified nodes through command IDs, traversing the TCB whole chain table and sequentially calling the task functions.
2. And determining the task ID, the task type, the initialization entry function and the exit function according to the requirements, and creating the collection TCB task of a single task. Taking the creation of server monitoring tasks as an example: defining the task ID as SERVER _ CONNECT _ TCB _ ID, the task type as LISTENDEAL, the initialization function as ServerConnectInit, the initialization function pointer as NULL, the exit function as NULL (all exit function pointers are NULL because the function needs to be operated all the time), the exit function data pointer as NULL (all exit function data pointers are NULL because the function needs to be operated all the time), the private data pointer as NULL (no private data exists here), the initialization function mainly comprises reading system configuration files to prepare network connection, setting a heartbeat monitoring period, defining contents such as related command codes and data transmission states communicated with the SERVER, and preparing for data communication.
3. The command set of task IDs is registered in the TCB to adapt different process flows according to different commands, i.e. the ID command set needs to be predefined according to the business requirements.
4. Registering different processing functions connected with the server according to different ID commands, namely adding the task corresponding to the task ID in the step 2 into a TCB task management linked list, and defining the processing function connected with the server.
5. Adding the registered task of the TCB to a task management linked list, and setting the running state of the task ID;
6. finding a processing function corresponding to the task ID in the task management linked list through the task ID, setting an operation marking bit, and starting operation to obtain a server monitoring task;
7. repeating the steps 2-6, and establishing the next task;
8. the server monitors the task receiving data, the task manager schedules and dispatches the tasks according to different task IDs, and the scheduling function copies and processes corresponding data according to task types.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing descriptions of specific exemplary embodiments of the present invention have been presented for purposes of illustration and description. It is not intended to limit the invention to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain certain principles of the invention and its practical application to enable one skilled in the art to make and use various exemplary embodiments of the invention and various alternatives and modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims and their equivalents.
Claims (7)
1. A method for realizing management software multitasking based on C language is characterized by comprising the following steps:
(a) Determining task ID, task type, initialization entry function and exit function according to requirements, and creating a collection TCB task of a single task;
(b) Registering the command set of task IDs in the TCB to adapt different task processing flows according to different ID commands;
(c) Registering different processing functions connected with the server according to different ID commands;
(d) Adding the task of the TCB which finishes the registration of the processing function to a task management linked list, and setting the running state of the task ID;
(e) Finding a processing function corresponding to the task ID in the TCB task management linked list through the task ID, setting an operation marking position, and starting operation; and
(f) Repeating the steps (a) to (e) to create the next task;
the method encapsulates all information used in a single task in the same data structure, wherein the information comprises: task command ID, running state, task type identification, received data buffer, received data length, thread ID, exclusive lock, initialization function pointer, exit function pointer, thread service processing function, private data pointer, running error code, user running error processing function pointer, data packet command set;
the method for realizing the multitask of the management software based on the C language defines tasks as nodes of a structure type, each node is a task, and the nodes are managed through the task management linked list.
2. The method for managing software multitasking based on the C language realization as claimed in claim 1, wherein said method for managing software multitasking based on the C language realization further comprises: and receiving data through the registered ID task, scheduling and dispatching the task according to different task IDs by the task manager, and copying and processing corresponding data according to different task types by the scheduling function.
3. The method for managing software multitasking based on C language according to claim 1, characterized by that said method for managing software multitasking based on C language further includes: and if the task processing process is abnormal, calling a corresponding error processing function according to a corresponding error code in the task ID.
4. The method for managing software multitasking based on the C language implementation as claimed in claim 2, characterized in that said task types include snoop, short processing, long processing.
5. The method for implementing management software multitasking based on C language according to claim 1, wherein a thread is established in different processing functions connected with said server to process data communicated with said server, and wherein said task ID is in one-to-one correspondence with said processing functions.
6. The method for managing software multitasking according to claim 1, wherein the task manager main functions are adding new node functions, deleting specified node functions, searching node functions, traversing node, calling task functions, and core scheduling functions.
7. The method for managing software multitasking based on C language according to claim 5, characterized in that said method for managing software multitasking based on C language is used for controlling the start, pause and exit of task by means of controlling the running flag bit of task and implementing the information synchronization between threads by means of mutual exclusion lock.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910445168.6A CN110147247B (en) | 2019-05-27 | 2019-05-27 | Method for realizing management software multitask based on C language |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910445168.6A CN110147247B (en) | 2019-05-27 | 2019-05-27 | Method for realizing management software multitask based on C language |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110147247A CN110147247A (en) | 2019-08-20 |
CN110147247B true CN110147247B (en) | 2023-01-24 |
Family
ID=67593100
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910445168.6A Active CN110147247B (en) | 2019-05-27 | 2019-05-27 | Method for realizing management software multitask based on C language |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110147247B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1391386A (en) * | 2001-06-12 | 2003-01-15 | 华为技术有限公司 | Method for protecting task process in multitask operating system |
CN1728701A (en) * | 2004-07-30 | 2006-02-01 | 国家数字交换系统工程技术研究中心 | Method for treating protocol stack of route through one process |
CN103049325A (en) * | 2013-01-09 | 2013-04-17 | 浙江大学 | Method for implementing CSA (context save area) node manager on basis of TC1767 platform |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8161453B2 (en) * | 2004-11-16 | 2012-04-17 | Rabih Chrabieh | Method and apparatus for implementing task management of computer operations |
-
2019
- 2019-05-27 CN CN201910445168.6A patent/CN110147247B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1391386A (en) * | 2001-06-12 | 2003-01-15 | 华为技术有限公司 | Method for protecting task process in multitask operating system |
CN1728701A (en) * | 2004-07-30 | 2006-02-01 | 国家数字交换系统工程技术研究中心 | Method for treating protocol stack of route through one process |
CN103049325A (en) * | 2013-01-09 | 2013-04-17 | 浙江大学 | Method for implementing CSA (context save area) node manager on basis of TC1767 platform |
Non-Patent Citations (2)
Title |
---|
FreeRTOS 任务调度 任务创建;腾讯云用户:orientlu;《腾讯云,网址:https://cloud.tencent.com/developer/article/1336670?from=article.detail.1658611》;20180913;全文 * |
uCOS II 之任务控制块TCB;CSDN用户:EmbeddedOsprey;《CSDN,网址:https://blog.csdn.net/weixin_42876465/article/details/84592187》;20181128;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110147247A (en) | 2019-08-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10740093B2 (en) | Advanced packaging techniques for improving work flows | |
US6832367B1 (en) | Method and system for recording and replaying the execution of distributed java programs | |
US5513357A (en) | Use of build status indicators in connection with building of complex computer programs from source code parts | |
US5864864A (en) | Method and apparatus for providing transparent persistent data support to foreign data types | |
AU600755B2 (en) | Apparatus for distributing data processing across a plurality of loci of control | |
CA2398148C (en) | System and method for managing bi-directional relationships between objects | |
US20050076046A1 (en) | Combining data descriptions | |
CN105446806B (en) | A kind of processing method and processing device of the application program without response | |
US20030079175A1 (en) | Data processing system and development tool | |
US9823991B2 (en) | Concurrent workload simulation for application performance testing | |
CN106708740B (en) | Script testing method and device | |
GB2468742A (en) | Database migration or synchronization with ordering of data replication instructions based upon dependencies between data to prevent errors | |
Kheldoun et al. | Specification and verification of complex business processes-a high-level petri net-based approach | |
CN112559525A (en) | Data checking system, method, device and server | |
US7640538B2 (en) | Virtual threads in business process programs | |
CN107391539B (en) | Transaction processing method, server and storage medium | |
WO2023098041A1 (en) | Method and apparatus for executing blockchain transaction | |
CN110147247B (en) | Method for realizing management software multitask based on C language | |
CN111435329A (en) | Automatic testing method and device | |
WO2024002302A1 (en) | Application management method, application subscription method, and related device | |
JP2003242313A (en) | Business progress controller and method thereof, business progress control program, and recording medium recorded with the program | |
CN110968342B (en) | Version comparison method, device and system | |
JP2005092544A (en) | Work flow generation management processing method, work flow processing system and work flow control program | |
US9934035B2 (en) | Device and method for tracing updated predicate values | |
US10719425B2 (en) | Happens-before-based dynamic concurrency analysis for actor-based programs |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |