CN110659140A - Instruction execution method and related equipment - Google Patents

Instruction execution method and related equipment Download PDF

Info

Publication number
CN110659140A
CN110659140A CN201810701825.4A CN201810701825A CN110659140A CN 110659140 A CN110659140 A CN 110659140A CN 201810701825 A CN201810701825 A CN 201810701825A CN 110659140 A CN110659140 A CN 110659140A
Authority
CN
China
Prior art keywords
target
function
thread
asynchronous
call
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810701825.4A
Other languages
Chinese (zh)
Other versions
CN110659140B (en
Inventor
杨亮
张文明
陈少杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810701825.4A priority Critical patent/CN110659140B/en
Publication of CN110659140A publication Critical patent/CN110659140A/en
Application granted granted Critical
Publication of CN110659140B publication Critical patent/CN110659140B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/549Remote execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Exchange Systems With Centralized Control (AREA)

Abstract

The embodiment of the invention provides an instruction execution method and related equipment, which are used for solving the multithreading problem caused in the asynchronous calling process. The method provided by the embodiment of the invention comprises the following steps: sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction; receiving an asynchronous completion instruction; searching a target structure body RpcComponiteMessage from the global dictionary according to the remote calling identifier gid; judging whether the current remote call is safe in thread or not according to the target structure RpcCompositeMessage; if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call; registering a target signal processing function ApcRoutine in a target thread; and delivering a target signal to the target thread for processing based on the access identification of the target thread.

Description

Instruction execution method and related equipment
Technical Field
The present invention relates to the field of remote asynchronous call, and in particular, to a method for executing an instruction and a related device.
Background
Remote procedure calls are procedures that one process calls to a method provided by another process, but are still consistent with the function that called the process from the caller's perspective. In the remote procedure call, all parameters to be provided to the callee process are serialized into a network message and then sent to the callee process through network transmission. After the callee completes the corresponding service, the generated result is also serialized into a network message and sent to the caller process.
However, in the existing remote procedure call, the thread on which the calling process initiates the remote procedure call to the called process through the asynchronous calling function is not the same as the thread on which the called process is called after completing the processing, which easily causes a multithreading problem, for example, a program crash may be caused.
Disclosure of Invention
The embodiment of the invention provides an instruction execution method and related equipment, which are used for solving the multithreading problem caused in the asynchronous calling process.
A first aspect of an embodiment of the present invention provides an instruction execution method, including:
sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
receiving the asynchronous completion instruction, wherein the asynchronous completion instruction carries a remote calling identifier gid;
searching a target structure body Rpcompositemmessage from a global dictionary according to the remote calling identifier gid, wherein the global dictionary at least comprises the target structure body Rpcompositemmessage corresponding to the remote calling identifier gid, the target structure body Rpcompositemmessage comprises an access identifier of a target thread, and the target thread is a thread used by the first process for sending the remote asynchronous calling instruction;
judging whether a current remote call is thread safe or not according to the target structure RpcCompositeMessage, wherein the current remote call is a remote call initiated by the first process to the second process;
if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call;
registering a target signal processing function ApcRoutine in the target thread to receive a target signal through the target thread and process the target signal through the target signal processing function ApcRoutine, wherein the target signal carries a target function object task;
and delivering the target signal to the target thread for processing based on the access identification of the target thread.
Optionally, before the sending, by the first process, the remote asynchronous call instruction to the second process, the method further includes:
acquiring the target attribute value through the asynchronous call function RpcAllProduceEx, wherein the target attribute value is used for indicating whether the current remote call is safe in thread or not;
acquiring an access identifier of a target thread of the first process;
generating the target structure RpcComositemeAddress according to the access identifier and the target attribute value;
and storing the target structure RpcCompositeMessage to the global dictionary.
Optionally, the determining a target function object task according to the target structure rpccositemessage includes:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
Optionally, the delivering the target signal to the target thread for processing based on the access identifier of the target thread includes:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
A second aspect of the embodiments of the present invention provides an apparatus for instruction execution, including:
the sending unit is used for sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
a receiving unit, configured to receive the asynchronous completion instruction, where the asynchronous completion instruction carries a remote call identifier gid;
a searching unit, configured to search a target structure rpccompasitemessage from a global dictionary according to the remote call identifier gid, where the global dictionary at least includes the target structure rpccositemessage corresponding to the remote call identifier gid, the target structure rpccositemessage includes an access identifier of a target thread, and the target thread is a thread used by the first process to send the remote asynchronous call instruction;
a judging unit, configured to judge whether a current remote call is thread-safe according to the target structure RpcCompositeMessage, where the current remote call is a remote call initiated by the first process to the second process;
a determining unit, configured to determine a target function object task according to the target structure RpcCompositeMessage when the current remote call thread is safe, where the target function object task includes an asynchronous completion function rpccomplete route, and the asynchronous completion function rpccomplete route is used to indicate data called by the current remote call;
a registering unit, configured to register a target signal processing function apcrroute in the target thread, receive a target signal through the target thread, and process the target signal through the target signal processing function apcrroute, where the target signal carries the target function object task
And the execution unit is used for processing the target signal to the target thread based on the access identifier of the target thread.
Optionally, the apparatus further comprises:
an obtaining unit, configured to obtain the target attribute value through the asynchronous call function rpccallproceurex, where the target attribute value is used to indicate whether the current remote call is thread-safe;
the obtaining unit is further configured to obtain an access identifier of a target thread of the first process;
a generating unit, configured to generate the target structure RpcCompositeMessage according to the access identifier and the target attribute value;
and the storage unit is used for storing the target structure RpcComositemAddress to the global dictionary.
Optionally, the determining unit is specifically configured to:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
Optionally, the execution unit is specifically configured to:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
A third aspect of the present invention provides an electronic device comprising a memory and a processor, wherein the processor is configured to implement the steps of the method for instruction execution as described in any one of the above when executing a computer management class program stored in the memory.
A fourth aspect of the present invention provides a computer-readable storage medium having a computer management-like program stored thereon, characterized in that: the computer management like program when executed by a processor implements the steps of a method performed by the instructions of any of the above.
It can be seen from the above technical solutions that, in the embodiment of the present invention, the asynchronous completion function rpccmplete route returned by the called party (i.e., the second process) is delivered to the calling party (i.e., the first process) as a parameter of the target signal, and the target thread when asynchronous calling is initiated through the asynchronous calling function rpccallprocedure ex, so that it is ensured that the thread where the asynchronous calling function rpccallprocedure is called and the thread when the completion function is called are in the same thread, and the problem of easily causing multithreading in the prior art can be solved.
Drawings
FIG. 1 is a flowchart illustrating a possible method for instruction execution according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an embodiment of an apparatus for performing a possible instruction according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a hardware architecture of an apparatus for performing a possible instruction according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an embodiment of a possible electronic device according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an embodiment of a possible computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides an instruction execution method and related equipment, which are used for solving the multithreading problem caused in the asynchronous calling process.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
It should be noted that, before the caller initiates an asynchronous Call, the callee needs to register first, and in the existing Remote Procedure Call (RPC) implementation, there are two important RPC method functions, one is an asynchronous registration function, i.e., an RPC register Procedure function is used to register an RPC service, and the other is an asynchronous Call function, i.e., an RPC Call Procedure function, is used to Call an RPC service.
The following describes each function, the coding of each function, and the attribute of each function in detail, which are required by the embodiment of the present invention:
the RpcRegisterProcedure stores a string representing the RPC service name and a function object in a global RPC service dictionary with the service name as a key and the function object as a value. The function prototype is as follows
bool RpcRegisterProcedure(HRPC rpc,const char*name,const RpcAsyncProcedure&procedure,const char*signature);
Wherein, the parameter RPC represents an RPC instance handle, the name is the name of the RPC service, the procedure is the function object, and the signature is a parameter signature required by the function object (for checking whether the parameter transmitted from the calling terminal meets the parameter required by the function object.)
The RpcCallProcedure calls the remote RPC service function according to the designated RPC service name and the given parameter list. The functional prototype is as follows:
Figure BDA0001714682860000061
the parameter RPC also represents an RPC instance handle, session represents which remote program the RPC call request is to be sent to, name represents the name of the RPC service to be called, args represents all parameters of the call, numargs represents the number of args parameters, when async is not equal to 0, the call represents that the call is an RPC asynchronous call, and the result after the call is completed is passed through the callback function object of the async, but not through the return value of the function; if async is equal to 0, the call is an RPC synchronous call, the result after the call is completed is transmitted through the return value of the function, the timeOut parameter is used for setting the timeOut time (unit of millisecond) of the RPC call, and if the return result of the call is not received within the time specified by timeOut, the RPC call is triggered to timeOut regardless of synchronous call or asynchronous call.
As can be seen from the above discussion, function objects are used regardless of whether the RpcRegisterProducer or RpcAllProducer function is used. Wherein in the rpcegisterprocedure function, the function object used is of the rpcas syncprocedure type; in the RpcAllProducere function, the function object used is of the type RpcompleteRouteutine. Wherein the two types are defined as follows:
RpcAsyncProcedure;
typedef std::function<void(void*caller,IRpcArgument**args,int numArgs,AsyncRpcProcedureContext asyncContext)>RpcAsyncProcedure
it can be seen that rpcas sync procedure is std of one of the reception parameters: : and a function object, wherein the parameter, namely, the caller represents the remote identifier for calling the RPC service, the args represents the parameter of the RPC call, the numArgs represents the number of the parameters (the two parameters are transmitted when called by the RpcAllProduce), and the asyncContext parameter represents the context block executed by the RPC service.
RpcCompleteRoutine;
typedef std::function<void(IRpcArgumentArray*)>RpcCompleteRoutine
It can be seen that the callback function object is a received parameter std when the asynchronous RPC call is completed: : and a function object, wherein the unique parameter represents a result after RPC asynchronous calling.
It should be noted that, for better understanding of the rpcreisterprocedure, rpclcallprocedure, and callback function objects RpcAsyncProcedure, rpccmpleetroutine, a simple pseudo code is listed below. Assume now that there are two processes A, B, where RpcRegisterProducer method is called in process A to register an add RPC service, and RpcAllProducer method is called in process B to call the add RPC service in process A, the code is as follows:
and a process A:
void add(void*caller,IRpcArgument**args,int numArgs,AsyncProcdureContext context)
{
}
RpcRegisterProcedure(rpc,”add”,std::bind(add),”II”);
and a process B:
void onAddCompleted(IRpcArgumentArray*result)
{
}
RpcCallProcedure(rpc,0,”add”,args,2,std::bind(onAddCompleted),1000);
in the pseudo code, when the process B calls the RpcCallProcedure function to asynchronously call the add RPC service function of the process a, the process a enters the add function, and after the process a completes processing and sends a result to the process B, the process B enters the onaddcmpleted callback function object, so as to obtain the result of the call.
However, the above scheme has the disadvantage that on function objects of two types, namely rpcas syncprocedure and rpcscompletetroutine, because the two types are both function types in std standard library, and the function is a C + + template class, the memory layout sizes of the function objects may be inconsistent on different versions of compilers, so if the rpc.dll module in the present invention is compiled and generated by a VS2010 compiler; however, if the pseudo code is decompiled using the VS2015 compiler, then because std: : the memory layout of the function object is not consistent resulting in a crash of the program.
The reason why the program flush described above is generated is that, when RpcRegisterProcedure is called in the process a, std: : a bind function, binding the add function into a function object, compiling in a VS2015 compiler at the moment, and when entering the RpcRegisterProducer function, because the compiling is carried out by using a VS2010 compiler, a bottom RPC.dll module and an upper use module are compiled by different compiler versions, thereby causing the memory access to be out of bounds and causing the process A to crash; the same problem is also the case when the onaddpath function object is bound in the process B.
Therefore, the method is improved on the basis of the prior art, and the problem of process crash caused by inconsistency of the function objects on different compiler versions is solved.
Regardless of the rpccalprocedure function or the rpccalprocedureex function, when the RPC service function is called in an asynchronous manner, the completion function is executed in an asynchronous thread in the underlying implementation mechanism of the RPC. Therefore, the thread where the RpcAllProducere or the RpcAllProduceEx function is called is not the same as the thread where the function is called, and if some processing in the aspect of thread safety is not performed, the multithreading problem is particularly easy to cause.
On the basis of the RpcAllProduceEx function, the invention ensures that the thread called by the asynchronous completion function RpcompleteRouteine and the thread called by the RpcAllProduceEx are the same thread, namely the RpcAllProduceEx function is called in which thread, the completion function is also executed in the thread, thereby ensuring the safe asynchronous RPC calling of the thread.
In the embodiment of the invention, for the upgraded interfaces of the two functions, namely the RpcRegisterProduceEx function and the RpcALlProduceEx function, the two function interfaces abandon the previous C + + function object, a callback function is set by using the most basic function pointer mode in the C language, and related parameters are flexibly set by using the RpcAttribute attribute mode.
Wherein the function of RpcRegisterProduceEx is modeled as follows:
bool RpcRegisterProcedureEx(HRPC rpc,int64_t*attr);
as can be seen, the function parameter only receives two parameters, one is the RPC instance handle and the other is an int64 type attribute array. Storing all other needed parameters (including callback function pointer, RPC service name, RPC service function signature, etc.) in the array by key value pair
The functional prototype of RpcCallProcedureEx is as follows:
Figure BDA0001714682860000091
similarly, the function only retains the relevant necessary parameters, and other parameters (asynchronous callback function, timeout time and the like are also put in the attribute array of the int64 type);
as can be seen from the declaration of these two functions, they do not use the C + + function object. Therefore, the problem of process collapse caused by inconsistent compiler versions due to the use of the C + + function object can be solved.
The implementation steps of these two functions are then as follows:
RpcAttribute:
the above-mentioned rpcreisterprocedureex and RpcCallProcedureEx functions both use an ATTR array of int64 type, in which an array of key-value pairs that are each keyed by an rpcacttribute attribute is stored, and that necessarily END with an RPC _ ATTR _ END attribute, including
RPC_ATTR_CALLBACK_FUNCTION:
The attribute key is used to set the relevant callback function of the RpcRegisterProduceEx or RpcAllProduceEx functions.
When this attribute is used in the RpcRegisterProduceEx function, the representation is used to register the RPC service function. Then the type of service function is as follows:
typedef void(*RPC_CALLBACK_FUNCTION)(void*caller,IRpcArgument**args,int numArgs,AsyncRpcProcedureContext asyncContext,void*userData);
it can be seen that the callback function of the C language type is substantially identical to the function object of the C + + type, except for one more last void UserData, which is used to store the custom parameters when the upper layer is in use.
When this attribute is used in the RpcCallProcedureEx function, indicating that the associated callback function is completed when used to set the asynchronous call RPC service, then the type of the callback function is as follows:
typedef void(*RPC_COMPLETE_ROUTINE)(IRpcArgumentArray*,void*userData);
also, function objects of this type and C + + type are identical except for one more void × userData.
RPC_ATTR_CALLBACK_USERDATA:
This attribute key is used to set the value of void userData described above.
RPC_ATTR_FUNCTION_SIGNATURE:
The attribute key is used for setting a fourth parameter signature and a function signature value of the original RpcRegisterProducere function.
RPC_ATTR_FUNCTION_NAME:
The attribute key is used to set the second parameter name of the original RPC register procedure function, which represents the name of the RPC service.
RPC_ATTR_TIMEOUT_VALUE:
The attribute key is used to set the value in the RpcCallProcedure function used to set the timeOut, and if this value is not set when RpcCallProcedure ex is called, the default time is INFINITE, i.e., INFINITE timeOut.
RPC_ATTR_ASYNC_CALL:
The attribute key is used to display whether to call the RPC service in an asynchronous manner. When the attribute value is set to 1, even if the value of RPC _ ATTR _ CALLBACK _ FUNCTION is not specified, when the RpcALlProduceEx is called, the RPC is called in an asynchronous mode; if the attribute is set to 0, the displayed indication is to call RPC in a synchronous manner; at this time, even if the value of RPC _ ATTR _ CALLBACK _ FUNCTION is specified, it will be ignored.
RPC_ATTR_JUST_NOTIFY:
The attribute key is used for setting whether to call the RPC service in an RPC notification mode. If the value of the attribute is set to 1, an RPC service is called by adopting an RPC notification mode (at the moment, the calling party does not need the result of the call, and the called party of the RPC does not need to feed back the result to the calling party); if the value is set to 0, the RPC service is called by the RPC request (at this time, the caller needs the result of this call, and the callee needs to feed back the result to the caller).
RPC_ATTR_CALLER_THREAD:
On the basis of the above, the embodiment of the invention adds the attribute of RPC _ ATTR _ CALLER _ THREAD, if the attribute value is set to 1, when the RPC is called in an asynchronous mode, the call-back function RPC _ COMPLETE _ ROUTINE which is completed by the RPC is executed in the THREAD which calls RpcAllProduceEx, so that the asynchronous call is a call with THREAD safety; if the attribute value is set to 0, then the callback function will not execute in the thread that called RpcAllProduceEx, but will execute randomly in a thread pool (containing many threads), and such callback function is non-thread-safe. In the embodiment of the present invention, the attribute is set to 0 by default.
It should be noted that in the embodiment of the present invention, the asynchronous completion function rpccomplete route is triggered after receiving the response of the called party inside the RPC module, and the thread at this time is located in RpcMainThread inside the RPC module. In order for the completion function to execute in the thread that called RpcCallProcedureEx, then there must be a mechanism to enable the asynchronous completion function rpccmplete route to be posted for execution in another thread.
Therefore, the embodiment of the invention utilizes a signal mechanism under the Linux operating system, and can deliver a signal with a parameter value to a specified thread through the pthread _ signal function under the Linux operating system.
The embodiment of the invention uses the characteristic of the Linux operating system, uses the asynchronous completion function RpcompleteRouteine to be executed as the parameter of the signal, and sends the parameter of the signal to the target thread along with the signal, when the target thread receives the signal and executes the relevant signal processing function, the asynchronous completion function RpcompleteRouteine is obtained from the parameter of the relevant signal processing function, and then the asynchronous completion function RpcompleteRouteine is executed, thereby completing the execution of the asynchronous completion function RpcompleteRouteine in the target thread.
The function prototype of pthread _ sigqueue is as follows:
int pthread_sigqueue(pthread_t thread,int signo,sigval val);
the first parameter is the thread handle of the target thread (i.e. a signal specified by the second parameter is sent to the thread), the second parameter is a signal value, the third parameter is a signal-carried parameter, wherein the member of the validity _ ptr of the sigval is a specific parameter value; when the function returns to 0, the pfnACP function is successfully put into the hThread thread, otherwise, the function fails.
When pthread _ queue is called to send a signal to a thread, the signal must be registered in the process first, and a function of type void (int, signal _ t, void) can be registered as a processing function of the signal by using the signature function of the l-inux system.
When the target thread receives the signal, the signal _ handle processing function is executed, and in the si _ ptr member of the siginfo _ t parameter of the processing function, the parameter carried when the pthread _ signal function is called to send the signal can be acquired.
In the above, the functions, the codes of the functions, and the attributes of the functions that are needed in the embodiments of the present invention are described in detail, and an embodiment of a method for executing instructions in the embodiments of the present invention is described below with reference to fig. 1.
Referring to FIG. 1, one embodiment of a method for instruction execution according to the present invention includes:
101. and sending a remote asynchronous call instruction to the second process by using an asynchronous call function RpcAllProduceEx through the first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction.
In the embodiment of the invention, the first process is a calling process, the second process is a called process, and the asynchronous call function RpcAllProduceEx is the RpcAllProduceEx function, namely, the asynchronous call execution is initiated to the second process through the first process, the service corresponding to the asynchronous call instruction is executed through the second process, and the asynchronous completion instruction is returned after the second process completes the processing.
It should be noted that, before the first process sends a remote asynchronous call instruction to the second process using the asynchronous call function rpccallprocedure ex, the second process needs to register the service asynchronously called by the first process through the asynchronous registration function, the second process implements registration of the service through the rpccegisterprocedure ex function, the implementation of the rpccegisterprocedurex function, that is, obtaining a required value from the attr attribute array, and then calls an execution step of the rpccegisterprocedure function, which includes the following specific steps:
step 1a, obtaining an RPC service name;
the value of the key equal to RPC _ ATTR _ FUNCTION _ NAME is obtained from the ATTR attribute array, and the mark is rpcName.
Step 1b, obtaining an RPC callback function;
the value of the key, labeled rpcFunction, is obtained from the ATTR attribute array, equal to RPC _ ATTR _ CALLBACK _ FUNCTION.
Step 1c, obtaining RPC callback function custom parameters;
the value of the key, labeled USERDATA, is obtained from the ATTR attribute array equal to RPC _ ATTR _ CALLBACK _ USERDATA.
Step 1d, acquiring a function signature;
and acquiring a value of the key word equal to RPC _ ATTR _ FUNCTION _ SIGNATURE from the ATTR attribute array, and marking the value as SIGNATURE.
And step 1e, registering the required service.
After all the data are acquired, calling std: : and a bind function, binding the rpcFunction and the userData parameter into a C + + function object rpcFunctionObj ═ std: : bind (rpcFunction, userData);
the RpcRegisterProcedure function is then called to complete registration, i.e., RpcRegisterProcedure (rpc, rpcName, rpcfunction obj, signature).
102. An asynchronous completion instruction is received.
In this embodiment, after the second process completes the asynchronous call service, an asynchronous completion instruction may be returned to the first process, and at this time, an asynchronous completion instruction may be received, where the asynchronous completion instruction carries the remote call identifier gid.
103. And searching the target structure RpcCompositeMessage from the global dictionary according to the remote call identifier gid.
In this embodiment, after receiving the asynchronous completion instruction, extracting the remote call identifier gid from the asynchronous completion instruction, and finding the target structure rpccompasitemessage from the global dictionary according to the remote call identifier gid, where the global dictionary at least includes the target structure rpccositemessage corresponding to the remote call identifier gid, the target structure rpccositemessage includes an access identifier of a target thread, and the target thread is a thread used by the first process to send the remote asynchronous call instruction.
Specifically, when a return result message from a second thread is received in the client of the first thread, according to the gid unique identifier field in the message, then whether a target structure rpccompasitemessage corresponding to the gid field exists is searched in the global dictionary rect.
Specifically, rpmessage of the callee response is received, and an RPC call indicator (for uniquely identifying one RPC call) gid is acquired from the rpmessage, and the C + + source code structures of rpmessage and rpccositemessage are described below:
Figure BDA0001714682860000161
before searching the target structure rpccommitimemessage from the global dictionary according to the remote call identifier gid, the target structure rpccommitimemessage needs to be generated and stored in the global dictionary, and the specific steps are as follows:
step 2a, obtaining the target attribute value through an asynchronous call function RpcAllProduceEx, wherein the target attribute value is used for indicating whether the current remote call is thread safe or not;
as can be seen from the above discussion, within the RpcAllProduceEx function, the value of the RPC _ ATTR _ CALLER _ THREAD attribute is obtained, and if the value of the attribute is equal to 1, this indicates that the asynchronous RPC call to be executed is a THREAD-safe call, and if the value is equal to 0, or if the attribute is not set, this indicates that the asynchronous RPC call is a non-THREAD-safe asynchronous call.
Step 2b, acquiring an access identifier of a target thread of the first process;
when the pthread _ sigqueue system function is called, a specified thread handle (namely, an access identifier) is needed so that the specified asynchronous completion function rpccomplete route is delivered to the thread represented by the thread handle. Therefore, when the RpcCallProcedureEx function is called, the thread handle of the current thread needs to be acquired, and specifically, the pthread _ t thread handle of the target thread in the first thread is acquired by calling the pthread _ self function of the Linux system.
Step 2c, generating a target structure RpcComositemeAddress according to the access identifier and the target attribute value;
generating a structure body of RpcComposeAddress, and storing the attribute value of RPC _ ATTR _ CALLER _ THREAD into the threadSafe member of the structure; and saving the thread handle acquired in the step 2b into the callerContext member of the structure.
And 2d, storing the target structure RpcComositemAddress into the global dictionary.
After the target structure RpcCompositeMessage is generated, the target structure rpccositemessage is stored in the global dictionary.
104. And judging whether the current remote call is safe in thread according to the target structure RpcCompositeMessage, if so, executing the step 105, and if not, executing the step 108.
In this embodiment, it may be determined whether a current remote call is thread-safe according to the target structure rpccompasitemessage, where the current remote call is a remote call initiated by a current first process to a second process, specifically, whether a readsafe member of the current remote call is true is determined according to the obtained rpccositemessage structure, if true, step 105 is executed, and if not, step 108 is executed.
105. And determining a target function object task according to the target structure Rpcompositemmessage.
In this embodiment, the target function object task may be determined according to the target structure rpccompastemeessage, and specifically, the asynchronous completion function rpccollette route and the execution result function are obtained from the target structure rpccoputemeessage, where the asynchronous completion function rpccollette route is used to indicate data called by the current remote call, the execution result function is included in the asynchronous call function rpccollprocedureex, and then the target function object task is determined according to the asynchronous completion function rpccollette route and the execution result function.
106. A target signal processing function apcrroute is registered in the target thread.
In this embodiment, a target signal processing function apcrroute may be registered in a target thread to receive a target signal through the target thread, and the target signal is processed through the target signal processing function apcrroute, where the target signal carries a target function object task.
Specifically, when an RPC instance handle is created, a signal with a signal value of SIGUSR1 is registered by calling a signal, and the steps are as follows:
step 3a, filling a sigaction structure;
creating a structure of a signal, and assigning a signal processing function apcrroute (the type of which is the signal _ handler type in the above) to a sa _ signal member of the structure in the embodiment of the present invention; assign the SA _ SIGINFO value to the SA _ flags member of the fabric (to indicate that the ApcRoutine function is in effect, otherwise it will not be) if it is specified
Step 3b, registering a target signal processing function ApcRoutine;
and calling the sigaction system function, transmitting the SIGUR 1 signal value to the first parameter of the sigaction system function, transmitting the sigaction structure to the second parameter of the sigaction system function, and transmitting the third parameter into 0.
Here, the execution order of step 106 is not particularly limited, and it is sufficient if the target thread is registered before the target thread that needs to send the target signal.
107. And delivering the target signal to the target thread for processing based on the access identification of the target thread.
In this embodiment, a pthread _ sigqueue function is called based on the access identifier of the target thread to deliver the target signal to the target thread for processing.
The following is a detailed description:
first, the asynchronous completion function rpccompleterroute and the RPC execution result irpcartugmentarray are bound into one function object, that is, std: : a bind function, binding an asynchronous completion function RpcCompleteRoutenRpcCompleteRoutenine and an execution result IRpcArgmentArray in an RpcCompleteMessage structure into a target function object taskatsk;
secondly, sending a target signal;
after the previous step is finished, calling a pthread _ queue function, and setting the bound function object task into a value _ ptr member of a sigmal structure, so that the task is delivered to a target thread in the form of a signal parameter of a target signal. The specific codes are as follows:
Figure BDA0001714682860000183
val);
thus, after the target signal is successfully delivered to the target thread, the target signal enters the registered ApcRoutine target signal processing function ApcRoutine in the target thread, then the target function object tasktask is obtained according to the si _ ptr parameter of the siginfo _ t parameter of the ApcRoutine target signal processing function, and finally the tasktask is executed. The specific codes are as follows:
Figure BDA0001714682860000181
108. the non-thread-safe asynchronous completion function rpccomplete route is executed.
In this embodiment, since it is non-thread-safe, it is only necessary to directly deliver the rpccomplete route asynchronous completion function rpccomplete route in the rpccompastemesse structure to the thread pool for execution.
In summary, it can be seen that, in the embodiment of the present invention, the asynchronous completion function rpccomplete route that needs to be executed is taken as a parameter of a signal, and is sent to the target thread along with the signal, when the target thread receives the signal and executes the target signal processing function apccoute, the asynchronous completion function rpccomplete route is obtained from the parameter of the target signal processing function apccoute, and then the asynchronous completion function rpccomplete route is executed, so that the asynchronous completion function rpccomplete route is executed in the target thread, and thus it is ensured that the thread where the asynchronous call function rpccollprocedureeex is called and the thread where the completion function is called are in the same thread, and the problem of easily causing multi-threading in the prior art can be solved.
The following is exemplified with reference to the above-described process a and process B:
with the implementation of rpcreisterprocedureex and rpccalprocedureex in the versions, the code implementation of the original process A, B is as follows:
and a process A:
void add(void*caller,IRpcArgument**args,int numArgs,AsyncProcdureContext context,void*userData)
{
}
int64_t attr[]={
RPC_ATTR_CALLBACK_FUNCTION,add,
RPC_ATTR_FUNCTION_NAME,”add”,
RPC_ATTR_FUNCTION_SIGNATURE,”II”,
RPC_ATTR_END
};
RpcRegisterProcedureEx(rpc,attr);
and a process B:
void onAddCompleted(IRpcArgumentArray*result,void*userData)
{
}
int64_t attr[]={
RPC_ATTR_CALLBACK_FUNCTION,onAddCompleted,
RPC_ATTR_CALLER_THREAD,1
RPC_ATTR_TIMEOUT_VALUE,1000,
};
RpcCallProcedureEx(rpc,0,”add”,args,2,attr);
through the setting, the final onaddconsimpleted completion function is executed in the thread where the rpccall procedure ex is called, so that the safety of the thread is ensured.
According to the embodiment of the invention, by setting the RPC _ ATTR _ CALLER _ THREAD attribute, the asynchronous completion function RpcompleteRouteine is delivered to the calling THREAD when the RPC service function is asynchronously called in the Linux operating system, so that the safety of the THREAD is ensured.
The above describes a method for executing an instruction in the embodiment of the present invention, and a device for executing an instruction in the embodiment of the present invention is described below, where the device for executing an instruction may be a client of a first process, may not be a client of a first process, is an independent server client, may also be a service unit in a client of a first process, or a service unit in an independent server client, and is not limited specifically.
Referring to fig. 2, an embodiment of an apparatus for instruction execution according to an embodiment of the present invention includes:
a sending unit 201, configured to send a remote asynchronous call instruction to a second process through a first process using an asynchronous call function rpccallproceureex, so that the second process performs processing according to the remote asynchronous call instruction, and returns an asynchronous completion instruction;
a receiving unit 202, configured to receive the asynchronous completion instruction, where the asynchronous completion instruction carries a remote invocation identifier gid;
a searching unit 203, configured to search a target structure rpccompasitemessage from a global dictionary according to the remote call identifier gid, where the global dictionary at least includes the target structure rpccositemessage corresponding to the remote call identifier gid, the target structure rpccositemessage includes an access identifier of a target thread, and the target thread is a thread used by the first process to send the remote asynchronous call instruction;
a determining unit 204, configured to determine, according to the target structure RpcCompositeMessage, whether a current remote call is thread-safe, where the current remote call is a remote call initiated by the first process to the second process;
a determining unit 205, configured to determine a target function object task according to the target structure rpccommitiemessage when the current remote call thread is safe, where the target function object task includes an asynchronous completion function rpccomplete route, and the asynchronous completion function rpccomplete route is used to indicate data called by the current remote call;
a registering unit 206, configured to register a target signal processing function apcrroute in the target thread, so as to receive a target signal through the target thread, and process the target signal through the target signal processing function apcrroute, where the target signal carries the target function object task
And the execution unit 207 is used for delivering the target signal to the target thread for processing based on the access identifier of the target thread.
Optionally, the apparatus further comprises:
an obtaining unit 208, configured to obtain the target attribute value through the asynchronous call function rpccallproceurex, where the target attribute value is used to indicate whether the current remote call is thread-safe;
the obtaining unit 208 is further configured to obtain an access identifier of a target thread of the first process;
a generating unit 209, configured to generate the target structure RpcCompositeMessage according to the access identifier and the target attribute value;
a storage unit 210, configured to store the target structure RpcCompositeMessage in the global dictionary.
Optionally, the determining unit 205 is specifically configured to:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
Optionally, the execution unit 207 is specifically configured to:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
In summary, in the embodiment of the present invention, the asynchronous completion function rpccmplete route returned by the called party (i.e., the second process) is delivered to the calling party (i.e., the first process) as a parameter of the target signal, and the asynchronous calling function rpccallprocedure ex initiates the target thread when asynchronous calling is performed, so that the thread where the asynchronous calling function rpccallprocedure ex is called and the thread where the completion function is called are in the same thread, and the problem of easily causing multithreading in the prior art can be solved.
Fig. 2 above describes an apparatus for executing instructions in an embodiment of the present invention from the perspective of a modular functional entity, and the following describes an apparatus for executing instructions in an embodiment of the present invention in detail from the perspective of hardware processing, referring to fig. 3, an embodiment of an apparatus 300 for executing instructions in an embodiment of the present invention includes:
an input device 301, an output device 302, a processor 303 and a memory 304 (wherein the number of the processor 303 may be one or more, and one processor 303 is taken as an example in fig. 3). In some embodiments of the present invention, the input device 301, the output device 302, the processor 303 and the memory 304 may be connected by a bus or other means, wherein the connection by the bus is exemplified in fig. 3.
Wherein, by calling the operation instruction stored in the memory 304, the processor 303 is configured to perform the following steps:
sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
receiving the asynchronous completion instruction, wherein the asynchronous completion instruction carries a remote calling identifier gid;
searching a target structure body Rpcompositemmessage from a global dictionary according to the remote calling identifier gid, wherein the global dictionary at least comprises the target structure body Rpcompositemmessage corresponding to the remote calling identifier gid, the target structure body Rpcompositemmessage comprises an access identifier of a target thread, and the target thread is a thread used by the first process for sending the remote asynchronous calling instruction;
judging whether a current remote call is thread safe or not according to the target structure RpcCompositeMessage, wherein the current remote call is a remote call initiated by the first process to the second process;
if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call;
registering a target signal processing function ApcRoutine in the target thread to receive a target signal through the target thread and process the target signal through the target signal processing function ApcRoutine, wherein the target signal carries a target function object task;
and delivering the target signal to the target thread for processing based on the access identification of the target thread.
Optionally, by calling the operation instruction stored in the memory 304, the processor 303 is further configured to perform the following steps:
acquiring the target attribute value through the asynchronous call function RpcAllProduceEx, wherein the target attribute value is used for indicating whether the current remote call is safe in thread or not;
acquiring an access identifier of a target thread of the first process;
generating the target structure RpcComositemeAddress according to the access identifier and the target attribute value;
and storing the target structure RpcCompositeMessage to the global dictionary.
Optionally, the determining a target function object task according to the target structure rpccositemessage includes:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
Optionally, the delivering the target signal to the target thread for processing based on the access identifier of the target thread includes:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
Referring to fig. 4, fig. 4 is a schematic view of an embodiment of an electronic device according to an embodiment of the invention.
As shown in fig. 4, an embodiment of the present invention provides an electronic device, which includes a memory 410, a processor 420, and a computer program 411 stored in the memory 420 and running on the processor 420, and when the processor 420 executes the computer program 411, the following steps are implemented:
sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
receiving the asynchronous completion instruction, wherein the asynchronous completion instruction carries a remote calling identifier gid;
searching a target structure body Rpcompositemmessage from a global dictionary according to the remote calling identifier gid, wherein the global dictionary at least comprises the target structure body Rpcompositemmessage corresponding to the remote calling identifier gid, the target structure body Rpcompositemmessage comprises an access identifier of a target thread, and the target thread is a thread used by the first process for sending the remote asynchronous calling instruction;
judging whether a current remote call is thread safe or not according to the target structure RpcCompositeMessage, wherein the current remote call is a remote call initiated by the first process to the second process;
if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call;
registering a target signal processing function ApcRoutine in the target thread to receive a target signal through the target thread and process the target signal through the target signal processing function ApcRoutine, wherein the target signal carries a target function object task;
and delivering the target signal to the target thread for processing based on the access identification of the target thread.
In a specific implementation, when the processor 420 executes the computer program 411, any of the embodiments corresponding to fig. 1 may be implemented.
Since the electronic device described in this embodiment is a device used for implementing an instruction execution apparatus in the embodiment of the present invention, based on the method described in the embodiment of the present invention, a person skilled in the art can understand the specific implementation manner of the electronic device in this embodiment and various variations thereof, so that how to implement the method in the embodiment of the present invention by the electronic device is not described in detail herein, and as long as the person skilled in the art implements the device used for implementing the method in the embodiment of the present invention, the device used for implementing the method in the embodiment of the present invention belongs to the protection scope of the present invention.
Referring to fig. 5, fig. 5 is a schematic diagram illustrating an embodiment of a computer-readable storage medium according to the present invention.
As shown in fig. 5, the present embodiment provides a computer-readable storage medium 500 having a computer program 511 stored thereon, the computer program 511 implementing the following steps when executed by a processor:
sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
receiving the asynchronous completion instruction, wherein the asynchronous completion instruction carries a remote calling identifier gid;
searching a target structure body Rpcompositemmessage from a global dictionary according to the remote calling identifier gid, wherein the global dictionary at least comprises the target structure body Rpcompositemmessage corresponding to the remote calling identifier gid, the target structure body Rpcompositemmessage comprises an access identifier of a target thread, and the target thread is a thread used by the first process for sending the remote asynchronous calling instruction;
judging whether a current remote call is thread safe or not according to the target structure RpcCompositeMessage, wherein the current remote call is a remote call initiated by the first process to the second process;
if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call;
registering a target signal processing function ApcRoutine in the target thread to receive a target signal through the target thread and process the target signal through the target signal processing function ApcRoutine, wherein the target signal carries a target function object task;
and delivering the target signal to the target thread for processing based on the access identification of the target thread.
In a specific implementation, the computer program 511 may implement any of the embodiments corresponding to fig. 1 when executed by a processor.
It should be noted that, in the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to relevant descriptions of other embodiments for parts that are not described in detail in a certain embodiment.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Embodiments of the present invention further provide a computer program product, where the computer program product includes computer software instructions, and when the computer software instructions are executed on a processing device, the processing device executes a flow in the method for designing a wind farm digital platform in the embodiment corresponding to fig. 1.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

Claims (10)

1. A method of instruction execution, comprising:
sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process, so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
receiving the asynchronous completion instruction, wherein the asynchronous completion instruction carries a remote calling identifier gid;
searching a target structure body Rpcompositemmessage from a global dictionary according to the remote calling identifier gid, wherein the global dictionary at least comprises the target structure body Rpcompositemmessage corresponding to the remote calling identifier gid, the target structure body Rpcompositemmessage comprises an access identifier of a target thread, and the target thread is a thread used by the first process for sending the remote asynchronous calling instruction;
judging whether a current remote call is thread safe or not according to the target structure RpcCompositeMessage, wherein the current remote call is a remote call initiated by the first process to the second process;
if so, determining a target function object task according to the target structure RpcompositemAddress, wherein the target function object task comprises an asynchronous completion function RpcompleteRouteine which is used for indicating the data called by the current remote call;
registering a target signal processing function ApcRouteeApcRoute in the target thread to receive a target signal through the target thread, and processing the target signal through the target signal processing function ApcRoute, wherein the target signal carries a target function object task;
and delivering the target signal to the target thread for processing based on the access identification of the target thread.
2. The method of claim 1, wherein prior to sending a remote asynchronous call instruction by the first process to the second process, the method further comprises:
acquiring the target attribute value through the asynchronous call function RpcAllProduceEx, wherein the target attribute value is used for indicating whether the current remote call is safe in thread or not;
acquiring an access identifier of a target thread of the first process;
generating the target structure RpcComositemeAddress according to the access identifier and the target attribute value;
and storing the target structure RpcCompositeMessage to the global dictionary.
3. The method according to claim 1 or 2, wherein said determining a target function object task from said target structure rpccositemessage comprises:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
4. The method of claim 3, wherein delivering the target signal to the target thread for processing based on the access identification of the target thread comprises:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
5. An apparatus for instruction execution, comprising:
the sending unit is used for sending a remote asynchronous call instruction to a second process by using an asynchronous call function RpcAllProduceEx through a first process so that the second process processes according to the remote asynchronous call instruction and returns an asynchronous completion instruction;
a receiving unit, configured to receive the asynchronous completion instruction, where the asynchronous completion instruction carries a remote call identifier gid;
a searching unit, configured to search a target structure rpccompasitemessage from a global dictionary according to the remote call identifier gid, where the global dictionary at least includes the target structure rpccositemessage corresponding to the remote call identifier gid, the target structure rpccositemessage includes an access identifier of a target thread, and the target thread is a thread used by the first process to send the remote asynchronous call instruction;
a judging unit, configured to judge whether a current remote call is thread-safe according to the target structure RpcCompositeMessage, where the current remote call is a remote call initiated by the first process to the second process;
a determining unit, configured to determine a target function object task according to the target structure RpcCompositeMessage when the current remote call thread is safe, where the target function object task includes an asynchronous completion function rpccomplete route, and the asynchronous completion function rpccomplete route is used to indicate data called by the current remote call;
a registering unit, configured to register a target signal processing function apcrroute in the target thread, receive a target signal through the target thread, and process the target signal through the target signal processing function apcrroute, where the target signal carries the target function object task
And the execution unit is used for delivering the target signal to the target thread for processing based on the access identifier of the target thread.
6. The apparatus of claim 5, further comprising:
an obtaining unit, configured to obtain the target attribute value through the asynchronous call function rpccallproceurex, where the target attribute value is used to indicate whether the current remote call is thread-safe;
the obtaining unit is further configured to obtain an access identifier of a target thread of the first process;
a generating unit, configured to generate the target structure RpcCompositeMessage according to the access identifier and the target attribute value;
and the storage unit is used for storing the target structure RpcComositemAddress to the global dictionary.
7. The apparatus according to claim 5 or 6, wherein the determining unit is specifically configured to:
acquiring the asynchronous completion function RpcompleteRoutenine and an execution result function from the target structure RpcompleteAddress, wherein the execution result function is contained in the asynchronous call function RpcAllProduceEx;
and determining the target function object task according to the asynchronous completion function RpcompleteRoutenine and the execution result function.
8. The apparatus of claim 7, wherein the execution unit is specifically configured to:
and calling a pthread _ sigqueue function based on the access identification of the target thread to deliver the target signal to the target thread for processing.
9. An electronic device comprising a memory, a processor, wherein the processor is configured to implement the steps of the method performed by the instructions of any one of claims 1 to 4 when executing a computer management class program stored in the memory.
10. A computer-readable storage medium having stored thereon a computer management-like program, characterized in that: the computer management class program, when executed by a processor, implements the steps of the method performed by the instructions of any of claims 1 to 4.
CN201810701825.4A 2018-06-30 2018-06-30 Instruction execution method and related equipment Active CN110659140B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810701825.4A CN110659140B (en) 2018-06-30 2018-06-30 Instruction execution method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810701825.4A CN110659140B (en) 2018-06-30 2018-06-30 Instruction execution method and related equipment

Publications (2)

Publication Number Publication Date
CN110659140A true CN110659140A (en) 2020-01-07
CN110659140B CN110659140B (en) 2022-01-04

Family

ID=69027693

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810701825.4A Active CN110659140B (en) 2018-06-30 2018-06-30 Instruction execution method and related equipment

Country Status (1)

Country Link
CN (1) CN110659140B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567111A (en) * 2011-12-23 2012-07-11 深圳市融创天下科技股份有限公司 Method, system and terminal device capable of calling asynchronous procedure
US20120260261A1 (en) * 2011-04-07 2012-10-11 Microsoft Corporation Asynchronous callback driven messaging request completion notification
CN103455355A (en) * 2013-09-05 2013-12-18 南京朗睿软件科技有限公司 Android equipment, and asynchronous data uploading method and device for AdapterView of Android equipment
CN107277029A (en) * 2017-06-30 2017-10-20 武汉斗鱼网络科技有限公司 A kind of method of remote procedure call, device and computer equipment
CN107402826A (en) * 2017-06-30 2017-11-28 武汉斗鱼网络科技有限公司 A kind of method and device for carrying out remote procedure call in an asynchronous manner
CN108011909A (en) * 2016-10-28 2018-05-08 北京市商汤科技开发有限公司 Communication means and system, electronic equipment and computer cluster

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120260261A1 (en) * 2011-04-07 2012-10-11 Microsoft Corporation Asynchronous callback driven messaging request completion notification
CN102567111A (en) * 2011-12-23 2012-07-11 深圳市融创天下科技股份有限公司 Method, system and terminal device capable of calling asynchronous procedure
CN103455355A (en) * 2013-09-05 2013-12-18 南京朗睿软件科技有限公司 Android equipment, and asynchronous data uploading method and device for AdapterView of Android equipment
CN108011909A (en) * 2016-10-28 2018-05-08 北京市商汤科技开发有限公司 Communication means and system, electronic equipment and computer cluster
CN107277029A (en) * 2017-06-30 2017-10-20 武汉斗鱼网络科技有限公司 A kind of method of remote procedure call, device and computer equipment
CN107402826A (en) * 2017-06-30 2017-11-28 武汉斗鱼网络科技有限公司 A kind of method and device for carrying out remote procedure call in an asynchronous manner

Also Published As

Publication number Publication date
CN110659140B (en) 2022-01-04

Similar Documents

Publication Publication Date Title
CN109951547B (en) Transaction request parallel processing method, device, equipment and medium
US11550599B2 (en) Method and apparatus for running applet
CN110221968A (en) Method for testing software and Related product
CN108196878A (en) Generation method, device, electronic equipment and the storage medium of application program installation kit
CN108733496B (en) Event processing method and device
CN113986256A (en) Method and device for issuing application program, electronic equipment and storage medium
CN109445836A (en) A kind of management method of sound code file, server and computer readable storage medium
CN111538659A (en) Interface testing method and system for service scene, electronic device and storage medium
CN113434582B (en) Service data processing method and device, computer equipment and storage medium
CN107341106A (en) Application compatibility detection method, exploitation terminal and storage medium
CN110659141B (en) Instruction execution method and related equipment
CN110659140B (en) Instruction execution method and related equipment
CN112181822A (en) Test method and test method for starting time consumption of application program
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112256252B (en) Interface generation method and device, storage medium and electronic equipment
CN111475148A (en) Third-party dependent library isolation method and device, electronic equipment and storage medium
CN107092601B (en) Resource file construction method, resource file application method and device
CN111581578B (en) Interface request processing method and device
CN114625458A (en) Page data processing method and device, electronic equipment and storage medium
CN113935847A (en) Online process risk processing method, device, server and medium
CN112380820A (en) Automatic data backfilling method and device, electronic equipment and computer storage medium
CN111488286A (en) Method and device for independently developing Android module
CN110674491A (en) Method and device for real-time evidence obtaining of android application and electronic equipment
CN112667491A (en) Function test method and device of virtual machine
CN110365738A (en) Localization method, device and storage medium based on Hybird framework

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant