PROXIES FOR NATIVE CODE ACCESS
20170228269 · 2017-08-10
Inventors
Cpc classification
G06F9/45504
PHYSICS
G06F9/44521
PHYSICS
International classification
Abstract
A device includes a processor coupled to a non-transitory storage device couple which may store machine instructions executable by the processor to implement a first Java Native Interface (JNI) proxy and a JNI bridge. The JNI proxy. Through the use of the JNI proxy, native code may be accessed.
Claims
1. A mobile device, comprising: a processor; a non-transitory storage device coupled to the processor and storing; machine instructions executable by the processor to implement a first Java Native Interface (JNI) proxy and a JNI bridge; wherein the first JNI proxy is to cause the processor to receive a JNI call from a second JNI proxy on a computing device over a network and forward the received JNI call to the JNI bridge; wherein the JNI bridge contains a data structure to identify locations of native code on the mobile device corresponding to JNI calls; and wherein the JNI bridge is to receive the JNI call from the JNI proxy, to determine the location of native code corresponding to the received JNI proxy, and to cause the native code to be executed by the processor.
2. The mobile device of claim 1 wherein the first JNI proxy on the non-transitory storage device of the mobile computing device is to receive a result of an execution of the native code and to provide said result over the network to the computing device's second JNI proxy.
3. The mobile device of claim 1 wherein the native code is not Java code.
4. The mobile device of claim 1 wherein the native code is to access a hardware resource on the mobile device.
5. The mobile device of claim 4 wherein the hardware resource is at least one of a speaker, a display, a microphone, and a button.
6. A computing device, comprising: a processor; and a non-transitory storage device coupled to the, processor and storing machine instructions executable by the processor to implement a first Java Native Interface (JNI) proxy and a JNI bridge, and also storing first native code; wherein, when the JNI bridge receives a JNI call for access to native code, the JNI bridge is to determine whether the requested native code is resident on the computing device or resident on a mobile device accessible to the computing device over a network; and wherein, if the native code associated with the JNI call is resident on the mobile device, the JNI bridge provides the JNI call to the JNI proxy to forward the first JNI call to a second JNI proxy on the mobile device to thereby cause the native code on the mobile device to be accessed.
7. The computing device of claim 6 wherein if the native code associated with the JNI call is resident on the computing device, the first bridge does not provide the JNI call to the first JNI proxy and instead causes the native code resident on the computing device to be executed.
8. The computing device of claim 6, if the native code associated with the JNI call is resident on the mobile device, the first JNI proxy is to receive a result of an execution of the native code over the network from the second JNI proxy.
9. The computing device of claim 6 wherein the JNI call is to use native code to access a hardware resource on the mobile device and the JNI bridge is to determine that said native code is resident on the mobile device.
10. The computing device of claim 9 wherein the hardware resource is at least one of a speaker, a display, a microphone, and a button.
11. A method, comprising: determining, by a computing device and based on a Java Native Interface (JNI) call for native code, whether the native code associated with the JNI call is resident on the computing device or on a mobile device; if the native code is resident on the computing device, executing the native code by the computing device; and if the native code is resident on the mobile device, providing the JNI call to a JNI proxy on the computing device and forwarding, by the JNI proxy on the computing device, the JNI call to a JNI proxy on the mobile device, and executing the native code on the mobile device.
12. The method of claim 11 further comprising, if the native code is resident on the mobile device, providing the JNI call from the JNI proxy on the mobile device to a JNI bridge on the mobile device.
13. The method of claim 12 wherein determining whether the native code associated with the JNI call is resident on the computing device or on the mobile device comprises accessing a data structure in a JNI bridge on the computing device, said data structure specifying native code locations.
14. The method of claim 11 wherein, if the native code is resident on the mobile device, the method further comprises executing the native code to access a hardware resource on the mobile device including at least one of a speaker, a display, a microphone, and a button.
15. The method of claim 11 wherein, if the native code is resident on the mobile device, the method further comprises generating a response by the native code and providing the response through the JNI proxy on the mobile device to the JNI proxy on the computing device.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0002] For a detailed description of various examples, reference will now be made to the accompanying drawings in which:
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
DETAILED DESCRIPTION
[0009] Certain terms are used throughout the following description and claims to refer to particular system components. As one skilled in the art will appreciate, different companies may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following discussion and in the claims, the terms “including” and “comprising” are used in an open-ended fashion, and thus should be interpreted to mean “including, but not limited to . . . .” Also, the term “couple” or “couples” is intended to mean either an indirect or direct wired or wireless connection. Thus, if a first device couples to a second device, that connection may be through a direct connection or through an indirect connection via other devices and connections.
[0010]
[0011] The mobile device 100 may store one or more applications (“apps”) 110 for use by a user of the mobile device 100. The apps may perform any of a variety of functions. Apps 110 may be implemented in a variety of programming language. In one implementation an app 110 is implemented in the Java programming language.
[0012] Each app 110 may comprise one or more modules. In the example of
[0013]
[0014] For each software module hat executable on either the mobile device 100 or on the computing device 150, the mobile device 100 determines on which device that particular software module should be executed. This determination is made independently for each software module, so that one software module may be executed on the mobile device 100 while another software module may be executed on the computing device 150. In general, all software modules may be determined to be best executed on the mobile device, or all software modules may be determined to execute on the computing device 150. Further still, the determination may result in a mix of software module execution on both the mobile device 100 and the computing device 150.
[0015] Determining on which device to have a particular module executed is referred to as “offloading” the module. Any suitable technique for determining how to offload the software modules may be employed. In one example, the offloading decision is made based, on considerations of execution speed and power consumption. For a particular module of an app to be executed on the mobile device, the mobile device will consume power (e.g., battery power) to execute that module, and it will take the mobile device a certain amount of time to execute the module. On the other hand, the computing device could execute the same module and, in that case, the mobile device would not have to consume power to execute the module but would have to expend power to communicate with the computing device 150 (e.g., to send and receive wireless communications on its local wireless LAN or with respect to a base station). Further, the time to execute the module on the computing device 150 would also include the time required to transmit a request and data from the mobile device 100 to the computing device 150 and the time to receive any responses back to the mobile device from the computing device. In accordance with an implementation, the mobile device considers both power expenditure and speed issues to determine whether to offload a given module for execution on the computing device 150.
[0016] Equation (1) below compares the speed of executing the module on the mobile device versus the speed of executing the module on the computing device:
[0017] where t.sub.m is the computation time of the offloading candidate module on the mobile device (i.e., the amount of time it would take for the mobile device to execute the module), s.sub.m and s.sub.s are the computation speed of the candidate module on the mobile device and the computing device, respectively, d is the data transfer overhead (e.g., the quantity of data to be transferred between mobile device and computing device), and B is the bandwidth of the communication link between the mobile device and the computing device. The left-hand side of equation (1) above computes the amount of time the module will take to execute if offloaded to the computing device 150 plus the amount of time for data transfer between mobile device 100 and computing device 150. The right-hand side of equation (1) is the computation time of the module on the mobile device 100. The two computation times can be compared to determine on which device (mobile device 100 or computing device 150) the module would execute most expeditiously considering also the time required for data transmissions between the devices if the module were offloaded.
[0018] Equation (2) below analyzes the power consumption effects on the mobile device based on whether the mobile device or the computing device execute the module.
[0019] where P.sub.w(B) represents the power consumption of the mobile device in transmitting and receiving data (e.g., via its wireless local area network or wireless communications with a base station), P.sub.m is the power consumption of the mobile device. The power consumption may be a function of bandwidth—higher bandwidth communications generally result in higher power consumption of the mobile device. The left-hand side of equation (2) computes the energy expended by the mobile device 100 in exchanging data d with the computing device 150 if the module were offloaded to the computing device. In that case, the mobile device would only be required to send data to and receive data from the computing device and not expend energy in executing the module itself. The right-hand side of equation (2) computes the energy expended by the computing device in executing the module at a power consumption level of P.sub.m for time t.sub.m.
[0020] Referring back to
[0021] The data required by equations (1) and (2) above are provided by the runt-time profiler 162 and the network profile 164 to the offload planner 160 which computes equations (1) and (2). In one example, the offload planner 160 makes a determination to offload the module if both the equalities in equations (1) and (2) favor execution on the computing device 150. That is, offloading to the computing device 150 may occur if:
[0022] it would be faster to execute the module on the computing device than on the computing device taking the data transfer time into account, and
[0023] power consumption on the mobile device would be less if the module were offloaded than if the module were executed on the mobile device
[0024] The following discussion assumes that a decision to offload a software module to the computing device 150 has indeed been made. In the example of
[0025] While executing thread R′ on the computing device 150 (e.g., while executing a module of an app that has been offloaded to the computing device), the thread R′ may need to access a hardware resource 180 on the mobile device 100. The hardware resource may include, for example, one or more hardware devices of the mobile device 100 such as a speaker, a display, a microphone, and a button. The display may be a non-touch or a touch sensitive display. The button may be a physical button provided on the display and/or may be a soft button implemented on the display itself (in the case in which the display is a touch-sensitive display). As described below, the thread R′ may access the hardware resource 180 using the JNI bridge 154 and JNI proxy 156 on the computing device 150, as well as the JNI proxy 170, JNI bridge 172 and native code 174 on the mobile device 100. The native code 174 on the computing device 100 may be implemented in a language other than the programming language of the app, which itself may be Java. Thus, the native code may not be Java code. The native code 174 may function to access the hardware resource 180 on the mobile device 100.
[0026] Referring still to
[0027] The JNI bridge 154 cross-references the JNI native code specified in the JNI call to the particular device—mobile device 100 or computing device 150. If the native code requested in the JNI call is located in the mobile device 100 (as determined by the JNI bridge 154), the JNI bridge 154 provides the JNI call to the JNI proxy 156 on the computing device to forward the JNI call to the JNI proxy 170 on the mobile device 100 to thereby cause the native code 174 on the mobile device to be accessed. The JNI proxies 156 and 170 may be pass-through logic elements which pass through a received JNI call. That is, the JNI proxies 156, 170 may not otherwise process the JNI calls.
[0028] The JNI bridge 172 on the mobile device 100 receives the JNI call from the JNI proxy 170. The JNI bridge 172 may have a data structure 173 such as a look-up table as well that cross-references native code specified in the JNI calls to their exact location (e.g., by address) in storage on the mobile device 100.
[0029] If the native code 174 generates a response, the response may be provided to the JNI proxy 170 which forwards the response to the JNI proxy 156 on the computing device. Thus, any response messages or data may be received by the JNI proxy on the computing device and provided back to the thread R′.
[0030] If, however, the JNI bridge 154 on the computing device 150 determines that that native code specified by the JNI call 153 is resident on the computing device 150 and not on the mobile device 100, the JNI bridge 154 on the computing device does not provide the JNI call to the JNI proxy 156 and, instead causes the native code 158 resident on the computing device 150 to be executed. The native code 158 on the computing device 150 may perform tasks other than accessing a hardware resource 180 on the mobile device 100.
[0031]
[0032] The non-transitory storage device 210 may store machine instructions executable by the processor 200 of the respective mobile device 100 and computing device 150. The machine instructions may be executed to implement a JNI proxy 212, a JNI bridge 214 and native code 216. On the mobile device 100, the JNI proxy 212, a JNI bridge 214 and native code 216 correspond, respectively, to the JNI proxy 170, a JNI bridge 172 and native code 174. On the computing device 150, the JNI proxy 212, a JNI bridge 214 and native code 216 correspond, respectively, to the JNI proxy 156, a JNI bridge 154 and native code 158.
[0033] Using the example architecture of
[0034] Using the example architecture of
[0035]
[0036]
[0037] At 220, the method includes determining, for example, by the computing device 150 (using, for example, the JNI bridge 154) and based on a JNI call for native code, whether the native code associated with the JNI call is resident on the computing device 150 or on the mobile device 100. At 222, if the native code is resident on the computing device 150, the method includes executing the native code by the computing device. However, if the native code is resident on the mobile device 100, the method includes at 224 providing the JNI call to a JNI proxy 156 on the computing device 150 and at 226 forwarding, by the JNI proxy 156 on the computing device, the JNI call to the JNI proxy 170 on the mobile device. At 230, the native code is then executed on the mobile device 100.
[0038]
[0039] At 220, the method includes determining, for example, by the computing device 150 and based on a JNI call for native code, whether the native code associated with the JNI call is resident on the computing device 150 or on the mobile device 100. At 222, if the native code is resident on the computing device 150, the method includes executing the native code by the computing device. However, if the native code is resident on the mobile device 100, the method includes at 224 providing the JNI call to a JNI proxy 156 on the computing device 150 and at 226 forwarding, by the JNI proxy 156 on the computing device, the JNI call to the JNI proxy 170 on the mobile device. At 228, the method includes providing the JNI call from the JNI proxy 170 of the mobile device 100 to the mobile device's JNI bridge 172. At 230, the native code is executed on the mobile device 100. At 232, the method includes the native code on the mobile device generating a response which is provided (at 234) to the computing device through the JNI proxy 170 on the mobile device 100 to the JNI proxy 156 on the computing device 150.
[0040] The above discussion is meant to be illustrative of the principles and various examples of the present subject matter. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.