Programming method, device and equipment based on Linux system and storage medium

By disassembling the development functions on the Linux system and creating child threads, the problems of complex creation of new processes and system resource consumption in process development are solved, and development efficiency and software performance are improved.

CN119987735APending Publication Date: 2025-05-13镁佳(北京)科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510085072.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

On Linux operating systems, the development of process methods has the problem of complex process creation and process switching consumes system resources, which increases the complexity of programming.

Method used

By obtaining the function to be developed by the target software and the corresponding target main thread, the function to be developed is disassembled, multiple child threads corresponding to the target main thread, and the end logic between the child threads is determined based on the correlation between the sub-functions, and finally the functional program is compiled to realize the function to be developed.

Benefits of technology

It improves the development efficiency of the to-developed functions of the target software and improves the performance and reliability of the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987735A_ABST
    Figure CN119987735A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of computers, and discloses a programming method and device based on a Linux system, equipment and a storage medium, and the method comprises the following steps: obtaining a to-be-developed function of target software and a corresponding target main thread; performing function disassembly on the to-be-developed function to obtain a plurality of sub-functions; creating a plurality of sub-threads corresponding to the target main thread based on the number of the sub-functions; determining an end logic among the plurality of sub-threads based on an association relationship among the plurality of sub-functions; and compiling the function programs corresponding to the plurality of sub-threads based on the ending logic to realize the to-be-developed function of the target software. By means of the technical scheme, the development efficiency of the to-be-developed function of the target software can be improved, and meanwhile the performance and reliability of the target software are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a programming method, apparatus, device and storage medium based on a Linux system. Background Art

[0002] Linux usually refers to GNU / Linux, which is a free and freely disseminated UNIX-like operating system. It is a multi-user, multi-tasking, multi-threaded and multi-CPU operating system based on POSIX. It is compatible with 32-bit and 64-bit hardware architectures and can run mainstream Unix tools, applications and network protocols. When developing software on the Linux platform, developers can use the system's powerful functions and flexibility to build applications ranging from basic command line tools to complex graphical user interfaces.

[0003] However, in the practice of software development for the Linux operating system, process-based development is more common. However, process programming methods have some challenges when developing programs. For example, the process of creating a new process is more complicated, and process switching requires the operating system to perform multiple steps, which not only consumes a lot of system resources, but also increases the complexity of programming accordingly. Summary of the invention

[0004] In view of the above problems, an embodiment of the present invention provides a programming method, apparatus, device and storage medium based on a Linux system.

[0005] According to one aspect of an embodiment of the present invention, a programming method based on a Linux system is provided, the method comprising: obtaining a function to be developed of a target software and a corresponding target main thread; performing functional decomposition of the function to be developed to obtain multiple sub-functions; creating multiple sub-threads corresponding to the target main thread based on the number of sub-functions; determining the termination logic between the multiple sub-threads based on the association relationship between the multiple sub-functions; and compiling the functional programs corresponding to the multiple sub-threads based on the termination logic to realize the function to be developed of the target software. Through the above process, the development efficiency of the function to be developed of the target software can be improved, and the performance and reliability of the target software can be improved at the same time.

[0006] In an optional implementation, based on the number of sub-functions, multiple sub-threads corresponding to the target main thread are created, including:

[0007] Get the thread library corresponding to the target software;

[0008] Call thread creation function based on thread library;

[0009] Based on the number of sub-functions and the thread creation function, multiple sub-threads corresponding to the target main thread are created.

[0010] In an optional implementation, based on the number of sub-functions and the thread creation function, multiple sub-threads corresponding to the target main thread are created, including:

[0011] For any sub-function, a sub-thread corresponding to the sub-function is created based on a thread creation function to obtain a thread creation result. The thread creation function includes thread attributes, a function to be executed corresponding to the thread, and a thread creation result.

[0012] If the creation result indicates that the child thread is successfully created, the unique identifier corresponding to the child thread is fed back to the target main thread;

[0013] If the creation result indicates that the child thread creation failed, the error code is fed back to the target main thread.

[0014] In an optional implementation, determining the termination logic between multiple sub-threads based on the association relationship between multiple sub-functions includes:

[0015] Obtaining the association relationship between the current sub-function and other sub-functions among multiple sub-functions;

[0016] If the association relationship is non-association, the end logic of the sub-thread corresponding to the current sub-function is determined to be a detached state. The detached state is used to indicate that when the sub-thread corresponding to the current sub-function ends its thread execution, the thread will be directly recycled through the target main thread.

[0017] In an optional implementation, determining the termination logic between the multiple sub-threads based on the association relationship between the multiple sub-functions further includes:

[0018] If the association relationship is dependent, the ending logic of the sub-thread corresponding to the current sub-function is determined to be a co-ecology. The co-ecology is used to characterize that when the sub-thread corresponding to the current sub-function ends the thread execution, the sub-threads corresponding to other sub-functions need to call the thread suspension function to wait for the sub-thread corresponding to the current sub-function to end the thread execution, and then recycle the thread through the target main thread.

[0019] In an optional implementation, the above method further includes:

[0020] Obtain the first resource information that the subthread corresponding to the current subfunction needs to access during the thread execution process;

[0021] Obtain the second resource information that the sub-thread corresponding to other sub-functions needs to access during the thread execution process;

[0022] Comparing the first resource information and the second resource information to obtain a resource comparison result;

[0023] If the resource comparison result indicates that the first resource information is identical to the second resource information, the target function group is used to determine the timing of the subthread corresponding to the current subfunction and the subthreads corresponding to other subfunctions to access the first resource information and the second resource information.

[0024] In an optional implementation, the above method further includes:

[0025] Get the resource occupancy rate of any sub-thread among multiple sub-threads;

[0026] Calculate the difference between the resource occupancy rate and the resource occupancy rate threshold to obtain the resource occupancy rate difference;

[0027] The sub-threads are split based on the resource occupancy rate difference to obtain multiple molecular threads corresponding to the sub-threads.

[0028] According to another aspect of an embodiment of the present invention, a programming device based on a Linux system is provided, including: a data acquisition module for acquiring a function to be developed of a target software and a corresponding target main thread; a function decomposition module for decomposing the function to be developed to obtain multiple sub-functions; a thread creation module for creating multiple sub-threads corresponding to the target main thread based on the number of sub-functions; a logic determination module for determining the end logic between multiple sub-threads based on the association relationship between multiple sub-functions; and a program compilation module for compiling the functional programs corresponding to multiple sub-threads based on the end logic to realize the function to be developed of the target software. Through the above modules, the development efficiency of the function to be developed of the target software can be improved, while the performance and reliability of the target software can be improved.

[0029] According to another aspect of an embodiment of the present invention, a computer device is provided, including: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the aforementioned programming method based on the Linux system.

[0030] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which at least one executable instruction is stored, and the executable instruction enables a computer device / apparatus to execute the operation of the aforementioned programming method based on a Linux system.

[0031] According to another aspect of an embodiment of the present invention, a computer program product is provided, including computer instructions for causing a computer to execute the operations of the programming method based on a Linux system according to the first aspect or any corresponding implementation manner thereof.

[0032] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0034] Figure 1 A schematic diagram of a Linux-based programming method provided by the present invention is shown;

[0035] Figure 2 A schematic diagram of thread creation of a programming method based on a Linux system provided by the present invention is shown;

[0036] Figure 3 A thread waiting schematic diagram of a programming method based on a Linux system provided by the present invention is shown;

[0037] Figure 4 Another schematic diagram of a Linux-based programming method provided by the present invention is shown;

[0038] Figure 5 A schematic diagram of the structure of a programming device based on a Linux system provided by the present invention is shown;

[0039] Figure 6 A schematic structural diagram of a computer device provided by the present invention is shown. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0041] Figure 1 FIG. 1 is a flowchart showing a first embodiment of a programming method based on a Linux system according to the present invention. Figure 1 As shown, the method comprises the following steps:

[0042] Step 110, obtaining the to-be-developed functions of the target software and the corresponding target main thread.

[0043] The target main thread can be a thread responsible for the main logic processing or a thread responsible for interacting with other modules. By obtaining the function to be developed and the corresponding target main thread, clear guidance can be provided for subsequent development work to ensure that the development work can proceed in an orderly manner.

[0044] Step 120, decomposing the function to be developed into multiple sub-functions.

[0045] Among them, function decomposition is to decompose the complex functions to be developed into multiple relatively simple and independent sub-functions to facilitate subsequent coding implementation and testing. Each sub-function can correspond to one or more specific coding tasks, so as to facilitate the division of labor and collaboration among developers. Through function decomposition, the development work can be made clearer and more organized, and the development efficiency and code quality can be improved.

[0046] In addition, functional disassembly can also help identify potential technical difficulties and risk points. During the disassembly process, developers can conduct in-depth analysis and evaluation of each sub-function, discover possible problems, and formulate corresponding solutions and response strategies in advance. This can effectively avoid insurmountable technical obstacles in the subsequent development process and ensure the smooth progress of the project. At the same time, functional disassembly also facilitates subsequent testing work. Testers can formulate corresponding test plans and test cases based on the specific requirements of each sub-function, and verify and confirm the developed sub-functions one by one to ensure that each sub-function can work normally as expected.

[0047] Step 130: Create multiple sub-threads corresponding to the target main thread based on the number of sub-functions.

[0048] As described above, multiple sub-threads corresponding to the target main thread are created based on the number of sub-functions, so that the functions to be developed are implemented based on the multiple sub-threads corresponding to the target main thread.

[0049] In some optional implementations, when creating multiple sub-threads corresponding to the target main thread based on the number of sub-functions, you can first obtain the thread library corresponding to the target software; call the thread creation function based on the thread library; and create multiple sub-threads corresponding to the target main thread based on the number of sub-functions and the thread creation function.

[0050] In some optional embodiments, when multiple sub-threads corresponding to the target main thread are created based on the number of sub-functions and the thread creation function, for any sub-function, the sub-thread corresponding to the sub-function is created based on the thread creation function to obtain a thread creation result, and the thread creation function includes thread attributes, the function to be executed corresponding to the thread, and the thread creation result; if the creation result indicates that the sub-thread is successfully created, the unique identifier corresponding to the sub-thread is fed back to the target main thread; if the creation result indicates that the sub-thread creation fails, the error code is fed back to the target main thread.

[0051] In practice, see Figure 2 If the thread library corresponding to the target software is a POSIX thread library, the POSIX thread library provides a thread control method interface to the user, so that developers can write portable multi-threaded applications on a Linux operating system that complies with the POSIX standard.

[0052] First, the POSIX thread library is a standard interface for multithreaded programming, defining a set of functions, data types, and constants; the POSIX thread library introduces<pthread.h> header file; when linking a program that uses the POSIX thread library, use the "-lpthread" command item. Then, based on the POSIX thread library, call the pthread_create function (thread creation function) to create a thread. If the thread is successfully created, it returns 0, and if it fails, it returns a non-zero error code. The specific error information can be viewed through the global variable errno of the POSIX thread library; after successfully creating a thread, the pthread_create function returns the thread ID to the thread function (the target main thread).

[0053] In this embodiment, the specific contents of the pthread_create function are as follows:

[0054] intpthread_create(pthread_t*thread, constpthread_attr_t*attr, void*(*start_routine)(void*), void*arg);

[0055] Among them, thread is the thread ID returned after the thread is successfully created, attr is the thread attributes (thread attributes) to be set, and filling in NULL indicates the default attributes; start_routine points to a pointer to a function, which indicates the function to be executed by the new thread (the function to be executed corresponding to the thread, and the content of the function to be executed can be defined according to actual needs, such as processing music data, processing network data, etc.), the function must return a void* type and accept a void* type parameter, and arg represents the parameter passed to the start_routine function.

[0056] Step 140: determining the termination logic among the plurality of sub-threads based on the association relationship among the plurality of sub-functions.

[0057] As described above, by determining the termination logic among the multiple sub-threads based on the association relationship among the multiple sub-functions, the functional programs corresponding to the multiple sub-threads are compiled based on the termination logic, thereby realizing the functions to be developed of the target software.

[0058] In some optional implementations, when determining the termination logic between multiple sub-threads based on the association relationship between multiple sub-functions, the association relationship between the current sub-function and other sub-functions in the multiple sub-functions can be obtained first. If the association relationship is non-association, the termination logic of the sub-thread corresponding to the current sub-function is determined to be a detached state, and the detached state is used to characterize that when the sub-thread corresponding to the current sub-function ends the thread execution, the thread will be directly recycled through the target main thread. If the association relationship is dependent, the termination logic of the sub-thread corresponding to the current sub-function is determined to be a co-ecology, and the co-ecology is used to characterize that when the sub-thread corresponding to the current sub-function ends the thread execution, the sub-threads corresponding to other sub-functions need to call the thread suspension function to wait for the sub-thread corresponding to the current sub-function to end the thread execution, and then recycle the thread through the target main thread.

[0059] Furthermore, in POSIX threads, a thread is in one of two states:

[0060] Joinable state (co-ecology): By default, a thread is in the joinable state, and its exit status will not be recovered immediately. Other threads need to call the pthread_join function to wait for the thread to end and obtain its exit status. In this state, the thread's resources will be retained until other threads call the pthread_join function.

[0061] Detached state: When a thread is in the detached state, its exit state will be automatically recycled when the thread ends, without the need for other threads to call the pthread_join function. In this state, after the thread ends, the system's target main thread will immediately recycle its resources without waiting for the thread.

[0062] In practice, see Figure 3 , the thread waiting to call the pthread_join function (thread suspension function) will suspend and wait until the thread with ID thread terminates. The thread thread (target main thread) terminates in different ways, and the termination status obtained by pthread_join is different. The specific status is as follows:

[0063] The thread returns through return, and the unit pointed to by value_ptr stores the return value of the thread function;

[0064] The thread is abnormally terminated by another thread calling pthread_cancel, and the unit pointed to by value_ptr stores the constant PTHREAD_CANCELED;

[0065] The thread calls pthread_exit to terminate. The unit pointed to by value_ptr stores the parameters passed to pthread_exit.

[0066] The thread is not interested in the termination status and can pass NULL to the value_ptr parameter.

[0067] Further, the specific contents of pthread_exit are as follows:

[0068] voidpthread_exit(void*value_ptr);

[0069] Among them, value_ptr is a pointer used to pass the exit status of the thread to the parent thread (target main thread). It can be a pointer of any type and is usually used to pass the return value or other information of the thread.

[0070] Further, the specific content of thread_join is as follows:

[0071] intpthread_join(pthread_tthread, void**value_ptr);

[0072] Among them, thread is the ID of the thread to be waited, value_ptr is a pointer used to receive the exit status of the thread, and the thread calling this function will suspend and wait until the thread with ID thread terminates.

[0073] In some optional implementations, based on the association between multiple sub-functions, when determining the termination logic between multiple sub-threads, the first resource information required to be accessed by the sub-thread corresponding to the current sub-function during the thread execution process can also be obtained; the second resource information required to be accessed by the sub-thread corresponding to other sub-functions during the thread execution process can be obtained; the first resource information and the second resource information can be compared to obtain the resource comparison result; if the resource comparison result indicates that the first resource information and the second resource information are the same, the timing of the sub-thread corresponding to the current sub-function and the sub-thread corresponding to the other sub-functions to access the first resource information and the second resource information is determined by the target function group. If the resource comparison result indicates that the first resource information and the second resource information are different, it is processed according to the preset conflict resolution strategy. The conflict resolution strategy may include but is not limited to: priority strategy, that is, determining the order of accessing resources according to the priority of the sub-function or sub-thread; delay strategy, that is, temporarily delaying the access of a sub-thread to resources until another sub-thread completes the access; and mutual exclusion strategy, that is, using the mutual exclusion mechanism to ensure that only one sub-thread can access resources at the same time. After handling the conflict, the timing of the sub-thread accessing resources is re-determined to ensure the orderliness and correctness of resource access.

[0074] Furthermore, the target function group may include functions such as mutual exclusion locks, read-write locks, conditional variables, semaphores, etc. to ensure that conflicts or data inconsistencies do not occur when multiple threads access shared resources.

[0075] Specifically, mutex locks are used as thread synchronization mechanisms, which ensure that only one thread can access shared resources at any time, thereby avoiding data contention and inconsistency. Read-write locks are used to protect shared resources to allow multiple threads to read resources at the same time, which can improve the execution efficiency of the program when performing read operations. Semaphores are used in multi-threaded programming to manage access to shared resources. Condition variables are used with mutex locks to avoid race conditions. The main operations of condition variables include waiting for the condition to be met and notifying other waiting threads that the condition has been met. Condition variables are used to handle producer and consumer models and are used in conjunction with mutex locks.

[0076] Step 150 , compile the functional programs corresponding to the multiple sub-threads based on the termination logic to implement the functions to be developed of the target software.

[0077] During the compilation process, the functional program of each sub-thread can be strictly checked for syntax and logic to ensure the correctness and stability of the program. At the same time, the compiled program can be optimized according to the end logic to improve the execution efficiency and response speed of the software. In addition, the functional program of each sub-thread can be modularized to facilitate subsequent maintenance and upgrades.

[0078] The programming method based on the Linux system of the embodiment of the present invention obtains the to-be-developed function of the target software and the corresponding target main thread; decomposes the to-be-developed function to obtain multiple sub-functions; creates multiple sub-threads corresponding to the target main thread based on the number of sub-functions; determines the termination logic between the multiple sub-threads based on the association relationship between the multiple sub-functions; compiles the functional programs corresponding to the multiple sub-threads based on the termination logic to realize the to-be-developed function of the target software, thereby improving the development efficiency of the to-be-developed function of the target software and improving the performance and reliability of the target software.

[0079] Figure 4 FIG. 2 is a flow chart showing another embodiment of the programming method based on the Linux system of the present invention. Figure 4 As shown, the method comprises the following steps:

[0080] Step 410, obtaining the to-be-developed functions of the target software and the corresponding target main thread.

[0081] For details, please see Figure 1 Step 110 of the illustrated embodiment will not be described in detail here.

[0082] Step 420, decomposing the function to be developed into multiple sub-functions.

[0083] For details, please see Figure 1 Step 120 of the illustrated embodiment will not be described in detail here.

[0084] Step 430: Create multiple sub-threads corresponding to the target main thread based on the number of sub-functions.

[0085] Specifically, the above step 430 includes:

[0086] Step 4301, obtaining the resource occupancy rate of any sub-thread among multiple sub-threads.

[0087] Step 4302, calculate the difference between the resource occupancy rate and the resource occupancy rate threshold to obtain the resource occupancy rate difference.

[0088] Step 4303: split the sub-thread based on the resource occupancy rate difference to obtain multiple molecular threads corresponding to the sub-thread.

[0089] During the splitting process, if the resource occupancy rate difference exceeds the preset splitting threshold, the sub-thread will be split. The split molecular threads will share the workload of the atomic threads, thereby optimizing resource allocation and improving the overall operation efficiency of the system. The specific splitting strategy can be adjusted according to actual needs. For example, the number of split molecular threads can be determined based on the ratio of the resource occupancy rate difference, or split according to specific business logic to achieve the use of multi-threading to write CPU-intensive programs and IO-intensive programs. Through this splitting method, it can ensure that the resource occupancy rate of each molecular thread is kept within a reasonable range to avoid excessive concentration or waste of resources.

[0090] Among them, multithreading refers to the technology of implementing multiple threads concurrently from software or hardware. Computers with multithreading capabilities can execute more than one thread at the same time due to hardware support, thereby improving overall processing performance. Systems with this capability include symmetric multiprocessors, multi-core processors, and chip-level multiprocessing or simultaneous multithreading processors.

[0091] In actual operation, the pthread_detach function is used in POSIX threads to separate threads. The specific pthread_detach function is as follows:

[0092] intpthread_detach(pthread_tthread).

[0093] Step 440: Determine the termination logic among the multiple sub-threads based on the association relationship among the multiple sub-functions.

[0094] For details, please see Figure 1 Step 140 of the illustrated embodiment will not be described in detail here.

[0095] Step 450 , compile the functional programs corresponding to the multiple sub-threads based on the termination logic to implement the functions to be developed of the target software.

[0096] For details, please see Figure 1 Step 150 of the illustrated embodiment will not be described in detail here.

[0097] In summary, the programming method based on the Linux system of the embodiment of the present invention adopts thread programming instead of process programming. The cost of creating a new thread is much smaller than that of creating a new process. Compared with switching between processes, switching between threads requires much less work for the operating system. The resources occupied by threads are much less than those of processes. The parallel number of multi-processors can be fully utilized. While waiting for the slow I / O operation to end, the program can perform other computing tasks. In order to run on a multi-processor system, the calculation is decomposed into multiple threads for implementation, which is more suitable for CPU-intensive programs. In order to improve performance, I / O operations are overlapped, and threads can wait for different I / O operations at the same time, which is more suitable for IO-intensive programs. The problem that the programming method for the Linux operating system mostly adopts the process method, the process programming method has cumbersome steps to create a new process, and the cost is very high. When switching processes, the operating system needs to execute multiple steps, which occupies a lot of system resources, making the program execution slow. The programming process requires more steps, which increases the cumbersomeness of programming.

[0098] Figure 5 FIG. 2 is a schematic diagram showing a structural embodiment of a programming device based on a Linux system according to the present invention. Figure 5 As shown, the device comprises:

[0099] The data acquisition module 510 is used to acquire the functions to be developed of the target software and the corresponding target main thread;

[0100] Function decomposition module 520, used for decomposing the function to be developed into multiple sub-functions;

[0101] A thread creation module 530, for creating a plurality of sub-threads corresponding to a target main thread based on the number of sub-functions;

[0102] A logic determination module 540, for determining the termination logic between the plurality of sub-threads based on the association relationship between the plurality of sub-functions;

[0103] The program compiling module 550 is used to compile the functional programs corresponding to the multiple sub-threads based on the termination logic to realize the functions to be developed of the target software.

[0104] In an optional implementation, the function decomposition module 520 includes:

[0105] The thread library acquisition submodule is used to acquire the thread library corresponding to the target software;

[0106] Function call submodule, used to call thread creation function based on thread library;

[0107] The thread creation submodule is used to create multiple sub-threads corresponding to the target main thread based on the number of sub-functions and the thread creation function.

[0108] In an optional implementation, the thread creation submodule includes:

[0109] A sub-thread creation unit is used to create a sub-thread corresponding to any sub-function based on a thread creation function to obtain a thread creation result. The thread creation function includes thread attributes, a function to be executed corresponding to the thread, and a thread creation result.

[0110] An identifier feedback unit, configured to feedback a unique identifier corresponding to the child thread to the target main thread if the creation result indicates that the child thread is successfully created;

[0111] The error feedback unit is used to feedback an error code to the target main thread if the creation result indicates that the child thread creation fails.

[0112] In an optional implementation, the logic determination module 540 includes:

[0113] The association relationship acquisition submodule is used to obtain the association relationship between the current subfunction and other subfunctions among multiple subfunctions;

[0114] The first ending logic submodule is used to determine that the ending logic of the sub-thread corresponding to the current sub-function is in a detached state if the association relationship is non-association. The detached state is used to indicate that when the sub-thread corresponding to the current sub-function ends the thread execution, the thread will be directly recycled through the target main thread.

[0115] In some optional implementations, the logic determination module 540 further includes:

[0116] The first ending logic sub-module is used to determine that the ending logic of the sub-thread corresponding to the current sub-function is a co-ecology if the association relationship is a dependency. The co-ecology is used to characterize that when the sub-thread corresponding to the current sub-function ends at the end of the thread execution, the sub-threads corresponding to other sub-functions are required to call the thread suspension function to wait for the sub-thread corresponding to the current sub-function to end the thread execution, and then recycle the thread through the target main thread.

[0117] In some optional embodiments, the logic determination module 540 is also used to obtain the first resource information that the sub-thread corresponding to the current sub-function needs to access during the thread execution; obtain the second resource information that the sub-thread corresponding to other sub-functions needs to access during the thread execution; compare the first resource information and the second resource information to obtain a resource comparison result; if the resource comparison result indicates that the first resource information is the same as the second resource information, then determine the timing of the sub-thread corresponding to the current sub-function and the sub-threads corresponding to other sub-functions accessing the first resource information and the second resource information through the objective function group.

[0118] In some optional implementations, the logic determination module 540 is also used to obtain the resource occupancy rate of any sub-thread among multiple sub-threads; calculate the difference between the resource occupancy rate and the resource occupancy rate threshold to obtain the resource occupancy rate difference; split the sub-thread based on the resource occupancy rate difference to obtain multiple molecular threads corresponding to the sub-thread.

[0119] The further functional description of each of the above modules and units is the same as that of the above corresponding method embodiments and will not be repeated here.

[0120] Through the above device and its components, the technical solution provided by the embodiment of the present invention has the following advantages:

[0121] The programming device based on the Linux system of the embodiment of the present invention obtains the to-be-developed function of the target software and the corresponding target main thread through a data acquisition module; decomposes the to-be-developed function through a function decomposition module to obtain multiple sub-functions; creates multiple sub-threads corresponding to the target main thread based on the number of sub-functions through a thread creation module; determines the termination logic between the multiple sub-threads based on the association relationship between the multiple sub-functions through a logic determination module; compiles the functional programs corresponding to the multiple sub-threads based on the termination logic through a program compilation module to realize the to-be-developed function of the target software, thereby improving the development efficiency of the to-be-developed function of the target software and improving the performance and reliability of the target software.

[0122] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 610, memory 620, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 610 is taken as an example.

[0123] The processor 610 may be a central processing unit, a network processor or a combination thereof. The processor 610 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable logic gate array, a general purpose array logic or any combination thereof.

[0124] The memory 620 stores instructions executable by at least one processor 610, so that the at least one processor 610 executes the method shown in the above embodiment.

[0125] The memory 620 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of a computer device based on the presentation of a small program landing page, etc. In addition, the memory 620 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 620 may optionally include a memory remotely arranged relative to the processor 610, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a server cluster, a mobile communication network, and combinations thereof.

[0126] The memory 620 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 620 may also include a combination of the above types of memory.

[0127] The computer device also includes a communication interface 630, which is used for the computer device to communicate with other devices or a communication network.

[0128] An embodiment of the present invention further provides a computer-readable storage medium storing at least one executable instruction. When the executable instruction is executed on a computer device / a programming device based on a Linux system, the computer device / a programming device based on a Linux system executes the Linux system-based programming method in any of the above method embodiments.

[0129] An embodiment of the present invention further provides a computer program product, including computer instructions, where the computer instructions are used to enable a computer to execute the programming method based on a Linux system according to the first aspect or any corresponding implementation manner thereof.

[0130] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system or other device. In addition, the embodiments of the present invention are not directed to any particular programming language.

[0131] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. Similarly, in order to simplify the present invention and help understand one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. Wherein, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself is a separate embodiment of the present invention.

[0132] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and further may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive.

[0133] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.

Claims

1. A programming method based on Linux system, characterized in that: The method comprises: Obtain the functions to be developed of the target software and the corresponding target main thread; Decomposing the function to be developed into multiple sub-functions; Based on the number of the sub-functions, create a plurality of sub-threads corresponding to the target main thread; Determining the termination logic among the plurality of sub-threads based on the association relationship among the plurality of sub-functions; The functional programs corresponding to the multiple sub-threads are compiled based on the termination logic to implement the functions to be developed of the target software.

2. The method according to claim 1, characterized in that: The step of creating a plurality of sub-threads corresponding to the target main thread based on the number of the sub-functions includes: Obtaining a thread library corresponding to the target software; Calling a thread creation function based on the thread library; Based on the number of the sub-functions and the thread creation function, a plurality of sub-threads corresponding to the target main thread are created.

3. The method according to claim 2, characterized in that The step of creating a plurality of sub-threads corresponding to the target main thread based on the number of the sub-functions and the thread creation function includes: For any of the sub-functions, a sub-thread corresponding to the sub-function is created based on the thread creation function to obtain a thread creation result, wherein the thread creation function includes thread attributes, a function to be executed corresponding to the thread, and a thread creation result; If the creation result indicates that the child thread is successfully created, the unique identifier corresponding to the child thread is fed back to the target main thread; If the creation result indicates that the child thread creation fails, an error code is fed back to the target main thread.

4. The method according to claim 1, characterized in that The determining the termination logic between the multiple sub-threads based on the association relationship between the multiple sub-functions includes: Acquire an association relationship between a current sub-function and other sub-functions in the multiple sub-functions; If the association relationship is non-association, it is determined that the end logic of the sub-thread corresponding to the current sub-function is a detached state, and the detached state is used to represent that when the sub-thread corresponding to the current sub-function ends the thread execution, the thread will be directly recycled through the target main thread.

5. The method according to claim 4, characterized in that The determining the termination logic between the plurality of sub-threads based on the association relationship between the plurality of sub-functions further includes: If the association relationship is dependent, then it is determined that the ending logic of the sub-thread corresponding to the current sub-function is a symbiotic ecology, and the symbiotic ecology is used to characterize that when the sub-thread corresponding to the current sub-function ends at the end of thread execution, the sub-threads corresponding to other sub-functions are required to call the thread suspend function to wait for the sub-thread corresponding to the current sub-function to end thread execution, and then perform thread recovery through the target main thread.

6. The method according to claim 4, characterized in that The method further comprises: Obtaining first resource information that needs to be accessed by the sub-thread corresponding to the current sub-function during thread execution; Acquire the second resource information that the sub-thread corresponding to the other sub-function needs to access during the thread execution process; Comparing the first resource information and the second resource information to obtain a resource comparison result; If the resource comparison result indicates that the first resource information is the same as the second resource information, the sub-thread corresponding to the current sub-function and the sub-thread corresponding to the other sub-functions are determined through the target function group to access the first resource information and the second resource information.

7. The method according to claim 1, characterized in that The method further comprises: Obtaining the resource occupancy rate of any sub-thread among the multiple sub-threads; Calculating a difference between the resource occupancy rate and a resource occupancy rate threshold to obtain a resource occupancy rate difference; The sub-thread is split based on the resource occupancy rate difference to obtain a plurality of molecular threads corresponding to the sub-thread.

8. A programming device based on Linux system, characterized in that: The device comprises: A data acquisition module is used to obtain the functions to be developed of the target software and the corresponding target main thread; A function decomposition module, used for decomposing the function to be developed into multiple sub-functions; A thread creation module, used for creating a plurality of sub-threads corresponding to the target main thread based on the number of the sub-functions; A logic determination module, configured to determine the termination logic between the plurality of sub-threads based on the association relationship between the plurality of sub-functions; A program compiling module is used to compile the functional programs corresponding to the multiple sub-threads based on the termination logic to realize the functions to be developed of the target software.

9. A computer device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the operation of the Linux system-based programming method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium stores at least one executable instruction. When the executable instruction is executed on a computer device, the computer device executes the operation of the Linux system-based programming method according to any one of claims 1 to 7.