Client / server architecture-based binary code translation service system and method for a constrained system
The binary translation service system, based on a client/server architecture, leverages the high performance of the server side for binary translation, solving the problems of low translation efficiency and strong network dependence in constrained systems. This enables efficient cross-platform application operation and reduces the consumption of computing resources.
Patent Information
- Application Number
- CN202211422517.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2026-03-20
- Estimated Expiration
- 2042-11-14
AI Technical Summary
Existing binary translators suffer from low translation efficiency, high computational resource consumption, strong network dependence, and increased runtime due to frequent interactions in constrained systems, especially on devices with low computing power and small memory capacity, such as mobile phones and tablets.
A binary translation service system (BTaaS) based on a client/server architecture is adopted. This system leverages the high performance of the server for binary translation, reducing frequent interactions between the client and server by transmitting files in a single package, and ensuring the complete execution of the application even in network congestion. The system uses a unified identifier to manage files, supports both static and dynamic binary translators, and coordinates requests from multiple clients through a registry center to optimize translation efficiency.
It enables efficient cross-platform application execution in constrained systems, reduces computational resource consumption and network interaction time, improves translation efficiency, and ensures normal application execution even under unstable network conditions.
Smart Images

Figure CN115718642B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of software migration, and relates to a binary code translation service system and method based on a client / server architecture for a restricted system. BACKGROUND
[0002] Binary translation technology is an important means to solve the problem of application program porting. It can translate the code of the source architecture into the code of the target architecture without recompiling the source code. Binary translation technology can separate the dependence of the application program on the hardware, accelerate the promotion of new platforms, and has important significance in program porting, performance optimization, reverse engineering, security analysis, etc. Binary translation is mainly divided into three types: interpretation execution, static binary translation and dynamic binary translation [1] .
[0003] Static binary translation is an offline compilation technology, which translates the application program of the source architecture into the application program of the target architecture. The advantage of static binary translation is that the translation does not occupy the execution time of the application program, can be translated and optimized to the maximum extent before running, and the translated application program can be executed multiple times. However, static binary translation is deficient in translation completeness, and will encounter challenges in code discovery, code positioning, and handling of self-modifying code.
[0004] Dynamic binary translation is a just-in-time compilation technology, which enables the application program of the source architecture to be translated and executed on the machine of the target architecture. Most dynamic binary translators take code blocks (which can be basic blocks or functions) as the translation granularity, and store the translated code blocks in the code cache during the translation process. In subsequent execution, when the target code block is stored in the code cache, the code block in the code cache can be directly used, without the need for repeated translation. Most dynamic binary translators will further optimize the frequently executed code blocks. Since the translation and optimization of the code blocks are performed at runtime, translating and optimizing on only one restricted device will greatly increase the running time of the application program.
[0005] Most binary translators are mainly divided into three parts in the translation process, first, the machine code is promoted to intermediate code, then the intermediate code is optimized, and finally the intermediate code is generated to the target architecture code. Some terminal user devices such as mobile phones, tablets and the like have low computing power and small memory capacity. When the binary translator optimizes the intermediate code, some complex optimizations require high computing resources, and these limited systems cannot meet the requirements or the optimization time is too long. There are schemes in the industry to introduce a client / server architecture to solve this problem, which places the execution engine of the dynamic binary translator on the client side, focuses on running the translated code, and places the translation engine on the server side, focusing on translating the source architecture code into the target architecture code [2] The limited system can use the strong computing power of the server side to translate and optimize the code, reduce the load of the client side, and achieve the effect of decentralization of the computing power of the server side. However, such binary translators have obvious defects in the translation process of the application program. On the one hand, such binary translators use the code block multiple transmission method to realize the transmission of the code between the client and the server, and the frequent interaction between the two ends increases the running time of the application program; on the other hand, the client and the server send information through network connection, and the client has a strong dependence on the server, so once the network has an error, the application program will be forced to terminate running. Therefore, the prior art needs to be improved to solve the above problems. SUMMARY
[0006] In order to solve the problems in the prior art, the purpose of the present application is to provide a binary code translation service system based on a client / server architecture for a limited system. In the present application, the client and the server have the same architecture, which refers to a computer system based on different instruction set architectures, and the main technical problem to be solved is how to ensure fast response of the client while not occupying the client resources for binary translation as much as possible. The present application makes full use of the high performance of the server side to generate efficient target architecture application programs and serve the subsequent multiple executions of the client. The present application uses the file package one-time transmission method to realize the transmission of the code between the client and the server, thereby reducing the frequent interaction between the client and the server, and the client and the server do not have a strong dependence, and in the extreme case of poor network environment or even no network environment, the complete and correct execution of the application program can be guaranteed, and the client can still normally translate.
[0007] In the present application, the limited system refers to devices such as mobile phones, tablets and the like with less computing resources and small memory capacity.
[0008] The core innovation of the present application is to propose a new computing mode: binary translation as a service (BTaaS), which can meet the efficient translation needs of users in offline distributed computing, cloud computing and other scenarios. BTaaS uses a binary code translation service system based on a client / server architecture, changes the translation mode of traditional binary translators, and provides users with translated efficient application programs using servers, converts binary translation into a service provided to users, thereby shielding the implementation details of the backend from users. After a user submits an application program incompatible with the client architecture to the client, the client first checks whether the local of the client has a previously translated file package of the target architecture (the target architecture is the architecture of the client at this time) (referred to as a target file package, including an application program of the target architecture). If so, execute the corresponding translated application program; if not, send a request to the server. After receiving the request, the server checks whether the local of the server has a previously translated target file package. If so, the server sends the translated target file package to the client; if not, the server sends an untranslated message to the client to trigger the dynamic binary translator of the client to perform translation, and obtains the file package of the source architecture (referred to as a source file package, including an application program of the source architecture + library files and other necessary files) from the client. Then, the binary translator of the server is triggered to translate the source file package, and the translated target file package is saved.
[0009] When the client sends a request to the server and waits for a response from the server for more than a threshold value, the source file package is handed over to the dynamic binary translator in the client for translation.
[0010] Existing other binary translators take code blocks as the granularity, and before translating the code blocks, they first determine whether the code blocks have been translated, and then proceed according to the determination of whether the translation has been performed. The present application takes files as the granularity, compared with the existing method taking code blocks as the granularity, the application program of the target architecture generated by the server can be translated once and used everywhere; in the client / server scenario, the interaction between the client and the server can be reduced, and the running time can be reduced.
[0011] Because the server side has strong computing power, it can receive multiple client requests at the same time. Therefore, the first core problem that the application needs to solve is whether the server side can coordinate multiple client requests and improve translation efficiency on the basis of correct execution. The optimization goals include but are not limited to the optimization of the execution efficiency of the server side for multiple requests, and the storage management of the server side for the translated application. In order to solve the above problems well, the application selects a server as a registration center to coordinate multiple client requests, and the registration center is responsible for receiving client requests, finding the information of the best server according to the client requests, and forwarding the server information to the client for subsequent operation. The registration center optimizes the execution efficiency of the request by using the source application link method and other information. If the link method of the source application is static linking, the server side will use static binary translator and dynamic binary translator for translation respectively, if the static binary translator fails to translate, the dynamic binary translator will be used, if the static binary translator succeeds, the efficiency of the translation results of the two translators will be compared, and the translation result with higher efficiency will be selected. If the link method of the source application is dynamic linking, the server side will directly use the dynamic binary translator for translation. The registration center manages the translated application by storing the translated information, including the identifier of the translated application, the architecture of the target application and the corresponding server information.
[0012] The server side of the binary code translation service system of the application supports the installation of multiple static binary translators and dynamic binary translators. Because the static binary translator and the dynamic binary translator store the translated code in different forms: the static binary translator can generate the application program of the target architecture after translation, which can be directly called later, while the dynamic binary translator translates and executes simultaneously, and finally does not generate an executable target architecture application program, but stores the translated code in the form of code blocks in the code cache during execution. Before translating the code block, it will be judged that some code blocks have been translated, but because the code cache space is limited, part of the translated code block may be overwritten. If the target code of the code block is stored in the code cache, the code in the code cache is executed, if the target code block of the code block is not stored in the code cache, the target code block is stored in the code cache after translation. The second core problem that the application needs to solve is that no matter how the server side selects the translator, the client can correctly and effectively use the translation result of the server side.
[0013] In the binary code translation service system, in order to enable the client to correctly utilize the translation result of the server, the client and the server need to form a unified identifier for the same application program. One identifier can only correspond to one application program. The calculation method of the identifier needs to be as simple as possible, and the calculation time needs to be as short as possible, so as to reduce the influence on the overall running time. Secondly, the method of calculating the identifier between the client and the server should be the same, and the method of calculating the identifier between multiple clients should be the same, otherwise conflicts will occur. The unified identifier can be generated by using MD5, SHA256 and other hash algorithms. The unified identifier can be used for storage and search of the source file package and the target file package of the client and the server.
[0014] In static binary translation, the form of the generated target code is a target executable file, which can be directly executed by the client; in dynamic binary translation, the form of the generated target code is a target code block, which cannot be executed alone, and the client needs to call the corresponding dynamic binary translator to execute the code block. In the binary code translation service system, in order to facilitate the execution of the client, the server needs to provide the client with the same form of target architecture code, i.e. the target executable file. Therefore, the server needs to use dynamic information such as changes in registers, changes in control flow and changes in memory distribution, etc. and target architecture code blocks to organize the translation result of the dynamic binary translator into a target architecture executable file together with other file related information (such as translated library functions).
[0015] The system architecture diagram of the present application is shown in Figure 1 The present application is based on a client / server architecture, and the client sends a request to a buffer queue. The server obtains the request to be processed from the buffer. The server can execute multiple tasks of the request at the same time. The binary translator of the client only needs to ensure that the application program can be correctly translated and executed and perform some simple optimization to respond to the user as quickly as possible. The binary translator of the server can optimize the code as much as possible to generate an efficient application program of the target architecture. The translation results of multiple binary translators of the server are uniformly managed by a storage system. In the industry, binary translators are divided into two types according to the number of translatable source architectures: general binary translators that can translate multiple source architectures and specialized binary translators that can translate one source architecture. By setting up a registration center, the most suitable translator can be selected according to the content of the source file and the translation level of the translator. Based on these premises, as shown in Figure 2 The binary code translation service system of the present application supports 16 deployment schemes, which are as follows:
[0016] 1) Client chooses one or more specialized dynamic binary translator, server chooses one or more specialized static binary translator;
[0017] 2) Client chooses one or more specialized dynamic binary translator, server chooses one general static binary translator;
[0018] 3) Client chooses one or more specialized dynamic binary translator, server chooses one or more specialized dynamic binary translator;
[0019] 4) Client chooses one or more specialized dynamic binary translator, server chooses one general dynamic binary translator;
[0020] 5) Client chooses one or more specialized dynamic binary translator, server chooses one general static binary translator and one general dynamic binary translator;
[0021] 6) Client chooses one or more specialized dynamic binary translator, server chooses one general static binary translator and one or more specialized dynamic binary translator;
[0022] 7) Client chooses one or more specialized dynamic binary translator, server chooses one or more specialized static binary translator and one general dynamic binary translator;
[0023] 8) Client chooses one or more specialized dynamic binary translator, server chooses one or more specialized static binary translator and one or more specialized dynamic binary translator;
[0024] 9) Client chooses one general dynamic binary translator, server chooses one or more specialized static binary translator;
[0025] 10) Client chooses one general dynamic binary translator, server chooses one general static binary translator;
[0026] 11) Client chooses one general dynamic binary translator, server chooses one or more specialized dynamic binary translator;
[0027] 12) Client chooses one general dynamic binary translator, server chooses one general dynamic binary translator;
[0028] 13) Client chooses one general dynamic binary translator, server chooses one general static binary translator and one general dynamic binary translator;
[0029] 14) Client chooses one general dynamic binary translator, server chooses one general static binary translator and one or more special dynamic binary translators;
[0030] 15) Client chooses one general dynamic binary translator, server chooses one or more special static binary translators and one general dynamic binary translator;
[0031] 16) Client chooses one general dynamic binary translator, server chooses one or more special static binary translators and one or more special dynamic binary translators.
[0032] The present application also proposes a method for binary code translation using the above binary code translation service system, which comprises the following steps as shown in the figure: Figure 3
[0033] Step one, the client judges the application program
[0034] The client judges whether the translated target file package exists in the local, if yes, the application program of the target architecture can be directly executed, if not, the application program identifier is sent to the server to request the target file package, and the reply from the server is waited. If the waiting time exceeds the threshold value (the threshold value is set in relation to the network bandwidth and delay, and is set according to the actual situation) and the reply from the server is still not obtained, the dynamic binary translator in the local is triggered to translate, and then the step five is jumped to.
[0035] Step two, the server receives the request from the client and processes
[0036] The server queries whether the target file package exists in the local:
[0037] 1) If the server finds the file package, the server sends the target file package message to the client, and sends the target file package back to the client.
[0038] 2) If the server does not find the file package, the server sends the target file package message to the client, requests the source file package, and waits for the reply from the client. If the waiting time exceeds the threshold value and the reply from the client is still not obtained, the task is ended.
[0039] Step three, the client receives the reply from the server and performs according to the request result
[0040] The client receives the reply from the server, and has different operations for different request results:
[0041] 1) If the server side reply is that the target file package is found, the translated target file package is received and stored in the storage system of the client, and the application program is executed, and then step five is jumped to.
[0042] 2) If the server side reply is that the target file package is not found, the source file package is sent to the server side, and the dynamic binary translator of the client is triggered to translate.
[0043] Step four, the server side receives the source file package for translation
[0044] The server side receives the source file package sent by the client, triggers the binary translator of the server side to translate the source file package. After the translation is completed, the server side stores the translated target file package in the storage system of the server side.
[0045] Step five, the program ends
[0046] The program ends, the client ends the task, and releases the occupied resources.
[0047] The beneficial effects of the application include: the application designs a binary code translation service system based on the client / server architecture, which can realize efficient cross-platform running of the application program. The binary translators of the client and the server are triggered to translate when the application program is executed for the first time. The lightweight dynamic binary translator of the client only needs to ensure the correct execution of the application program in the first translation and does not need to consider the optimization of the execution performance too much, and the binary translator of the server does not need to consider the execution time of the translator too much, and has enough time to optimize to the maximum extent. In the subsequent execution of the application program, the application program generated by the server does not need to be translated again, which saves the time and computing resources of the client for optimization, realizes one-time translation and multiple executions. The binary translator based on the client / server architecture can better adapt to the current industry trend, so that the computing resources are evenly distributed, even the limited system can complete the execution of the complex application program, improves the execution range of the application program, and saves the reconstruction cost of the application program on the new architecture.
[0048] Compared with the previous dynamic binary translator, the dynamic binary translator on the server side in the application can generate the application program of the target architecture after the translation, which is convenient for subsequent repeated execution. Compared with the previous static binary translator, the application has better compatibility. In the scenario where the dynamic binary translator and the static binary translator are simultaneously provided on the server side, when the translation result of the static binary translator is incomplete, the dynamic binary translator can be used for translation. Compared with the traditional binary translator of the non-client / server architecture, the application can take advantage of the high performance of the server side, and is not limited by the computing resources of the client side, thereby reducing the computing pressure of the client side. The complex optimization and execution are separated, the relatively efficient application program of the target architecture is generated without occupying the running time of the client side, and the storage of the server side is larger, so that the repeated translation caused by insufficient storage space can be reduced. Compared with the previous dynamic binary translator of the client / server architecture, the application can separate most of the optimization time from the running time of the program, and use less time to obtain efficient code. The frequent interaction between the client side and the server side can be reduced, and the time overhead caused by the interaction can be reduced. The client side has no strong dependence on the server side, and the client side can still rely on the local dynamic binary translator to independently complete the translation and execution of the application program in the case of poor network.
[0049] When the application program is translated for the first time, the translation efficiency of the lightweight dynamic binary translator on the client side is low. In order to make up for this short board, the server side can perform binary translation on the commonly used application program on other architectures in advance before all client requests. In this way, even if the client is executing the application program for the first time, the application program translated in advance by the server side can be used. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 It is a translation service system architecture diagram of the application.
[0051] Figure 2 It is a translation service system deployment schematic diagram of the application.
[0052] Figure 3 It is a translation service system flow lane diagram of the application.
[0053] Figure 4 It is a file package storage schematic diagram of the application.
[0054] Figure 5 It is a flowchart of embodiment 1 of the application.
[0055] Figure 6 It is a flowchart of embodiment 2 of the application.
[0056] Figure 7 It is a flowchart of embodiment 3 of the application.
[0057] Figure 8 is the flow chart of the embodiment 4 of the present application.
[0058] Figure 9 is the schematic diagram of the information stored in the registration center of the present application.
[0059] Figure 10 is the overall layout diagram of the embodiment 5 of the present application.
[0060] Figure 11 is the flow chart of the embodiment 5 of the present application. DETAILED DESCRIPTION
[0061] The present application is further explained in conjunction with the following specific examples and drawings. The process, conditions, experimental methods, etc. for implementing the present application are the general knowledge and common sense in the art, and the present application does not have special limitations.
[0062] The present application provides a binary code translation service system for a restricted system based on a client / server architecture, which mainly includes a client and a server, the client is a terminal user device including a mobile phone, a tablet computer and the like, the client supports a dynamic binary translator, can ensure that an application program is correctly translated and executed and performs some simple optimization, and can respond to a user as soon as possible; the server has a large computing power, can support a static binary translator and a dynamic binary translator, and can execute multiple request tasks at the same time.
[0063] The present application also provides a method for performing binary code translation service by using the above binary code translation service system, which includes the following steps:
[0064] Step one, the client judges whether the application program has a target file package in the client storage system; if the application program has a target file package in the local storage system, the client executes the corresponding target application program, and ends the task after completion; if the application program does not have a target file package in the local storage system, the client sends an application program identifier to the server, requests a target file package, and waits for a reply from the server;
[0065] Step two, the server receives a target file package request from the client, queries whether the server stores a target file package; if the server storage system has a target file package, the server sends the target file package to the client; if the server storage system does not have a target file package, the server requests a source file package from the client, and waits for a reply from the client;
[0066] If the server does not respond to the request of the client, the client calls the source file package in the storage system of the client and uses the dynamic binary translator of the client to translate;
[0067] Step three, if the server sends the target file package to the client in step two, the client receives the translated target file package and stores it in the storage system of the client, and executes the target application program, and ends the task after completion; if the server does not send the target file package to the client in step two, the client obtains the source file package from the local storage system and sends it to the server, and triggers the dynamic binary translator of the client to translate, and ends the task after completion;
[0068] Step four, after the server receives the source file package sent by the client, it triggers the binary translator of the server to translate the source file package, and after the translation is completed, the server stores the translated target file package in the storage system of the server, and ends the task after completion.
[0069] The method of the application is specifically described through some embodiments.
[0070] The heavyweight binary translator is a binary translator with higher translation efficiency and better optimization effect relative to the lightweight binary translator. In the following embodiments, the heavyweight binary translator is marked by adding an apostrophe. The computing platforms of the client, client1 and client2, and the computing platforms of the server, server1, server2, server3, server4 and server5, can be based on different instruction set architectures, such as X86, ARM and RISC-V, or different versions of the same instruction set architecture, such as ARM v7 and ARM v8. However, the instruction set architecture and version between the computing platforms of the client and the computing platforms of the server in the same binary translation service system need to be the same. The universal dynamic binary translator UDBT (Universal Dynamic Binary Translation) and UDBT' can be one of the dynamic binary translators such as QEMU and HQEMU. The special dynamic binary translator DBT1' and DBT2' can be one of the dynamic binary translators such as LLPEMU, Instrew and Rv8. The universal static binary translator USBT' can be one of UQBT, etc. The special static binary translator SBT1' and SBT2' can be one of LLBT, FX!32, etc. The storage system uses a file system.
[0071] In the following embodiments, the same strategy is used by the client and the server to manage the storage of the file package. As Figure 4 One possible way to solve this problem is to use a data mapping table to manage the storage of the file package. The mapping relationship of the data is displayed in the form of a table (hereinafter referred to as a sub-table), which records the identifier of the source application, the storage location of the source file package, and the storage location of the target file package, respectively.
[0072] In addition, resource competition occurs among multiple clients. Taking the producer-consumer mode as an example, one possible way to solve this problem is shown. In the embodiment of the present application, the server end is regarded as a consumer, and the client end is regarded as a producer. A fixed-size buffer is set in the server end, which is used to balance the processing capacity of the producer and the consumer, and decouple the data interaction between them. The buffer is implemented by using a first-in-first-out buffer queue. The client sends a request to the buffer queue. The server end obtains the request to be processed from the buffer, and follows the following principles:
[0073] 1) When the buffer is full, the buffer will discard the subsequent requests sent by the client.
[0074] 2) When the buffer is empty, the server end enters a blocked state. When the buffer state is not empty, the server end is awakened.
[0075] Because there are many deployment schemes of the binary code translation service system in the present application, five representative deployment schemes are selected for description in the specific embodiments of the present application. Embodiments one to four all show the request interaction between a single client and a server end. The request coordination between multiple clients and a single server end is extended by default using the above method.
[0076] Embodiment one
[0077] The client selects a dedicated dynamic binary translator, and the server end selects a dedicated dynamic binary translator
[0078] As shown in Figure 5 , the computing platform client1 is a client, the architecture is ISA-A (Instruction Set Architecture-A), and the dynamic binary translator DBT1 and DBT2 are configured. The computing platform server1 is a server end, the architecture is ISA-A, and the dynamic binary translator DBT1' and DBT2' are configured. The application program app1 is based on ISA-B (Instruction Set Architecture-B).
[0079] 1. The computing platform client 1 looks up the local sub-table to see if the address of the target file package app1_target exists. If it does, the target application is executed; if it does not, the computing platform server 1 is sent the source application identifier app1, requesting the target file package app1_target, and waits for a reply from the computing platform server 1. If the waiting time exceeds a threshold value and the computing platform server 1 has not replied, the local dynamic binary translator DBT1 is triggered to perform translation according to the architecture ISA-B of the source application app1, and the process jumps to step 5.
[0080] 2. After the computing platform client 1 sends the request, the computing platform server 1 looks up the local sub-table to see if the address of the target file package app1_target exists according to the identifier app1.
[0081] 1) If it does, the computing platform server 1 sends the computing platform client 1 a message that the target file package app1_target has been found, and sends the target file package app1_target back to the computing platform client 1.
[0082] 2) If it does not, the computing platform server 1 sends the computing platform client 1 a message that the target file package app1_target has not been found, and requests the source file package app1_source (the source application app1 and necessary files such as library files), and waits for a reply from the computing platform client 1. If the waiting time exceeds a threshold value and the computing platform client 1 has not replied, the task is ended.
[0083] 3. After the computing platform client 1 receives the reply from the computing platform server 1, if the reply is that the target file package app1_target has been found, the received target application is run and the local sub-table is updated, and the process jumps to step 5. If the reply is that the target file package app1_target has not been found, the computing platform server 1 is sent the source file package app1_source, and the local dynamic binary translator DBT1 is triggered to perform translation according to the architecture ISA-B of the source application app1. The computing platform client 1 ends the task and releases the occupied resources.
[0084] 4. After the computing platform client 1 sends the source file package app1_source, the computing platform server 1 triggers the corresponding dynamic binary translator DBT1' to perform translation on the source file package app1_source according to the architecture ISA-B of the source application app1, generates the target file package app1_target, stores it in the file system, and updates the local sub-table.
[0085] 5. The program ends.
[0086] Embodiment Two
[0087] Client chooses universal dynamic binary translator, server chooses universal dynamic binary translator
[0088] As shown in Figure 6 , computing platform client1 is a client, with architecture ISA-A, and is configured with dynamic binary translator UDBT. Computing platform server2 is a server, with architecture ISA-A, and is configured with dynamic binary translator UDBT'. Application app1 is based on ISA-B.
[0089] 1. Computing platform client1 looks up the local sub-table to see if the address of target file package app1_target exists. If it does, the target application is executed; if it does not, computing platform client1 sends source application identifier app1 to computing platform server2, requests target file package app1_target, and waits for a reply from computing platform server2. If the waiting time exceeds a threshold value and computing platform server2 has not replied, computing platform client1 triggers the local dynamic binary translator UDBT to translate according to the architecture ISA-B of source application app1, and then jumps to step 5.
[0090] 2. After computing platform server2 receives the request from computing platform client1, it looks up the local sub-table to see if the address of target file package app1_target exists according to identifier app1.
[0091] 1) If it does, computing platform server2 sends a message to computing platform client1 that target file package app1_target has been found, and sends target file package app1_target back to computing platform client1.
[0092] 2) If it does not, computing platform server2 sends a message to computing platform client1 that target file package app1_target has not been found, requests source file package app1_source (source application app1 + library files and other necessary files), and waits for a reply from computing platform client1. If the waiting time exceeds a threshold value and computing platform client1 has not replied, the task is ended.
[0093] 3. After receiving a response from computing platform server2, if the response indicates the target application has been found, client1 runs the received target application and updates its local sub-table, then proceeds to step 5. If the response indicates the target application has not been found, client1 sends the source file package app1_source to computing platform server2, and simultaneously triggers the dynamic binary translator UDBT to perform translation based on the ISA-B architecture of the source application app1. Client1 then terminates the task and releases the resources it has occupied.
[0094] 4. The computing platform server2 receives the source file package app1_source sent by the computing platform client1. Based on the ISA-B architecture of the source application app1, it triggers the dynamic binary translator UDBT' on the computing platform server2. The dynamic binary translator UDBT' translates the source file package app1_source. During the translation process, it uses the translated code blocks and dynamic information to generate the target file package app1_target, stores it in the file system, and updates the local sub-table.
[0095] 5. The program has finished running.
[0096] Example 3
[0097] The client selects a general dynamic binary translator, while the server selects either a general dynamic binary translator or a general static binary translator.
[0098] like Figure 7 As shown, computing platform client1 is the client-side, with an ISA-A architecture, and is configured with the lightweight dynamic binary translator UDBT. Computing platform server3 is the server-side, with an ISA-A architecture, and is configured with the heavyweight static binary translator USBT' and the dynamic binary translator UDBT'. Application app1 is based on ISA-B.
[0099] 1. The computing platform client1 checks its local sub-table to see if the address of the target file package app1_target exists. If it does, the target application is executed; otherwise, the source application identifier app1 is sent to the computing platform server3, requesting the target file package app1_target, and the client1 waits for a response from the computing platform server3. If the waiting time exceeds the threshold and no response is received from the computing platform server3, the local dynamic binary translator UDBT is triggered to perform translation, and then the process jumps to step 5.
[0100] 2. After receiving the request from the client, the server searches the local sub-table for the address of the target file package app1_target according to the source application identifier app1.
[0101] 1) If the target file package app1_target is found, the server sends a message to the client that the target file package app1_target has been found, and sends the target file package app1_target back to the client.
[0102] 2) If the target file package app1_target is not found, the server sends a message to the client that the target file package app1_target has not been found, and requests the source file package app1_source (the source application app1 and necessary files such as library files), and waits for a reply from the client. If the waiting time exceeds a threshold value and the server still does not receive a reply from the client, the server ends the task.
[0103] 3. After receiving the reply from the server, the client runs the received target application and updates the local sub-table if the reply is that the target file package app1_target has been found, and then jumps to step 5. If the reply is that the target file package app1_target has not been found, the client sends the source file package app1_source to the server and triggers the dynamic binary translator UDBT to perform translation. The client ends the task and releases the occupied resources.
[0104] 4. After receiving the source file package app1_source from the client, the server triggers the dynamic binary translator UDBT' and the static binary translator USBT' to perform translation on the source file package app1_source. If the static binary translator USBT' can independently complete the translation, the server compares the running performance of the result file packages of the two translators after the translation is completed, selects the result target file package app1_target with the highest performance, and stores the result target file package app1_target in the file system. If the static binary translator USBT' cannot independently complete the translation, the server stores the result target file package app1_target of the dynamic binary translator UDBT' in the file system and updates the local sub-table.
[0105] 5. The program ends.
[0106] Embodiment Four
[0107] The client selects a general dynamic binary translator, and the server selects multiple special dynamic binary translators and a special static binary translator
[0108] AsFigure 8 As shown, the computing platform clientl is a client, with architecture ISA-A, configured with a dynamic binary translator UDBT, the computing platform server4 is a server, with architecture ISA-A, configured with multiple special-purpose dynamic binary translators and multiple special-purpose static binary translators, including static binary translators SBT1', SBT2' and dynamic binary translators DBT1', DBT2'. The application app1 is based on ISA-B. For a client request, only one DBT (e.g. DBT1' in this embodiment) and one SBT (e.g. SBT1' in this embodiment) are needed; the server supports processing multiple concurrent client requests;
[0109] 1. The computing platform clientl checks whether the address of the target file package app1_target is stored in the local sub-table. If yes, the target application is executed; if not, the computing platform server4 is sent the source application identifier app1, requesting the target file package app1_target, and waits for a reply from the computing platform server4. If the waiting time exceeds a threshold value and no reply from the computing platform server4 is received, the local dynamic binary translator UDBT is triggered to perform translation, and the process jumps to step 5.
[0110] 2. After receiving the request from the computing platform clientl, the computing platform server4 checks whether the address of the target file package app1_target is stored in the local sub-table according to the source application identifier app1.
[0111] 1) If yes, the computing platform server4 sends the computing platform clientl a message that the target file package app1_target has been found, and sends the target file package app1_target back to the computing platform clientl.
[0112] 2) If not, the computing platform server4 sends the computing platform clientl a message that the target file package app1_target has not been found, requests the source file package app1_source (the source application app1 and necessary files such as library files), and waits for a reply from the computing platform clientl. If the waiting time exceeds a threshold value and no reply from the computing platform clientl is received, the task is ended.
[0113] 3. After the computing platform client 1 receives the reply from the computing platform server 4, if the reply is found, the received target application is run and the local sub-table is updated, and then the process jumps to step 5. If the reply is not found, the source file package app1_source is sent to the computing platform server 4, and the dynamic binary translator UDBT is triggered to perform translation. The computing platform client 1 ends the task and releases the occupied resources.
[0114] 4. The computing platform server 4 receives the source file package app1_source sent by the computing platform client 1, and triggers the corresponding dynamic binary translator DBT1' and static binary translator SBT1' of the computing platform server 4 according to the architecture ISA-B of the source application app1 to perform translation on the file package app1_source respectively. If the static binary translator SBT1' can independently complete the translation, the running performance of the target file packages of the two translators is compared after the translation is completed, the target file package app1_target with the highest performance is selected, and is stored in the file system. If the static binary translator SBT1' cannot independently complete the translation, the target file package app1_target of the dynamic binary translator DBT1' is stored in the file system, and the local sub-table is updated.
[0115] 5. The program ends.
[0116] Example Five
[0117] Multiple different architecture clients, and a server cluster composed of multiple different architectures
[0118] In the above embodiment, the client and the server are both of one architecture. The binary code translation service system in the application converts binary translation into a service to users, and therefore needs to adapt to multiple architectures. The registration center is responsible for receiving client requests and allocating the best server according to the client's request in the cluster. The registration center can be of any architecture, and is responsible for load balancing of the server cluster, such as Figure 9 As shown in the figure, the registration center maintains a service registration table, records the server identifier, server IP address, port number, source architecture and target architecture supported by the binary translator configured on the server, and the last use time of the server, and the registration center also saves the server storage situation summary table corresponding to all translated file packages, including the identifier of the source application, the target application architecture and the server identifier.
[0119] As shown in the figure, the registration center maintains a service registration table, records the server identifier, server IP address, port number, source architecture and target architecture supported by the binary translator configured on the server, and the last use time of the server, and the registration center also saves the server storage situation summary table corresponding to all translated file packages, including the identifier of the source application, the target application architecture and the server identifier. Figure 10As shown, the computing platforms clientl, client2 are clients, the computing platform clientl is based on architecture ISA-A, and the computing platform client2 is based on architecture ISA-B. The computing platforms serverl, server2, server3, server4, server5, and registry_center collectively form a service cluster. The computing platforms serverl, server2, server3, and server4 are configured the same as in the foregoing embodiment. The computing platform server5 is based on architecture ISA-B. The registry_center is not limited to an architecture. The application program app 1 is based on ISA-B, and the application program app2 is based on ISA-C.
[0120] The execution flow is as shown in FIG. 4. Figure 11 As shown, the client sends an identifier of a source application program, an architecture of the source application program, and a linking manner of the source application program to the registry_center, and requests the registry_center to assign a server. After receiving the request of the client, the registry_center queries whether a server has translated the total table, and the specific classification is as follows.
[0121] 1. If a server has translated the total table and the architecture of the target application program is the same, the server address is sent to the client.
[0122] 2. Otherwise, selection is made according to the linking manner of the source application program, the architecture of the source application program, the architecture of the target application program, the idle condition of the server, and the configuration of the binary translator on the server. The principle to be followed is that the source architecture and the target architecture supported by the binary translator on the server need to support the architecture of the source application program and the architecture of the target application program, respectively:
[0123] 1) If it is statically linked, a server containing a static binary translator is preferentially selected.
[0124] 2) If it is dynamically linked, a server not containing a static binary translator is preferentially selected.
[0125] If there are multiple servers meeting the conditions in the foregoing process, selection is made according to the longest idle algorithm, and if there are still multiple servers meeting the conditions, random selection is made.
[0126] 3. The client receives a reply of the registry_center:
[0127] 1) If the source file package has been translated, the client sends an identifier of the source application program and the like to the server corresponding to the IP and port number of the computing platform replied by the registry_center, and requests the server to send a target file package.
[0128] 2) If the source file package has not been translated, send a content request to the corresponding server to translate the source file package according to the IP and port number of the computing platform in the reply of the registry center.
[0129] 4. The server receives the request of the client:
[0130] 1) If the source file package has been translated, return the target file package to the client.
[0131] 2) If the source file package has not been translated, trigger the binary translator to translate the source file package:
[0132] a) If the translation is successful, update the sub-table of the server, and send a message to the registry center to synchronize the update of the general table and the service registration table information.
[0133] b) If the translation fails, send the necessary information such as the architecture of the source application program (the purpose is to request a server without static binary translator), the architecture of the source application program, the architecture of the target application program, etc. to the registry center to request to replace the server without static binary translator. After receiving the IP and port of the new server, the old server transfers the information sent by the client to the new server, and jumps to step 4.
[0134] 5. If the client receives the target file package sent by the server, execute the target application program and update the local sub-table.
[0135] The following takes the computing platform client1 as an example:
[0136] 1. The computing platform client1 sends a request to the registry center registry_center.
[0137] 2. The registry center registry_center receives the request, queries the best server as the computing platform server1 according to the architecture ISA-B of the source application program app1, the architecture ISA-A of the computing platform client1 and the linking mode of the source application program app1, and the computing platform server1 has translated the source application program app1. The registry center registry_center sends the relevant information to the computing platform client1.
[0138] 3. The computing platform client1 receives the information that the computing platform server1 has translated the source application program app1, sends the identifier of the source application program and the architecture ISA-A of the target application program to the computing platform server1 to request the target file package.
[0139] 4. The computing platform server1 receives the request, queries the target file package, and sends the target file package to the computing platform client1. The computing platform client1 releases the occupied resources.
[0140] 5. The computing platform client1 receives the target file package, executes the target application program, and updates the local sub-table.
[0141] 6. End the task.
[0142] Reference
[0143] [1] Ma Xiangning. Key technology research of binary translation [D]. Graduate School of the Chinese Academy of Sciences (Institute of Computing Technology), 2004.
[0144] [2] Chinese invention patent, publication number: CN101504613A, distributed dynamic binary translation method for limited system.
[0145] The protection scope of the present application is not limited to the above embodiments. Changes and advantages that can be thought of by those skilled in the art without departing from the spirit and scope of the present application are included in the present application, and are protected by the appended claims.
Claims
1. A binary code translation service system based on a client / server architecture for constrained systems, characterized in that, The translation service utilizes a server to provide clients with pre-translated applications, transforming binary translation into a service offered to users, thus shielding them from the backend implementation details. The translation service system comprises a client and a server. The client and server share the same architecture, which refers to computer systems based on different instruction set architectures. The client refers to end-user devices, including mobile phones and tablets, and supports dynamic binary translators. The server is deployed on a server, supports both static and dynamic binary translators, and can execute multiple request tasks simultaneously. The server coordinates multiple client requests, optimizes the execution efficiency of multiple requests, and stores and manages the translated application during the service process. The coordination of multiple client requests is achieved by selecting a server in the system as a registry center. The registry center is responsible for allocating services, receiving client requests, finding the best server information based on the client requests, and forwarding the server information to the client for subsequent operations. The optimization of the execution efficiency of multiple requests is coordinated by the registry center according to the linking method of the source application. If the source application is linked statically, the server uses both a static binary translator and a dynamic binary translator for translation. If the static binary translator fails, the translation result of the dynamic binary translator is used. If the static binary translator succeeds, the efficiency of the two translators is compared, and the more efficient translation result is selected. If the source application is linked dynamically, the server directly uses the dynamic binary translator for translation. The translated application is managed by storing the translated information in the registry center.
2. The binary code translation service system as described in claim 1, characterized in that, The system translates binary data into a service provided to the user, shielding the user from the implementation details of the backend. The client and server use a single file packet transmission method to transfer code between the client and server, and there is no strong dependency between the client and server. Even if communication between the client and server is not smooth, the application can still maintain complete and correct execution.
3. The binary code translation service system as described in claim 1, characterized in that, The static binary translator and the dynamic binary translator store the translated code in different ways: the static binary translator can generate an application for the target architecture after translation, which can be directly called later; the dynamic binary translator translates and executes at the same time, and does not generate an executable application for the target architecture in the end, but stores the translated code in the form of code blocks in the code cache during the execution process. Before translating a code block, the dynamic binary translator will check if the target code for that code block is in the code cache. If the target code for that code block is in the code cache, the code in the code cache will be executed. If the target code block is not in the code cache, the target code block will be stored in the code cache after the translation is completed.
4. The binary code translation service system as described in claim 1, characterized in that, The client and the server form a unified identifier for the same application. Each unified identifier corresponds to a unique application. The unified identifier is used for storing and searching source and target file packages on the client and server sides, and for the client to correctly use the translation results from the server side.
5. The binary code translation service system as described in claim 1, characterized in that, The server-side utilizes dynamic information and target architecture code blocks to organize the translation results of the dynamic binary translator into a target architecture executable file, including the target architecture code blocks, for the client to effectively use the server-side translation results.
6. The binary code translation service system as described in claim 1, characterized in that, The binary code translation service system includes 16 deployment schemes, including: 1) The client uses one or more dedicated dynamic binary translators, and the server uses one or more dedicated static binary translators; 2) The client uses one or more dedicated dynamic binary translators, and the server uses one general-purpose static binary translator; 3) The client uses one or more dedicated dynamic binary translators, and the server uses one or more dedicated dynamic binary translators; 4) The client uses one or more dedicated dynamic binary translators, and the server uses one general-purpose dynamic binary translator; 5) The client uses one or more dedicated dynamic binary translators, and the server uses one general-purpose static binary translator and one general-purpose dynamic binary translator; 6) The client uses one or more dedicated dynamic binary translators, and the server uses one general static binary translator and one or more dedicated dynamic binary translators; 7) The client uses one or more dedicated dynamic binary translators, and the server uses one or more dedicated static binary translators and one general dynamic binary translator; 8) The client uses one or more dedicated dynamic binary translators, and the server uses one or more dedicated static binary translators and one or more dedicated dynamic binary translators; 9) The client uses one general-purpose dynamic binary translator, and the server uses one or more dedicated static binary translators; 10) The client uses one general-purpose dynamic binary translator, and the server uses one general-purpose static binary translator; 11) The client uses one general-purpose dynamic binary translator, and the server uses one or more dedicated dynamic binary translators; 12) The client uses one general-purpose dynamic binary translator, and the server uses one general-purpose dynamic binary translator; 13) The client uses one general-purpose dynamic binary translator, and the server uses one general-purpose static binary translator and one general-purpose dynamic binary translator; 14) The client uses one general-purpose dynamic binary translator, and the server uses one general-purpose static binary translator and one or more dedicated dynamic binary translators; 15) The client uses one general-purpose dynamic binary translator, and the server uses one or more dedicated static binary translators and one general-purpose dynamic binary translator; 16) The client uses one general-purpose dynamic binary translator, and the server uses one or more dedicated static binary translators and one or more dedicated dynamic binary translators.
7. A binary code translation service method based on a client / server architecture for constrained systems, characterized in that, The method utilizes the binary code translation service system as described in any one of claims 1-6, and the method includes the following steps: when a user submits an application that is incompatible with the client architecture to the client, the client first checks whether the client's local storage contains the previously translated target architecture file package; If so, execute the corresponding translated application; If not, a request is sent to the server. After receiving the request, the server will check if the previously translated target file package exists locally on the server. If it does, the translated target file package will be sent to the client. If it has not been translated, a message indicating that it has not been translated is sent to the client to trigger the client's dynamic binary translator to perform the translation, while retrieving the source architecture file package from the client. Then, the server-side binary translator is triggered to translate the source file package and save the translated target file package.
8. The binary code translation service method as described in claim 7, characterized in that, The method uses files as the granularity. Before translating a file, it first determines whether the file has been translated before, and then proceeds with the subsequent process based on whether the file has been translated.
Citation Information
Patent Citations
Distributed dynamic binary translation method used for limited system
CN101504613A
Service robot cloud platform interface system based on SOA and working method thereof
CN105872094A