Abstract:
A method, an apparatus, and a system for mutual communication between processes of a many-core processor are provided that relate to the field of many-core operating systems The method is executed by a target kernel, where the target kernel corresponds to a target processor core. The method includes acquiring a message header of a message from a quick message channel (QMC); executing a central processing unit (CPU) pre-fetching command according to the message header, so that a message body that is in the message stored in a shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core; and switching to a target process, so that the target process acquires the message body from the cache. The embodiments of the present invention apply to a scenario of mutual communication between processes of a many-core processor.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application is a continuation of International Application No. PCT/CN2013/074709, filed on Apr. 25, 2013, which claims priority to Chinese Patent Application No. 201210505157.0, filed on Nov. 30, 2012, both of which are hereby incorporated by reference in their entireties. 
     
    
     TECHNICAL FIELD 
       [0002]    The present invention relates to the field of many-core operating systems, and in particular to a method, an apparatus, and a system for mutual communication between processes of a many-core processor. 
       BACKGROUND 
       [0003]    With rapid development of mobile communication technologies, people have an increasingly-urgent requirement for high performance, high speed, and low delay of a communication system, and therefore raise an increasingly-higher requirement for a processor of an electronic device. The processor of an electronic device has developed from single-core to multiple-core and then to many-core. A many-core processor uses a non-cache-coherent architecture and a multi-kernel operating system (multi-kernel OS). Various processes of a many-core processor communicate with each other by means of message transmission. 
         [0004]    In the prior art, inter-core communication is implemented by a shared memory, polling, and Inter-Process Interrupt (IPI) on a non-cache-coherent many-core processor platform. A shared memory is split into multiple blocks that have a same size as a cache line. A transmit end places a message body into the shared memory, places a channel identifier (channel ID) that includes memory address information into a Message Passing Buffer (MPB), and instructs a receive end through the IPI to obtain the channel ID from the MPB. Finally, a user-layer application at the receive end reads the message body from the shared memory. 
         [0005]    In the process of implementing the foregoing inter-core communication, the inventor has discovered that the prior art at least has the following problem. The user-layer application needs to read the message body from the shared memory, thereby decreasing the speed of reading the message body and degrading user experience. 
       SUMMARY 
       [0006]    Embodiments of the present invention provide a method, an apparatus, and a system for mutual communication between processes of a many-core processor, so as to increase the speed of reading a message body and enhance user experience. 
         [0007]    The embodiments of the present invention provide the following technical solutions to attain the foregoing objectives. 
         [0008]    According to a first aspect, an embodiment of the present invention provides a method for mutual communication between processes of a many-core processor, where the method is executed by a target kernel, the target kernel corresponds to a target processor core, and the method includes acquiring a message header of a message from a quick message channel (QMC); executing a central processing unit (CPU) pre-fetching command according to the message header, so that a message body that is in the message stored in a shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core; and switching to a target process, so that the target process acquires the message body from the cache. 
         [0009]    In a first possible implementation manner, the message header includes a start address of the message body stored in the shared memory and a size of the message body, where the start address and the size of the message body are used to indicate the message body stored in the shared memory; or the message header includes a start address and an end address of the message body stored in the shared memory, where the start address and the end address are used to indicate the message body stored in the shared memory. 
         [0010]    In a second possible implementation manner, with reference to the first aspect or the first possible implementation manner of the first aspect, the message header includes identity information, where the identity information is used to identify that the message body of the message is transmitted through the QMC. 
         [0011]    In a third possible implementation manner, with reference to the second possible implementation manner of the first aspect, before executing the CPU pre-fetching command according to the message header, the method further includes detecting whether the message header includes the identity information; and executing the CPU pre-fetching command according to the message header includes executing the CPU pre-fetching command according to the message header if it is detected that the message header does not include the identity information. 
         [0012]    In a fourth possible implementation manner, with reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, or the third possible implementation manner of the first aspect, the message header includes a first target process identity used to identify the target process that corresponds to the message header; before acquiring the message header of the message from the QMC, the method further includes receiving a first interrupt triggering signal sent by a source kernel; performing first interrupt processing according to the first interrupt triggering signal, and in the process of performing the first interrupt processing, reading the message header from the QMC and placing, according to the first target process identity in the message header, the message header into a message receiving queue corresponding to the target process; and performing process scheduling after exiting the first interrupt processing; and acquiring the message header of the message from the QMC includes acquiring the message header from the message receiving queue corresponding to the target process when the target process is being scheduled. 
         [0013]    In a fifth possible implementation manner, with reference to the third possible implementation manner of the first aspect, the method includes switching to the target process if it is detected that the message header includes the identity information, so that the target process acquires, from the QMC, the message body corresponding to the message header in the message. 
         [0014]    In a sixth possible implementation manner, with reference to the fifth possible implementation manner of the first aspect, the message header further includes a second target process identity; before acquiring the message header of the message from the QMC, the method includes receiving a second interrupt triggering signal sent by the source kernel; performing second interrupt processing according to the second interrupt triggering signal, and in the process of performing the second interrupt processing, reading the message header and the message body from the QMC and placing, according to the second target process identity in the message header, the message header and the message body into a message receiving queue corresponding to the target process; and performing process scheduling after exiting the second interrupt processing; and switching to the target process if it is detected that the message header includes the identity information, so that the target process acquires, from the QMC, the message body corresponding to the message header in the message includes, if it is detected that the message header includes the identity information, switching to the target process when the target process is being scheduled, so that the target process acquires the message body from the message receiving queue that corresponds to the target process. 
         [0015]    In a seventh possible implementation manner of the first aspect, with reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, or the sixth possible implementation manner of the first aspect, the message body is sent by a source processor core by using the following method detecting whether the size of the message body is greater than the maximum payload that can be sent by the QMC; and if it is detected that the size of the message body is greater than the maximum payload that can be sent by the QMC, storing, by the source processor core, the message body into the shared memory; and storing, by the source kernel, information that is used to indicate the message body of the message stored in the shared memory as the message header into the QMC, and sending to the target kernel; if it is detected that the size of the message body is not greater than the maximum payload that can be sent by the QMC, storing, by the source kernel, the message body of the message into the QMC; and storing information that is used to indicate the message body of the message stored in the QMC as the message header into the QMC, and sending to the target kernel. 
         [0016]    According to a second aspect, an embodiment of the present invention provides a many-core processor, including a source processor core and a target processor core, where the target processor core runs a target kernel and the target kernel includes an acquiring unit configured to acquire a message header of a message from a QMC; a command pre-fetching unit configured to execute a CPU pre-fetching command according to the message header acquired by the acquiring unit, so that a message body, of the message, that is stored in a shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core; and a process switching unit configured to switch to a target process after the command pre-fetching unit executes the CPU pre-fetching command, so that the target process acquires the message body from the cache. 
         [0017]    According to a third aspect, an embodiment of the present invention provides a many-core processor system, including a source processor core, a target processor core, and a memory, where the memory is configured to store codes that are run by the source processor core and the target processor core; the target processor core is configured to read the codes stored in the memory, so that a target kernel executes the following method by running a kernel program: acquiring a message header of a message from a QMC; executing a CPU pre-fetching command according to the message header, so that a message body that is in the message stored in a shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core; and switching to a target process, so that the target process acquires the message body from the cache. 
         [0018]    The embodiments of the present invention provide a method, an apparatus, and a system for mutual communication between processes of a many-core processor. A target kernel of a target processor core acquires a message header from a QMC; executes, according to the acquired message header, a CPU pre-fetching command, instructing to load a message body to a cache that corresponds to the target processor core; and switches to a target process, so that the target process acquires the message body from the cache. In this way, during communication between processes, the message body is loaded to the cache, so that the target process may directly acquire the message body from the cache without the need of accessing a shared memory to acquire the message body, thereby increasing the speed of reading the message body and enhancing user experience. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0019]    To illustrate the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments. The accompanying drawings in the following description show merely some embodiments of the present invention, and a person of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts. 
           [0020]      FIG. 1  is a schematic diagram of a method for mutual communication between processes of a many-core processor according to an embodiment of the present invention; 
           [0021]      FIG. 2  is a schematic diagram of another method for mutual communication between processes of a many-core processor according to an embodiment of the present invention; 
           [0022]      FIG. 3  is a schematic diagram of another method for mutual communication between processes of a many-core processor according to an embodiment of the present invention; 
           [0023]      FIG. 4  is a schematic diagram of another method for mutual communication between processes of a many-core processor according to an embodiment of the present invention; 
           [0024]      FIG. 5  is a schematic structural diagram of a many-core processor according to an embodiment of the present invention; 
           [0025]      FIG. 6  is a schematic structural diagram of a target kernel shown in  FIG. 5 ; 
           [0026]      FIG. 7  is another schematic structural diagram of a target kernel shown in  FIG. 5 ; 
           [0027]      FIG. 8  is another schematic structural diagram of a target kernel shown in  FIG. 5 ; 
           [0028]      FIG. 9  is another schematic structural diagram of a target kernel shown in  FIG. 5 ; 
           [0029]      FIG. 10  is a schematic structural diagram of a source processor core shown in  FIG. 5 ; and 
           [0030]      FIG. 11  is a schematic structural diagram of a many-core processor system according to an embodiment of the present invention. 
       
    
    
     DETAILED DESCRIPTION 
       [0031]    The following clearly and completely describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. The described embodiments are merely a part rather than all of the embodiments of the present invention. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention. 
         [0032]    An embodiment of the present invention provides a method for mutual communication between processes of a many-core processor. The method is executed by a target kernel, where the target kernel corresponds to a target processor core. As shown in  FIG. 1 , the method includes the following steps. 
         [0033]      101 . Acquire a message header of a message from a QMC. 
         [0034]    If a source kernel of the processor stores a message body of a message into a shared memory, the message header of the message is used to indicate the message body stored in the shared memory. In this case, the message header of the message includes a start address of the message body and a size of the message body stored in the shared memory, where the start address and the size of the message body are used to indicate the message body stored in the shared memory. 
         [0035]    Optionally, the message header of the message includes a start address and an end address of the message body stored in the shared memory, where the start address and the end address are used to indicate the message body stored in the shared memory. 
         [0036]    It should be noted that the message header may use other methods to indicate the message body stored in the shared memory, which is not restricted in the present invention. 
         [0037]    Further, the message header further includes a first target process identity. 
         [0038]    The first target process identity is used to identify the target process that corresponds to the message header. 
         [0039]    It should be noted that each process has a corresponding process identity in all the embodiments of the present invention. 
         [0040]    It should be noted that the target kernel is in a kernel state when the target kernel acquires the message header of the message from the QMC. 
         [0041]      102 . Execute a CPU pre-fetching command according to the message header, so that the message body that is in the message stored in a shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core. 
         [0042]    After the target kernel acquires the message header of the message, if the message header includes the start address of the message body and the size of the message body stored in the shared memory, the target kernel executes the CPU pre-fetching command according to the start address of the message body and the size of the message body stored in the shared memory, so that the target kernel loads the message body of the message from the shared memory to the cache that corresponds to the target processor core. 
         [0043]    If the message header includes the start address and the end address of the message body stored in the shared memory, the target kernel executes the CPU pre-fetching command according to the start address and the end address of the message body stored in the shared memory, so that the target kernel loads the message body of the message from the shared memory to the cache that corresponds to the target processor core. 
         [0044]      103 . Switch to the target process, so that the target process acquires the message body from the cache. 
         [0045]    The target kernel switches to the target process after the target kernel executes the CPU pre-fetching command; optionally, when the message body is loaded to the cache that corresponds to the target processor core, the target kernel switches to the target process simultaneously, so that the target process acquires the message body from the cache. 
         [0046]    Further, that the target kernel switches to the target process includes that the target kernel switches from a kernel state to a user state. 
         [0047]    This embodiment of the present invention provides a method for mutual communication between processes of a many-core processor. A target kernel of a target processor core acquires a message header from a QMC; executes, according to the acquired message header, a CPU pre-fetching command, instructing to load a message body to a cache that corresponds to the target processor core; and switches to a target process, so that the target process acquires the message body from the cache. In this way, during communication between processes, the message body is loaded to the cache, so that the target process may directly acquire the message body from the cache without the need of accessing a shared memory to acquire the message body, thereby increasing the speed of reading the message body and enhancing user experience. 
         [0048]    An embodiment of the present invention provides a method for mutual communication between processes of a many-core processor. The method is executed by a target kernel and a source kernel, where the target kernel corresponds to a target processor core and the source kernel corresponds to a source processor core. The method includes the following steps. 
         [0049]      201 . A first process of the source processor core invokes a library function in an MsgLib to send a message. 
         [0050]    When the first process needs to send a message to a target process of the target processor core, the first process needs to invoke the library function in the MsgLib. 
         [0051]    It should be noted that there are two methods for the source processor core to send a message to the target processor core. One is that the library function in the MsgLib of the source processor core does not detect a size of a message body of the message but directly stores the message body of the message into a shared memory, so that the target kernel acquires the message body of the message through the shared memory. If the source processor core uses this method, steps  202   a ,  203  to  206 , and  208   b  to  209   b  are executed, as shown in  FIG. 2  and  FIG. 3 . A second method is that the library function in the MsgLib of the source processor core detects the size of the message body of the message and stores the message body of the message according to a detection result. If the source processor core uses the second method, steps  202   b ,  203  to  207 , and  208   a  are executed, or steps  202   b ,  203  to  207 , and  208   b  to  209   b  are executed, as shown in  FIG. 4  and with reference to  FIG. 3 . 
         [0052]      202   a . The library function in the MsgLib of the source processor core stores the message body of the message into the shared memory, and switches the source processor core to a kernel state. 
         [0053]    After the library function in the MsgLib of the source processor core stores the message body of the message into the shared memory. The source processor core is switched from a user state to the kernel state by means of system invocation, and then the source kernel is accessed. 
         [0054]      202   b . The library function in the MsgLib of the source processor core detects whether the size of the message body is greater than the maximum payload that can be sent by the QMC, and switches the source processor core to the kernel state. 
         [0055]    The maximum payload that can be sent by the QMC is preset. The maximum payload that can be sent by the QMC may be preset by using three methods, which are described as follows. 
         [0056]    It should be noted that the many-core processor that implements communication between processes includes at least two processor cores. A determining processor core is a first processor core that is enabled after the many-core processor is started, may be the source processor core or the target processor core. After determining the maximum payload that can be sent by the QMC, the determining processor core sends, to another processor core, the determined maximum payload that can be sent by the QMC. 
         [0057]    A first method of determining, by the determining processor core, the maximum payload that can be sent by the QMC is as follows. 
         [0058]    The determining processor core determines that the amount of transmitted data of the QMC is equal to a size of a Cache Line; and then determines the maximum payload, which can be sent by the QMC, by using a formula S payload =S cache −S addr −S size −S dstp , where S cache  indicates bytes occupied by the amount of transmitted data of the QMC, S addr  indicates bytes occupied by a start address of the shared memory, S size  indicates bytes occupied by the size of the message body of the message, S dstp  indicates bytes occupied by a target process identity, and S payload  indicates bytes occupied by the maximum payload that can be sent by the QMC. In this case, the number of QMCs included in the determining processor core is S T /S cache , where S T  is the number of bytes carried on a first channel. The first channel is a channel allocated to each processor core to transmit a message body. 
         [0059]    It should be noted that the first channel is split into S T /S cache  QMCs in the preceding process. 
         [0060]    It should be noted that one QMC is used during each time of message transmission in all embodiments of the present invention. 
         [0061]    For example, it is assumed that the number of bytes carried on the first channel is 8 k, a size of the Cache Line is 32 bytes, Address occupies 5 bytes, the size of the message body occupies 1 byte, and the target process identity occupies 2 bytes. Then, the maximum payload that can be sent by the QMC is calculated as 24 bytes according to the formula S payload =S cache −S addr −S size −S dstp ; and the determining processor core may use S T /S cache =8 k/32=256 QMCs. That is, the first channel is split into 256 QMCs. 
         [0062]    A second method of determining, by the determining processor core, the maximum payload that can be sent by the QMC is as follows. 
         [0063]    The determining processor core determines the amount of transmitted data of the QMC according to a formula 
         [0000]    
       
         
           
             
               
                 S 
                 chanel 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       S 
                       T 
                     
                     
                       
                         ( 
                         
                           N 
                           - 
                           1 
                         
                         ) 
                       
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             ; 
           
         
       
     
         [0000]    and then, determines the maximum payload, which can be sent by the QMC, by using a formula S payload =S chanel −S addr −S size −S dstp . 
         [0064]    S T  indicates the number of bytes carried on a first channel; the first channel is a channel allocated to each processor core of the many-core processor to transmit a message body; N−1 indicates the number of QMCs; and S cache  indicates bytes occupied by a Cache Line. 
         [0065]    It should be noted that in this method, the many-core processor that implements communication between processes has at least two processor cores, so that one QMC is shared between every two processor cores. If the many-core processor has N processor cores, there are N−1 QMCs. 
         [0066]    For example, if N is 48, the number of QMCs is 47, a size of the Cache Line is 32 bytes, Addr occupies 5 bytes, the size of the message body occupies 1 byte, a target process identity occupies 2 bytes, and the number of bytes carried on the first channel is 8192. Then, the amount of transmitted data of the QMC is determined as 160 bytes according to the formula 
         [0000]    
       
         
           
             
               
                 S 
                 chanel 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       S 
                       T 
                     
                     
                       
                         ( 
                         
                           N 
                           - 
                           1 
                         
                         ) 
                       
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             ; 
           
         
       
     
         [0000]    and the maximum payload that can be sent by the QMC is determined as 152 bytes by using the formula S payload =S chanel −S addr −S size −S dstp . 
         [0067]    A third method of determining, by the determining processor core, the maximum payload that can be sent by the QMC is as follows. 
         [0068]    The determining processor core splits a first channel into a part used for inter-kernel communication and a part used for inter-program communication; determines the amount of transmitted data of a QMC, which is used for the inter-kernel communication, according to a formula 
         [0000]    
       
         
           
             
               
                 S 
                 
                   chanel 
                    
                   
                       
                   
                    
                   1 
                 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       
                         S 
                         T 
                       
                       * 
                       
                         P 
                         kernel 
                       
                     
                     
                       
                         ( 
                         
                           n 
                           - 
                           1 
                         
                         ) 
                       
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             ; 
           
         
       
     
         [0000]    and determines a maximum payload, which can be sent by a QMC used for the inter-kernel communication, according to a formula S payload =S chanel1 −S addr −S size −S dstp , where P kernel  indicates a percentage of QMCs, used for the inter-kernel communication, of the determining processor core among QMCs of the first channel, and N−1 indicates the number of QMCs used for the inter-kernel communication. 
         [0069]    Further, in this method, a manner of determining the number of QMCs for the inter-kernel communication is that one QMC is shared between every two processor cores when the many-core processor that implements communication between processes has at least two processor cores. For example, if the many-core processor has N processor cores, there are N−1 QMCs. 
         [0070]    The determining processor core determines the amount of transmitted data of a QMC, used for the inter-program communication, of the determining processor core according to a formula 
         [0000]    
       
         
           
             
               
                 S 
                 
                   chanel 
                    
                   
                       
                   
                    
                   2 
                 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       
                         S 
                         T 
                       
                       * 
                       
                         ( 
                         
                           1 
                           - 
                           
                             P 
                             kernel 
                           
                         
                         ) 
                       
                     
                     
                       M 
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             ; 
           
         
       
     
         [0000]    and determines the maximum payload that can be sent by a QMC, used for the inter-program communication, of the determining processor core according to a formula S payload =S chanel2 −S addr −S size −S dstp , where M indicates the number of QMCs used for the inter-program communication. 
         [0071]    It should be noted that in this method both P kernel  and M are preset according to a requirement of a user. 
         [0072]    For example, if N is 48, the number of QMCs used for the inter-kernel communication is 47; if 50% of the first channel is used for the inter-kernel communication, P kernel  is 50%, a size of a Cache Line is 32 bytes, Addr occupies 5 bytes, the size of the message body occupies 1 byte, a target process identity occupies 2 bytes, and the number of bytes for the inter-kernel communication carried on the first channel is 8192. Then, the amount of transmitted data of a QMC used for the inter-kernel communication is determined as 64 bytes according to the formula 
         [0000]    
       
         
           
             
               
                 S 
                 
                   chanel 
                    
                   
                       
                   
                    
                   1 
                 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       
                         S 
                         T 
                       
                       * 
                       
                         P 
                         kernel 
                       
                     
                     
                       
                         ( 
                         
                           N 
                           - 
                           1 
                         
                         ) 
                       
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             ; 
           
         
       
     
         [0000]    and the maximum payload that can be sent by a QMC used for the inter-kernel communication is determined as 56 bytes according to the formula S payload =S chanel1 −S addr −S size −S dstp . 
         [0073]    It is assumed that M is 4. Then, the amount of transmitted data of a QMC used for the inter-program communication is determined as 1024 bytes according to 
         [0000]    
       
         
           
             
               
                 S 
                 
                   chanel 
                    
                   
                       
                   
                    
                   2 
                 
               
               = 
               
                 
                   ⌊ 
                   
                     
                       
                         S 
                         T 
                       
                       * 
                       
                         ( 
                         
                           1 
                           - 
                           
                             P 
                             kernel 
                           
                         
                         ) 
                       
                     
                     
                       M 
                       * 
                       
                         S 
                         cache 
                       
                     
                   
                   ⌋ 
                 
                 * 
                 
                   S 
                   cache 
                 
               
             
             , 
           
         
       
     
         [0000]    and the maximum payload that can be sent by a QMC used for the inter-program communication is determined as 1016 bytes according to the formula S payload =S chanel2 −S addr −S size −S dstp . 
         [0074]    It should be noted that for the amount of data carried by first channels in at least two processor cores of the many-core processor that implements communication between processes is the same. 
         [0075]    It should be noted that the determining processor core may also use other methods to determine the maximum payload that can be sent by the QMC, which is not restricted in the present invention. 
         [0076]    After a first process invokes the library function in the MsgLib, the library function in the MsgLib detects whether the size of the message body of the message to be sent by the first process is greater than the maximum payload that can be sent by the QMC. 
         [0077]    If it is detected that the size of the message body of the message is greater than the maximum payload that can be sent by the QMC, the message body is stored into the shared memory. In addition, the source processor core is switched from the user state to the kernel state by means of system invoking, and then, the source kernel is accessed. 
         [0078]    Optionally, the message body is first written into a cache unit, and after all data of the message body is written into the cache unit, all the data of the message body in the cache unit is written into the shared memory. This can ensure that the message body read from the shared memory is complete and correct. 
         [0079]    It should be noted that all the data of the message body may also be directly written into the shared memory, and all the data of the message body may be written into the shared memory in other manners, which is not restricted in the present invention. 
         [0080]    Optionally, a size of the shared memory occupied by the message body is a first integer multiple of the size of a Cache Line, where the first integer is an integer greater than 0. 
         [0081]    If it is detected that the size of the message body of the message is not greater than the maximum payload that can be sent by the QMC, the source processor core is switched from the user state to the kernel state by means of system invoking, and then the source kernel is accessed. 
         [0082]      203 . The source kernel writes the message into the QMC. 
         [0083]    The source kernel processor executes step  202   a , or executes step  202   b . If it is detected in step  202   b  that the message body of the message is greater than the maximum payload that can be carried by the QMC, because the message body of the message is already stored in the shared memory, the source kernel only needs to store information of the message that is used to indicate the message body of the message stored in the shared memory as a message header into the QMC, and send to the target kernel. 
         [0084]    Optionally, the message header of the message includes a start address of the message body and the size of the message body stored in the shared memory, where the start address stored in the shared memory is not null, and the start address and the size of the message body are used to indicate the message body stored in the shared memory. 
         [0085]    Alternatively, the message header of the message includes a start address and an end address of the message body stored in the shared memory, where the start address and the end address are used to indicate the message body stored in the shared memory, and neither the start address nor the end address is null. 
         [0086]    It should be noted that the message header of the message may use other methods to indicate the message body stored in the shared memory, which is not restricted in the present invention. 
         [0087]    Further, the message header further includes a first target process identity. 
         [0088]    The first target process identity is used to identify the target process that corresponds to the message header. 
         [0089]    Further, the message header further includes first data of the message body, so that the target process detects whether the first data of the message body included in the message header is consistent with first data of the message body acquired from the cache; and executes the subsequent processing process of the message body if the two are consistent; may discard, instead of processing, the message body acquired from the cache if the two are inconsistent. 
         [0090]    If step  202   b  is executed and it is detected in step  202   b  that the message body of the message is not greater than the maximum payload that can be carried by the QMC, the source kernel stores the message body of the message into the QMC, stores the information that is used to indicate the message body of the message stored in the QMC as the message header into the QMC, and sends to the target kernel. That is, both the message header and the message body of the message are stored in the QMC. 
         [0091]    It should be noted that, in all embodiments of the present invention, if both the message header and the message body of a message are stored in the QMC, the message is called a small message. 
         [0092]    Optionally, the message header of the small message includes the size of the message body and identity information. 
         [0093]    The identity information is used to identify that the message body of the message is transmitted through the QMC. 
         [0094]    Optionally, the identity information includes information indicating that the start address stored in the shared memory is null. 
         [0095]    It should be noted that other information may also be used as the identity information. For example, the size of the message body may be set to a fixed value to serve as the identity information. The present invention is not limited thereto. 
         [0096]    Further, the message header of the small message further includes a second target process identity. 
         [0097]      204 . The source kernel sends an interrupt triggering signal to the target kernel of the target processor core to trigger the target kernel to perform interrupt processing, and the target kernel receives the interrupt triggering signal. 
         [0098]    The source kernel may determine, according to a target process identity carried in the message header of the message, the target processor core where the target kernel is located, and send the interrupt triggering signal to the target processor core. 
         [0099]    If the message body of the message is stored in the shared memory, the target process identity in the message header of the message is identified as a first target process identity. Then, the source kernel determines a first target processor core according to the first target process identity, and sends a first interrupt triggering signal to the first target processor core. In this case, a target kernel located in the first target processor core receives the first interrupt triggering signal. 
         [0100]    If the message body of the message is stored in the QMC, the target process identity in the message header of the message is identified as a second target process identity. Then, the source kernel determines a second target processor core according to the second target process identity, and sends a second interrupt triggering signal to the second target processor core. In this case, a target kernel located in the second target processor core receives the second interrupt triggering signal. 
         [0101]    It should be noted that the first interrupt triggering signal and the second interrupt triggering signal may be the same or may be different from each other, which is not restricted in the present invention. 
         [0102]      205 . The target kernel performs interrupt processing according to the interrupt triggering signal, and dumps the message stored in the QMC to a corresponding message receiving queue. 
         [0103]    The target kernel receives the interrupt triggering signal and performs the interrupt processing. In this case, the target processor core stops executing a current process, that is, it switches from the user state to the kernel state. 
         [0104]    If the interrupt triggering signal received by the target kernel is a first interrupt triggering signal, it indicates that the message body of the message is stored in the shared memory and the source kernel has stored the message header of the message into the QMC. The target kernel performs interrupt processing according to the first interrupt triggering signal, and in the process of performing first interrupt processing, reads the message header from the QMC and places, according to the first target process identity in the message header, the message header into the message receiving queue that corresponds to the target process. 
         [0105]    If the interrupt triggering signal received by the target kernel is a second interrupt triggering signal, it indicates that the message body of the message is stored in the QMC and the source kernel has stored both the message header and the message body of the message into the QMC. That is, the source kernel has stored a small message into the QMC. The target kernel performs second interrupt processing according to the second interrupt triggering signal, and in the process of performing the second interrupt processing, reads the message header and the message body from the QMC and places, according to the second target process identity in the message header, the message header and the message body as a small message into the message receiving queue that corresponds to the target process. 
         [0106]      206 . The target kernel performs process scheduling after exiting the interrupt processing. 
         [0107]    If the interrupt processing performed by the target kernel is first interrupt processing, the target kernel performs process scheduling after exiting the first interrupt processing; if the interrupt processing performed by the target kernel is second interrupt processing, the target kernel performs process scheduling after exiting the second interrupt processing. 
         [0108]    After the target kernel performs the process scheduling, if a currently scheduled process is the first process, of the source processor core, which is to send the message, that is, a target process is scheduled, the target kernel finds the message receiving queue of the target process and acquires the message header stored in the message receiving queue. 
         [0109]    It should be noted that if the currently scheduled process is not the first process, of the source processor core, which is to send the message, that is, if a third process is scheduled, the target kernel finds a message receiving queue of the third process and acquires the message header stored in the message receiving queue. The processing process is consistent with the processing process in which the target process is scheduled, and the following makes a description by using scheduling of the target process as an example. 
         [0110]      207 . The target kernel detects whether the message header includes the identity information. 
         [0111]    If the message body of the message is stored in the QMC, the message header of the message includes the identity information; if the message body of the message is stored in the shared memory, the message header of the message does not include the identity information. 
         [0112]    It should be noted that the following steps to be executed by the target kernel vary according to different results of the detection performed by the target kernel. If the target kernel detects that the message header includes the identity information, step  208   a  is executed; if the target kernel detects that the message header does not include the identity information, steps  208   b  to  209   b  are executed. 
         [0113]      208   a . The target kernel switches to the target process. 
         [0114]    If the target kernel detects that the message header includes the identity information, it indicates that the message body of the message is also transmitted to the target kernel through the QMC, and in step  205 , the message body is stored in the message receiving queue of the target process. 
         [0115]    If a process executed before the interrupt processing is the target process, the target kernel does not need to perform process switching, but only needs to switch from the kernel state to the user state, that is, the target kernel may switch to the target process, and the target process directly acquires the message body from the message receiving queue that corresponds to the target process. 
         [0116]    If a process executed before the interrupt processing is not the target process, the target kernel needs to execute a process switching program to switch to the target process, so that the target process directly acquires the message body from the message receiving queue that corresponds to the target process. 
         [0117]      208   b . The target kernel executes a CPU pre-fetching command according to the message header. 
         [0118]    When the target kernel does not execute step  207  or when step  207  is executed and the target kernel detects that the message header does not include the identity information, the target kernel executes the CPU pre-fetching command according to the message header, so that the message body is loaded to a cache that corresponds to the target processor core. 
         [0119]    If the message header includes the start address of the message body and the size of the message body stored in the shared memory, the target kernel executes the CPU pre-fetching command according to the start address of the message body and the size of the message body stored in the shared memory, so that the target kernel loads the message body, which is in the message stored in the shared memory and corresponds to the message header, from the shared memory to the cache that corresponds to the target processor core. 
         [0120]    If the message header includes the start address and the end address of the message body stored in the shared memory, the target kernel executes the CPU pre-fetching command according to the start address and the end address of the message body stored in the shared memory, so that the target kernel loads the message body, which is in the message stored in the shared memory and corresponds to the message header, from the shared memory to the cache that corresponds to the target processor core. 
         [0121]      209   b . Switch to the target process, so that the target process acquires the message body from the cache. 
         [0122]    The target kernel switches to the target process after the target kernel executes the CPU pre-fetching command; optionally, when the message body is loaded to the cache that corresponds to the target processor core, the target kernel switches to the target process simultaneously, so that the target process acquires the message body from the cache. 
         [0123]    If a process executed before the interrupt processing is the target process, the target kernel does not need to perform the process switching, but only needs to switch from the kernel state to the user state, that is, the target kernel may switch to the target process, and the target process acquires the message body from the cache. 
         [0124]    Optionally, when the message body is loaded to the cache that corresponds to the target processor core, the target kernel switches from the kernel state to the user state simultaneously, that is, switches to the target process. 
         [0125]    If a process executed before the interrupt processing is not the target process, the target kernel needs to execute a process switching program to switch to the target process, so that the target process acquires the message body from the cache. 
         [0126]    Optionally, when the message body is loaded to the cache that corresponds to the target processor core, the target kernel simultaneously executes the process switching program to switch to the target process. 
         [0127]    This embodiment of the present invention provides a method for mutual communication between processes of a many-core processor. A target kernel detects, according to a message header of a message, whether a corresponding message body is transmitted by a QMC. If it is not transmitted by the QMC, the target kernel learns that the message body is stored in a shared memory, executes, according to the acquired message header, a CPU pre-fetching command instructing to load the message body from the shared memory to a cache that corresponds to a target processor core, and switches to a target process, so that the target process acquires the message body from the cache. If the message body is transmitted directly by the QMC, the target kernel switches to the target process, so that the target process acquires the message from a message queue that corresponds to the target process. In this way, during communication between processes, the message body is loaded to the cache, so that the target process may directly acquire the message body from the cache without the need of accessing the shared memory to acquire the message body, thereby increasing the speed of reading the message body and enhancing user experience. In addition, when a size of the message body is not greater than the maximum payload that can be carried by the QMC, the message body is transmitted through the QMC, and then, the target kernel does not need to access the shared memory for transmission but directly acquires the message body from the QMC, thereby further increasing the speed of reading the message body and enhancing the user experience. 
         [0128]    An embodiment of the present invention provides a many-core processor. As shown in  FIG. 5 , the many-core processor includes a source processor core  401  and a target processor core  402 . The target processor core runs a target kernel  403 , and the source processor core  401  runs a source kernel  404 . As shown in  FIG. 6 , the target kernel includes an acquiring unit  4031  configured to acquire a message header of a message from a QMC, where optionally, the message header includes a start address of a message body and a size of the message body stored in a shared memory, and the start address and the size of the message body are used to indicate the message body stored in the shared memory; or the message header includes a start address and an end address of the message body stored in the shared memory, and the start address and the end address are used to indicate the message body stored in the shared memory; a command pre-fetching unit  4032  configured to execute a CPU pre-fetching command according to the message header acquired by the acquiring unit  4031 , so that the message body that is in the message stored in the shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core; and a process switching unit  4033  configured to switch to a target process after the command pre-fetching unit  4032  executes the CPU pre-fetching command, so that the target process acquires the message body from the cache. 
         [0129]    As shown in  FIG. 7 , the target kernel  403  further includes the following units. 
         [0130]    Optionally, the message header includes identity information, where the identity information is used to identify that the message body of the message is transmitted through the QMC. A first detecting unit  4034  configured to detect whether the message header includes the identity information. 
         [0131]    The command pre-fetching unit  4032  is configured to, when the first detecting unit  4034  detects that the message header does not include the identity information, execute the CPU pre-fetching command according to the message header acquired by the acquiring unit  4031 . 
         [0132]    Further, as shown in  FIG. 8 , the target kernel  403  further includes a first transceiver unit  4035  configured to receive a first interrupt triggering signal sent by the source kernel  404 ; and a first processing unit  4036  configured to perform first interrupt processing according to the first interrupt triggering signal received by the first transceiver unit  4035 . 
         [0133]    The message header further includes a first target process identity used to identify the target process that corresponds to the message header. 
         [0134]    The acquiring unit  4031  is configured to, when the first processing unit  4036  is performing the first interrupt processing, read the message header from the QMC and place, according to the first target process identity in the message header, the message header into a message receiving queue that corresponds to the target process. 
         [0135]    Further, when the message body of the message is stored in the shared memory, the message header further includes first data of the message body, so that the target process detects whether the first data of the message body included in the message header is consistent with first data of the message body acquired from the cache; and executes the subsequent processing process of the message body if the two are consistent; may discard, instead of processing, the message body acquired from the cache if the two are inconsistent. 
         [0136]    The first processing unit  4036  is further configured to perform process scheduling after exiting the first interrupt processing. 
         [0137]    The acquiring unit  4031  is configured to acquire the message header from the message receiving queue that corresponds to the target process when the first processing unit  4036  schedules the target process. 
         [0138]    The process switching unit  4033  is configured to switch to the target process when the first detecting unit  4034  detects that the message header includes the identity information, so that the target process acquires, from the QMC, the message body that is in the message and corresponds to the message header. 
         [0139]    Further, the message header further includes a second target process identity. 
         [0140]    As shown in  FIG. 9 , the target kernel further includes a second transceiver unit  4037  configured to receive a second interrupt triggering signal sent by the source kernel  404 ; and a second processing unit  4038  configured to perform second interrupt processing according to the second interrupt triggering signal received by the second transceiver unit  4037 . 
         [0141]    The acquiring unit  4031  is configured to, when the second processing unit  4038  is performing the second interrupt processing, read the message header and the message body from the QMC and place, according to the second target process identity in the message header, the message header and the message body into the message receiving queue that corresponds to the target process. 
         [0142]    The second processing unit  4038  is further configured to perform process scheduling after exiting the second interrupt processing. 
         [0143]    The process switching unit  4033  is further configured to switch to the target process when the first detecting unit  4034  detects that the message header includes the identity information and the second processing unit  4038  schedules the target process, so that the target process acquires the message body from the message receiving queue that corresponds to the target process. 
         [0144]    It should be noted that the first processing unit and the second processing unit may be integrated into one processing unit, or separately set as two processing units. The first transceiver unit and the second transceiver unit may be integrated into one transceiver unit, or separately set as two transceiver units. The present invention is not limited thereto. 
         [0145]    As shown in  FIG. 10 , the source processor core  401  includes a second detecting unit  4011  configured to detect whether the size of the message body is greater than the maximum payload that can be sent by the QMC; and a storing unit  4012  configured to store the message body into the shared memory when the second detecting unit  4011  detects that the size of the message body is greater than the maximum payload that can be sent by the QMC. 
         [0146]    The storing unit  4012  is configured to write all data of the message body into a cache unit, and write all the data of the message body in the cache unit into the shared memory. 
         [0147]    Optionally, a size of the shared memory occupied by the message body is a first integer multiple of a size of a cache line; and the first integer is an integer greater than 0. 
         [0148]    As shown in  FIG. 10 , the source kernel  404  includes a third processing unit  4041  configured to store information that is used to indicate the message body of the message stored in the shared memory as the message header into the QMC, and send to the target kernel. 
         [0149]    The third processing unit  4041  is further configured to store the message body into the QMC if the detecting unit  4011  of the source processor core  401  detects that the size of the message body is not greater than the maximum payload that can be sent by the QMC; and store information that is used to indicate the message body of the message stored in the QMC as the message header into the QMC, and send to the target kernel. 
         [0150]    If the size of the message body of the message is greater than the maximum payload that can be carried by the QMC, the message header is used to indicate the message body stored in the shared memory; if the size of the message body of the message is not greater than the maximum payload that can be carried by the QMC, the message header is used to indicate the message body of the message stored in the QMC. 
         [0151]    An embodiment of the present invention provides a many-core processor. A target kernel of a target processor core transmits a message header from a QMC, and stores the message header into a message receiving queue that corresponds to a target process. The target kernel detects, according to the message header of a message, whether a corresponding message body is transmitted by the QMC. If it is not transmitted by the QMC, the target kernel learns that the message body is stored in a shared memory, executes, according to the acquired message header, a CPU pre-fetching command instructing to load the message body from the shared memory to a cache that corresponds to the target processor core, and switches to the target process, so that the target process acquires the message body from the cache. If the message body is transmitted directly by the QMC, the target kernel switches to the target process, so that the target process acquires the message from a message queue that corresponds to the target process. In this way, during communication between processes, the message body is loaded to the cache, so that the target process may directly acquire the message body from the cache without the need of accessing the shared memory to acquire the message body, thereby increasing the speed of reading the message body and enhancing user experience. In addition, when a size of the message body is not greater than the maximum payload that can be carried by the QMC, the message body is transmitted through the QMC, and the target kernel does not need to access the shared memory for transmission but directly acquires the message body from the QMC, thereby further increasing the speed of reading the message body and further enhancing the user experience. 
         [0152]    An embodiment of the present invention provides a many-core processor system. As shown in  FIG. 11 , the many-core processor system includes a source processor core  801 , a target processor core  802 , and a memory  803 . 
         [0153]    The memory  803  is configured to store codes that are run by the source processor core and the target processor core. 
         [0154]    The target processor core  802  is configured to read the codes stored in the memory  803 , so that a target kernel executes the following method by running a kernel program: acquiring, by the target kernel, a message header of a message from a QMC. 
         [0155]    Optionally, the message header includes a start address of a message body and a size of the message body stored in a shared memory, and the start address and the size of the message body are used to indicate the message body stored in the shared memory; or the message header includes a start address and an end address of the message body stored in the shared memory, and the start address and the end address are used to indicate the message body stored in the shared memory. 
         [0156]    The target kernel further executes a CPU pre-fetching command according to the message header, so that the message body that is in the message stored in the shared memory and corresponds to the message header is loaded to a cache that corresponds to the target processor core. 
         [0157]    The target kernel further switches to a target process, so that the target process acquires the message body from the cache. 
         [0158]    Further, the message header includes identity information, where the identity information is used to indicate that the message body of the message is transmitted through the QMC. 
         [0159]    In this case, the target kernel further detects whether the message header includes the identity information. 
         [0160]    If it is detected that the message header does not include the identity information, the CPU pre-fetching command is executed according to the message header. 
         [0161]    Further, the target kernel further receives a first interrupt triggering signal sent by the source processor core  801 , and performs first interrupt processing according to the received first interrupt triggering signal. 
         [0162]    The message header further includes a first target process identity used to identify the target process that corresponds to the message header. 
         [0163]    In the process of performing the first interrupt processing, the target kernel further reads the message header from the QMC and places, according to the first target process identity in the message header, the message header into a message receiving queue that corresponds to the target process. 
         [0164]    Further, when the message body of the message is stored in the shared memory, the message header further includes a part of data of the message body, so that the target process detects, according to the part of data of the message body, the message body acquired from the cache. 
         [0165]    The target kernel further performs process scheduling after exiting the first interrupt processing. 
         [0166]    When scheduling the target process, the target kernel acquires the message header from the message receiving queue that corresponds to the target process. 
         [0167]    If it is detected that the message header includes the identity information, the target kernel switches to the target process, so that the target process acquires, from the QMC, the message body that is in the message and corresponds to the message header. 
         [0168]    Further, the message header further includes a second target process identity. 
         [0169]    In this case, the target kernel further receives a second interrupt triggering signal sent by the source processor core  801 , and performs second interrupt processing according to the received second interrupt triggering signal. 
         [0170]    In the process of performing the second interrupt processing, the target kernel reads the message header and the message body from the QMC, and places, according to the second target process identity in the message header, the message header and the message body into the message receiving queue that corresponds to the target process. 
         [0171]    The target kernel further performs process scheduling after exiting the second interrupt processing. 
         [0172]    When scheduling the target process, the target kernel switches to the target process, so that the target process acquires the message body from the message receiving queue that corresponds to the target process. 
         [0173]    The source processor core  801  is configured to read the codes stored in the memory  803 , so that a source kernel executes the following method by running a kernel program: detecting, by the source processor core  801 , whether the size of the message body is greater than the maximum payload that can be sent by the QMC. 
         [0174]    The message body is stored into the shared memory if it is detected that the size of the message body is greater than the maximum payload that can be sent by the QMC. 
         [0175]    Optionally, the source processor core  801  executes the following: writing all data of the message body into a cache unit, and then writing all the data of the message body in the cache unit into the shared memory. 
         [0176]    Optionally, a size of the shared memory occupied by the message body is a first integer multiple of a size of a cache line; and the first integer is an integer greater than 0. 
         [0177]    The source kernel stores information that is used to indicate the message body of the message stored in the shared memory as the message header into the QMC, and sends to the target kernel. 
         [0178]    The source kernel further executes the following: storing the message body into the QMC if it is detected that the size of the message body is not greater than the maximum payload that can be sent by the QMC; and storing the information that is used to indicate the message body of the message stored in the QMC as the message header into the QMC, and sending to the target kernel. 
         [0179]    If the size of the message body of the message is greater than the maximum payload that can be carried by the QMC, the message header is used to indicate the message body stored in the shared memory; if the size of the message body of the message is not greater than the maximum payload that can be carried by the QMC, the message header is used to indicate the message body of the message stored in the QMC. 
         [0180]    An embodiment of the present invention provides a many-core processor system. A target kernel of a target processor core transmits a message from a QMC, and stores the message into a message receiving queue that corresponds to a target process. The target kernel detects, according to a message header of the message, whether a corresponding message body is transmitted by the QMC. If it is not transmitted by the QMC, the target kernel learns that the message body is stored in a shared memory, executes, according to the acquired message header, a CPU pre-fetching command instructing to load the message body from the shared memory to a cache that corresponds to the target processor core, and switches to the target process, so that the target process acquires the message body from the cache. If the message body is transmitted directly by the QMC, the target kernel switches to the target process, so that the target process acquires the message from a message queue that corresponds to the target process. In this way, during communication between processes, the message body is loaded to the cache, so that the target process may directly acquire the message body from the cache without the need of accessing the shared memory to acquire the message body, thereby increasing the speed of reading the message body and enhancing user experience. In addition, when a size of the message body is not greater than the maximum payload that can be carried by the QMC, the message body is transmitted through the QMC, and then the target kernel does not need to access the shared memory for transmission but directly acquires the message body from the QMC, thereby further increasing the speed of reading the message body and further enhancing the user experience. 
         [0181]    A person of ordinary skill in the art should understand that all or part of the steps of the foregoing method embodiments may be implemented by a program instructing relevant hardware. The foregoing program may be stored in a computer readable storage medium. When the program runs, the foregoing steps included in the method embodiments are performed. The foregoing storage medium may be any medium capable of storing program codes, such as a read-only memory (ROM), a random-access memory (RAM), a magnetic disk, or an optical disk. 
         [0182]    The foregoing description is merely about specific embodiments of the present invention, but is not intended to limit the protection scope of the present invention. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in the present invention shall fall within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.