Serial port printing method, system and equipment based on multi-core system and medium

By using the spin lock mechanism and breakpoint identification in the multi-core system, the conflict and deadlock problems of the UART serial port printing module in the multi-core system are solved, and efficient interrupt response and information differentiation are achieved.

CN120669933APending Publication Date: 2025-09-19ARTMEM TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510580903.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In a multi-core SOC/MCU system, when multiple cores share a UART serial port printing module, conflicts and deadlocks are likely to occur, especially when the interrupt service program needs to print.

Method used

A spin lock mechanism is adopted, and each processor is configured with a lock flag to allow interrupt response during the spin lock period. A breakpoint identifier is inserted into the printed information to distinguish the information of the processor and the interrupt service program to avoid deadlock.

Benefits of technology

Improves the timeliness of interrupt response, supports interrupt nested printing, avoids deadlock, and improves the readability of printed information through breakpoint identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120669933A_ABST
    Figure CN120669933A_ABST
Patent Text Reader

Abstract

The invention discloses a serial port printing method, system and device based on a multi-core system and a medium, and relates to the technical field of multi-core systems. The method comprises the steps that when the spin lock is in an unlocking state and the value of a locking mark of a processor is a first numerical value, the spin lock is locked, and the value of the locking mark is assigned to be a second numerical value; printing serial port information corresponding to the processor through a serial port printing module; in the printing process, if the processor responds to the interrupt service programs, the serial port printing module interrupts printing of the serial port information of the processor, and after the serial port information corresponding to each interrupt service program is inserted in each interrupt position, the serial port information of the processor continues to be printed; after the serial port information of the processor is printed, the spin lock is unlocked; and according to the breakpoint identifier, distinguishing and splicing the serial port information corresponding to the processor and each interrupt service program. According to the method, deadlock can be avoided, and the interrupt response timeliness is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of multi-core systems, and in particular to a serial port printing method, system, device and medium based on a multi-core system. Background Art

[0002] In a multi-core SoC / MCU system, if a UART serial port printing module is shared, multiple cores simultaneously outputting print information, which can cause conflicts and result in garbled characters on the serial port. A common solution to this problem is to add a spin lock to the UART driver. When a core needs to print, it first locks the lock, then performs the print operation, and then unlocks the lock after completion. During this time, if other cores also want to print but fail to lock the lock, they must wait, thus resolving the conflict. However, this solution can cause a deadlock if an interrupt is triggered on the printing core and the interrupt service routine requests printing. Summary of the Invention

[0003] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a serial port printing method, system, device and medium based on a multi-core system, which can avoid deadlock.

[0004] On the one hand, according to an embodiment of the present invention, a serial port printing method based on a multi-core system includes multiple processors, the multiple processors share a serial port printing module, the serial port printing module is configured with a spin lock, and each processor is configured with a lock flag, and the initial value of the lock flag is a first value; the method includes:

[0005] When any of the processors drives the serial port printing module, obtaining the state of the spin lock;

[0006] When the spin lock is in an unlocked state and the value of the lock flag of the processor is the first value, locking the spin lock and assigning the value of the lock flag to a second value;

[0007] Printing the serial port information corresponding to the processor through the serial port printing module;

[0008] During the printing process, if the processor responds to the interrupt service routine, the serial port printing module interrupts the printing of the serial port information of the processor, inserts the serial port information corresponding to each interrupt service routine at each interruption, and then continues to print the serial port information of the processor, and adds a breakpoint mark between the serial port information before and after each interruption;

[0009] When the serial port information of the processor is finished printing, unlocking the spin lock and assigning the value of the lock flag to the first value;

[0010] According to the breakpoint identifier, the serial port information corresponding to the processor and each of the interrupt service routines is distinguished and spliced.

[0011] According to some embodiments of the present invention, during the printing process, if the processor responds to an interrupt service routine, the serial port printing module interrupts printing of the processor's serial port information, inserts serial port information corresponding to each interrupt service routine at each interruption, and then continues printing the processor's serial port information, and adds a breakpoint identifier between the serial port information before and after each interruption, including:

[0012] Counting the number of times the processor responds to the interrupt service program, and adding 1 to the count value each time the serial port information of the interrupt service program is inserted; the initial value of the count value is 0;

[0013] Add the first breakpoint identifier before each inserted serial port information;

[0014] Adding a second breakpoint identifier after each inserted serial port information; the first breakpoint information and the second breakpoint information both include the count value corresponding to the inserted serial port information;

[0015] Each time a piece of serial port information is printed, the count value is reduced by 1.

[0016] According to some embodiments of the present invention, the first breakpoint identifier includes a first special character, the corresponding count value, a second special character and a line break character; the second breakpoint identifier includes the line break character, the first special character, the corresponding count value and the second special character.

[0017] According to some embodiments of the present invention, distinguishing and splicing serial port information corresponding to the processor and each interrupt service routine according to the breakpoint identifier includes:

[0018] Acquire all serial port information printed by the serial port printing module, and determine the first breakpoint identifier and the second breakpoint identifier having the same count value;

[0019] Separating serial port information between the first breakpoint identifier and the second breakpoint identifier having the same count value in descending order of the count value as serial port information of the corresponding interrupt service program;

[0020] The remaining serial port information is spliced ​​into the serial port information of the processor.

[0021] According to some embodiments of the present invention, after the step of obtaining the state of the spin lock when any of the processors drives the serial port printing module, the step further includes:

[0022] When the spin lock is in a locked state, the processor is placed in a waiting queue, waiting for the spin lock to be in an unlocked state;

[0023] When the spin lock is changed from a locked state to an unlocked state, the printing tasks of the processors in the waiting queue are executed in sequence through the serial port printing module according to the priorities of the processors in the waiting queue.

[0024] According to some embodiments of the present invention, the first value is FALSE and the second value is TRUE.

[0025] According to some embodiments of the present invention, the spin lock is configured with a status flag, and the status flag is used to represent the locked state of the spin lock.

[0026] On the other hand, according to an embodiment of the present invention, a serial port printing system based on a multi-core system includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the serial port printing method based on a multi-core system as described in the above-mentioned embodiment.

[0027] On the other hand, an electronic device according to an embodiment of the present invention includes the serial port printing system based on a multi-core system as described in the above embodiment.

[0028] On the other hand, a computer-readable storage medium according to an embodiment of the present invention stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the serial port printing method based on a multi-core system described in the above embodiment.

[0029] The serial port printing method, system, device and medium based on a multi-core system according to the embodiments of the present invention have at least the following beneficial effects: it is possible to not prohibit responding to interrupts during the period when the spin lock is locked, thereby improving the timeliness of responding to interrupts and supporting printing with nested interrupts; at the same time, a mechanism for avoiding deadlock is added. Before preparing to acquire the lock, it is first determined whether the current processor is already locked. If so, the serial port print is directly output; otherwise, normal locking is performed and then the print is output, thereby avoiding deadlock; in addition, in order to avoid confusion caused by the insertion of new serial port print information due to interrupts during normal printing, breakpoint markers are added before and after the inserted print information to improve readability.

[0030] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:

[0032] Figure 1 This is a flowchart of the steps of the serial port printing method based on a multi-core system according to an embodiment of the present invention;

[0033] Figure 2 This is a flowchart of an execution of a serial port printing method based on a multi-core system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application. The step numbers in the following embodiments are provided only for the convenience of explanation and do not limit the order of the steps. The order of execution of the steps in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.

[0035] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, they cannot be understood as limitations on the present invention.

[0036] The terms "first," "second," "third," and "fourth," etc., in the specification, claims, and accompanying drawings of the present invention are used to distinguish between different items, not to describe a specific order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.

[0037] References to "embodiments" in this disclosure mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the disclosure. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0038] A spin lock is a synchronization mechanism used to control access to a shared resource, ensuring that only one processor can access a specific resource at any given time. A spin lock uses a shared flag to indicate the lock's state. Acquiring the lock is called locking, and releasing the lock is called unlocking. If the spin lock is already held by another processor, the new caller will continue to loop, waiting for the holder to unlock the lock.

[0039] Deadlock occurs when a processor locks a spin lock without unlocking it. In response to an interrupt, the interrupt program performs another locking operation, but the second locking operation will never succeed, causing the processor to enter an infinite loop. The locking operation performed by the interrupt service program can easily cause deadlock.

[0040] Existing solutions typically disable interrupt responses before locking and restore interrupt responses after unlocking to avoid deadlock. However, this approach can lead to delayed interrupt responses in scenarios with high real-time requirements.

[0041] To this end, an embodiment of the present invention provides a serial port printing method, system, device and medium based on a multi-core system, which can solve the problem of untimely interrupt response or deadlock caused by the UART serial port module being protected by a spin lock in a multi-core architecture. It does not need to block interrupts during printing, thereby improving the timeliness of interrupt response.

[0042] On the one hand, the embodiment of the present invention proposes a serial port printing method based on a multi-core system. It should be noted that the multi-core system has multiple processors, and the multiple processors share a serial port printing module. The serial port printing module is configured with a spin lock, and each processor is configured with a lock flag. The initial value of the lock flag is a first value. Figure 1 As shown, the serial port printing method based on the multi-core system includes the following steps:

[0043] Step S100: When any processor drives the serial port printing module, the state of the spin lock is obtained;

[0044] Step S200: When the spin lock is in an unlocked state and the value of the lock flag of the processor is a first value, the spin lock is locked and the value of the lock flag is assigned to a second value;

[0045] Step S300: Printing the serial port information corresponding to the processor through the serial port printing module;

[0046] Step S400: During the printing process, if the processor responds to the interrupt service routine, the serial port printing module interrupts the printing of the processor's serial port information, inserts the serial port information corresponding to each interrupt service routine at each interruption, and then continues printing the processor's serial port information, and adds a breakpoint mark between the serial port information before and after each interruption;

[0047] Step S500: After the serial port information of the processor is printed, the spin lock is unlocked and the value of the lock flag is assigned to the first value;

[0048] Step S600: Distinguish and splice the serial port information corresponding to the processor and each interrupt service routine according to the breakpoint identifier.

[0049] Specifically, in a multi-core system, there are multiple cores / processors, each core independently runs its own program and has an independent data segment. When multiple processors share a serial port printing module, a spin lock needs to be configured to ensure that only one processor can access the serial port printing module at any time. When a processor is occupying the serial port printing module for printing, the spin lock will be locked to ensure that other processors cannot call the serial port printing module. When the processor completes printing, the spin lock is unlocked, allowing other processors to use the serial port printing module. Therefore, when any processor needs to drive the serial port printing module, it needs to first obtain the status of the spin lock. Only after the spin lock is in the unlocked state can the processor occupy the serial port printing module.

[0050] In this example, a lock_flag flag, i.e., a locked flag, is added to each processor of the multi-core system, with a default value of FALSE (i.e., the first numerical value). When the spin lock is in the unlocked state and the processor is driving the serial port printing module, the value of the locked flag will be first determined. If it is FALSE, it means that the processor has not yet locked the spin lock. At this time, the processor will perform a locking operation, lock the spin lock, and assign the value of the locked flag to a second numerical value, which is configured to TRUE in this example. After locking, the processor can start to use the serial port printing module to print serial port information, and after completing the printing of the serial port information, release the spin lock and reassign lock_flag to FALSE.

[0051] If the processor is interrupted by the interrupt service program during the printing of the processor's serial port information, and the interrupt service program also needs to print, then in response to the interrupt service program, the value of the lock flag will be judged first. If lock_flag is equal to TRUE, it means that the processor has completed the locking of the spin lock. At this time, there is no need to lock it again. Instead, the serial port information that the interrupt service program needs to print is directly output through the serial port printing module. During this process, the processor will first be interrupted to print a part of the serial port information, and the serial port information that the interrupt service program needs to print will be inserted. After the serial port information of the interrupt service program is printed, the remaining serial port information that the processor needs to print will continue to be printed. Through the above scheme, the processor can respond to the interrupt information of the interrupt service program in a timely manner during the printing process, and since there is no need to lock the spin lock again when printing the interrupt information of the interrupt service program, deadlock problems will not occur.

[0052] However, according to the above solution, since the interrupt service routine's print information is inserted when printing the processor's serial port information, the information ultimately printed by the serial port printing module is relatively chaotic, making it impossible to accurately obtain the required print information. To this end, in this example, breakpoint markers are added between the serial port information before and after each interrupt. Through the breakpoint markers, it is possible to accurately distinguish which print information belongs to the processor's serial port information and which print information belongs to the interrupt service routine's serial port information. Ultimately, the serial port information corresponding to the processor and each interrupt service routine can be distinguished and spliced.

[0053] Therefore, according to the serial port printing method based on a multi-core system in an embodiment of the present invention, it is possible to not prohibit responding to interrupts during the period when the spin lock is locked, thereby improving the timeliness of responding to interrupts and supporting printing with nested interrupts. At the same time, a mechanism for avoiding deadlock is added. Before preparing to acquire the lock, it is first determined whether the current processor is already locked. If so, the serial port print is directly output; otherwise, normal locking is performed before outputting the print. In order to avoid confusion caused by inserting new serial port print information due to interruptions during normal printing, breakpoint markers are added before and after the inserted print information to improve readability.

[0054] Furthermore, in some embodiments of the present invention, the above-mentioned step S400: during the printing process, if the processor responds to the interrupt service routine, the serial port printing module interrupts the printing of the processor's serial port information, inserts the serial port information corresponding to each interrupt service routine at each interruption, and then continues to print the processor's serial port information, and adds a breakpoint mark between the serial port information before and after each interruption, includes the following four steps:

[0055] Step S410: Count the number of times the processor responds to the interrupt service routine, and add 1 to the count value each time the serial port information of the interrupt service routine is inserted; the initial value of the count value is 0;

[0056] Step S420: Add a first breakpoint identifier before each inserted serial port information;

[0057] Step S430: adding a second breakpoint identifier after each inserted serial port information; the first breakpoint information and the second breakpoint information both include a count value corresponding to the inserted serial port information;

[0058] Step S440: After each piece of serial port information is printed, the count value is reduced by 1.

[0059] It should be noted that during the processor's printing process, more than one interrupt signal may be received, triggering multiple interrupts. Therefore, the processor counts the number of times it responds to the interrupt service routine, incrementing the count by 1 each time the interrupt service routine's serial port information is inserted. Furthermore, a first breakpoint identifier and a second breakpoint identifier are added before and after each inserted serial port information, respectively. For example, after printing part of the processor's serial port information, the first interrupt is triggered. A count of 1 is placed before the serial port information corresponding to the first interrupt. If a second interrupt is triggered while printing the serial port information for the first interrupt, a count of 2 is placed before the serial port information corresponding to the second interrupt. After printing the serial port information for the second interrupt, a count of 2 is also placed after the serial port information for the second interrupt. The count is then decremented to 1, and the remaining serial port information for the first interrupt is printed. The count of 1 is then placed after the first interrupt's serial port information, and the remaining serial port information for the processor is printed. Breakpoint identifiers enable accurate distinction between different serial port information.

[0060] Furthermore, in this example, the first breakpoint identifier includes a first special character, a corresponding count value, a second special character, and a line break character; the second breakpoint identifier includes a line break character, a first special character, a corresponding count value, and a second special character. The first special character may be "{" and the second special character may be "}", or the first special character may be "(" and the second special character may be ")". It should be noted that the first special character and the second special character may also be other symbols. The following example illustrates the printing method of this embodiment:

[0061] Assume that the main process serial port information that the processor needs to print is: HelloWorld!!!

[0062] The first interruption should print: there is the firstinterrupt server.

[0063] Nested second interrupt prints: there is the secondinterrupt server.

[0064] Assume that the first special character char1 is "{" and the second special character char2 is "}".

[0065] For example:

[0066] There is no effect of the breakpoint identification mechanism: Hellthere is the fithere is the secondinterrupt server.rstinterrupt server.oWorld!!!

[0067] The effect of the breakpoint identification mechanism has been increased:

[0068] Hell{1}

[0069] thereis the fi{2}

[0070] thereis the secondinterrupt server.

[0071] {2}rstinterrupt server.

[0072] {1}oWorld!!!

[0073] From the above results, we can see that the information between {2} is the second interruption information, the information between {1} is the first interruption information, and the remaining information is the main process print information. This breakpoint identification mechanism can avoid the confusion caused by interruptions during normal printing and inserting new serial port print information. Adding breakpoint identifiers before and after the inserted print information improves readability.

[0074] Furthermore, in some embodiments of the present invention, the above-mentioned step S600: distinguishing and splicing serial port information corresponding to the processor and each interrupt service routine according to the breakpoint identifier includes the following three steps:

[0075] Step S610: Acquire all serial port information printed by the serial port printing module, and determine a first breakpoint identifier and a second breakpoint identifier having the same count value;

[0076] Step S620: Separate serial port information between the first breakpoint identifier and the second breakpoint identifier having the same count value in descending order of the count value, and use the serial port information of the corresponding interrupt service program;

[0077] Step S630: concatenate the remaining serial port information into the serial port information of the processor.

[0078] Specifically, this application adds a breakpoint serial port information repair tool that can splice the broken serial port information together by recognizing special characters and numbers. Still taking the above example, assuming that all the serial port information finally printed by the serial port printing module is:

[0079] Hell{1}

[0080] thereis the fi{2}

[0081] thereis the secondinterrupt server.

[0082] {2}rstinterrupt server.

[0083] {1}oWorld!!!

[0084] Then, in descending order of count values, they are {2} and {1}. First, looking at the information between the two {2}, we can see that "there is the second interrupt server." is the print information of the second interrupt. After separating it, the remaining information is:

[0085] Hell{1}

[0086] thereis the firstinterrupt server.

[0087] {1}oWorld!!!

[0088] By looking at the information between the two {1}, we can see that "there is the firstinterruptserver." is the print information of the first interrupt. After separating it, the remaining information is "Hello World!!!". From this, we can distinguish and piece together the serial port information corresponding to the processor and each interrupt.

[0089] Through the above solution, interrupt nested printing is supported, and the processor and serial port information corresponding to each interrupt can be accurately distinguished, ensuring that the final printed information is accurate and will not be confused.

[0090] The specific process of the serial port printing method based on a multi-core system according to the embodiment of the present invention is as follows: Figure 2 shown.

[0091] Furthermore, in some embodiments of the present application, after the above step S100: when any processor drives the serial port printing module, obtaining the state of the spin lock, the following two steps are also included:

[0092] When the spin lock is in the locked state, the processor pauses printing and puts it in the waiting queue;

[0093] When the spin lock is changed from a locked state to an unlocked state, the printing tasks of the processors in the waiting queue are executed in sequence through the serial port printing module according to the priorities of the processors in the waiting queue.

[0094] It should be noted that if a certain processor needs to call the serial port print module to print, then the state of spin lock will be checked first, if find that spin lock is already in locked state, then illustrate that other processor has been occupied serial port print module, at this moment, this processor can't call the serial port print module, only have to wait for a last processor to finish printing and after spin lock is unlocked, just can call the serial port print module.If during one of them processor occupies serial port print module, there are other multiple processors all to call serial port print module, can be placed in waiting queue according to the print priority of these processors, after serial port print module is discharged, can process the print task of each processor in the waiting queue successively according to the print priority.If find that spin lock is not in locked state, then can proceed to above-mentioned step S200-step S600.

[0095] It should be noted that in this example, the spin lock is configured with a status flag that indicates the locked state of the spin lock. Each processor can query whether the spin lock is locked or unlocked based on the status flag, thereby preventing multiple processors from calling the serial port printing module simultaneously.

[0096] According to the serial port printing method based on a multi-core system in an embodiment of the present invention, in a system that uses a spin lock to protect serial port printing, it can support the printing function of the interrupt service program without blocking interrupts, support interrupt nested printing, and can realize the marking and repair of breakpoint information, thereby improving the timeliness of interrupt response.

[0097] On the other hand, an embodiment of the present application further provides a serial port printing system based on a multi-core system, comprising:

[0098] The processor may be implemented as a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0099] The memory can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory and is called by the processor to execute the serial port printing method based on a multi-core system in the embodiments of this application.

[0100] Input / output interface, used to realize information input and output;

[0101] Communication interface, used to realize communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, Wi-Fi, Bluetooth, etc.);

[0102] The bus transmits information between the various components of the device (such as the processor, memory, input / output interfaces, and communication interfaces);

[0103] The processor, memory, input / output interface and communication interface are connected to each other through a bus within the device.

[0104] On the other hand, an embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned serial port printing system based on the multi-core system.

[0105] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory 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 embodiments, the memory optionally includes a memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of the above-mentioned networks include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0106] Although specific embodiments are described herein, those skilled in the art will recognize that many other modifications or alternative embodiments are also within the scope of this disclosure. For example, any of the functions and / or processing capabilities described in conjunction with a particular device or component may be performed by any other device or component. In addition, although various exemplary implementations and architectures have been described in accordance with embodiments of the present disclosure, those skilled in the art will recognize that many other modifications to the exemplary implementations and architectures described herein are also within the scope of this disclosure.

[0107] Some aspects of the present disclosure have been described above with reference to the block diagrams and flow charts of the systems, methods, systems and / or computer program products according to the exemplary embodiments. It should be understood that the combination of one or more blocks in the block diagram and the flow chart and the blocks in the block diagram and the flow chart can be realized by executing computer executable program instructions respectively. Equally, according to some embodiments, some blocks in the block diagram and the flow chart may not need to be executed in the order shown, or may not need to be executed in full. In addition, additional components and / or operations beyond those components and / or operations shown in the blocks in the block diagram and the flow chart may be present in certain embodiments.

[0108] Therefore, the blocks in the block diagrams and flow charts support combinations of means for performing the specified functions, combinations of elements or steps for performing the specified functions, and program instruction means for performing the specified functions. It should also be understood that each block in the block diagrams and flow charts, and combinations of blocks in the block diagrams and flow charts, can be implemented by a dedicated hardware computer system that performs the specific functions, elements, or steps, or a combination of dedicated hardware and computer instructions.

[0109] The program modules, applications, etc. described herein may include one or more software components, including, for example, software objects, methods, data structures, etc. Each such software component may include computer-executable instructions that, in response to execution, cause at least a portion of the functionality described herein (e.g., one or more operations of the illustrative methods described herein) to be performed.

[0110] Software component can be encoded with any one in various programming languages.A kind of exemplary programming language can be low-level programming language, such as the assembly language associated with specific hardware architecture and / or operating system platform.Comprise that the software component of assembly language instruction may need to be converted to executable machine code by assembler before being executed by hardware architecture and / or platform.Another exemplary programming language can be a more advanced programming language, and it can be transplanted across multiple architectures.Comprise that the software component of more advanced programming language may need to be converted to intermediate representation by interpreter or compiler before execution.Other examples of programming language include but are not limited to macro language, shell or command language, job control language, script language, database query or search language or report writing language.In one or more exemplary embodiments, the software component that comprises the instruction of one in the above-mentioned programming language example can be directly executed by operating system or other software component, without first being converted into another form.

[0111] Software components can be stored as files or other data storage structures. Software components of similar types or related functions can be stored together, such as in a specific directory, folder, or library. Software components can be static (e.g., preset or fixed) or dynamic (e.g., created or modified at execution time).

[0112] The embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in the relevant technical field without departing from the scope of the present invention.

Claims

1. A serial port printing method based on a multi-core system, characterized in that: The multi-core system has multiple processors, the multiple processors share a serial port printing module, the serial port printing module is configured with a spin lock, each processor is respectively configured with a lock flag, and the initial value of the lock flag is a first value; the method includes: When any of the processors drives the serial port printing module, obtaining the state of the spin lock; When the spin lock is in an unlocked state and the value of the lock flag of the processor is the first value, locking the spin lock and assigning the value of the lock flag to a second value; Printing the serial port information corresponding to the processor through the serial port printing module; During the printing process, if the processor responds to the interrupt service routine, the serial port printing module interrupts the printing of the serial port information of the processor, inserts the serial port information corresponding to each interrupt service routine at each interruption, and then continues to print the serial port information of the processor, and adds a breakpoint mark between the serial port information before and after each interruption; When the serial port information of the processor is finished printing, unlocking the spin lock and assigning the value of the lock flag to the first value; According to the breakpoint identifier, the serial port information corresponding to the processor and each of the interrupt service routines is distinguished and spliced.

2. The serial port printing method based on a multi-core system according to claim 1, characterized in that: During the printing process, if the processor responds to the interrupt service routine, the serial port printing module interrupts the printing of the serial port information of the processor, inserts the serial port information corresponding to each interrupt service routine at each interruption, and then continues to print the serial port information of the processor, and adds a breakpoint mark between the serial port information before and after each interruption, including: Counting the number of times the processor responds to the interrupt service program, and adding 1 to the count value each time the serial port information of the interrupt service program is inserted; the initial value of the count value is 0; Add the first breakpoint identifier before each inserted serial port information; Adding a second breakpoint identifier after each inserted serial port information; the first breakpoint information and the second breakpoint information both include the count value corresponding to the inserted serial port information; Each time a piece of serial port information is printed, the count value is reduced by 1.

3. The serial port printing method based on a multi-core system according to claim 2, characterized in that: The first breakpoint identifier includes a first special character, the corresponding count value, a second special character and a line feed character; the second breakpoint identifier includes the line feed character, the first special character, the corresponding count value and the second special character.

4. The serial port printing method based on a multi-core system according to claim 2, characterized in that: The distinguishing and splicing the serial port information corresponding to the processor and each interrupt service routine according to the breakpoint identifier includes: Acquire all serial port information printed by the serial port printing module, and determine the first breakpoint identifier and the second breakpoint identifier having the same count value; Separating serial port information between the first breakpoint identifier and the second breakpoint identifier having the same count value in descending order of the count value as serial port information of the corresponding interrupt service program; The remaining serial port information is spliced ​​into the serial port information of the processor.

5. The serial port printing method based on a multi-core system according to claim 1, characterized in that: After the step of obtaining the state of the spin lock when any of the processors drives the serial port printing module, the method further includes: When the spin lock is in a locked state, the processor is placed in a waiting queue, waiting for the spin lock to be in an unlocked state; When the spin lock is changed from a locked state to an unlocked state, the printing tasks of the processors in the waiting queue are executed in sequence through the serial port printing module according to the priorities of the processors in the waiting queue.

6. The serial port printing method based on a multi-core system according to claim 1, characterized in that: The first value is FALSE, and the second value is TRUE.

7. The serial port printing method based on a multi-core system according to claim 1, characterized in that: The spin lock is configured with a status flag, and the status flag is used to represent the locked state of the spin lock.

8. A serial port printing system based on a multi-core system, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute the serial port printing method based on a multi-core system as described in any one of claims 1 to 7.

9. An electronic device, characterized in that: Including the serial port printing system based on a multi-core system as described in claim 8.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the serial port printing method based on a multi-core system according to any one of claims 1 to 7.