Program execution method, device and equipment of smart card and medium
Patent Information
- Application Number
- CN202611441573.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-10-23
AI Technical Summary
如果一个卡端应用由于功能的需要导致运行时间过长,可能表现为指令执行时间过长,进而影响终端侧的功能
[0021]根据本发明实施例提供的智能卡的程序执行方法,通过在智能卡的主功能程序运行期间,在每次收到外部终端的非耗时交互指令时,在执行非耗时交互指令期间,提前调度执行目标卡端应用需执行的或目标卡端应用所需调用执行的耗时的目标功能程序,从而在收到指令触发目标卡端应用运行且需要目标功能程序的执行结果时,无需再执行目标功能程序或者只需执行剩余部分目标功能程序,从而可以快速获取目标功能程序的执行结果进行指令响应,继而提高目标卡端应用的指令响应速度,降低目标卡端应用的指令执行时间。
Smart Images

Figure CN122963743A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a program execution method, apparatus, device, and medium for a smart card. Background Technology
[0002] A smart card is a microcontroller used in the security field. Smart cards that support the Java Virtual Machine (JVM), also known as Java Card technology, allow card-side applications written in Java to implement smart card functions and run on the smart card. The JVM is further encapsulated as a smart card operating system that manages applications and schedules operations, with Java applications acting as the upper layer.
[0003] The Java Virtual Machine (JVM) can execute Java assembly instructions, and it has a specific set of bytecode instructions. These bytecode instructions are implemented in software, such as using the C language. This means that a similar instruction sequence executed in the JVM will be significantly less efficient than on a real CPU, typically by a factor of ten or more. A similar situation exists in Java card technology; however, due to the extremely limited resources of hardware like microcontrollers, the virtual machine is usually trimmed down, allowing only single-threaded operation, meaning only one application can run at a time.
[0004] The Java Card runtime environment includes a Java Card Virtual Machine (JCVM), which interacts with the outside world through communication protocols, waiting to receive APDU (Application Protocol Data Unit) instructions, dispatching the APDU instructions to a card-side application for processing, and returning response data upon completion. If a card-side application takes too long to run due to functional requirements, this may manifest as excessively long instruction execution times, thereby affecting the functionality of the terminal side. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and medium for executing programs on a smart card, which aims to optimize the instruction execution time of at least some of the card-side applications of the smart card.
[0006] In a first aspect, the present invention provides a program execution method for a smart card, wherein the smart card has at least one target card-side application installed thereon, the at least one target card-side application including one or more of the following: a time-consuming function program, an application containing a time-consuming function program, and an application that needs to call the execution result of the time-consuming function program during runtime, wherein the time-consuming function program is a function program whose execution time is greater than a preset time threshold, and the method includes: In response to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, a target function program is selected from the currently unprocessed time-consuming function programs, and the target function program is executed. In response to the completion of the execution of the target function program, the non-time-consuming interactive command response is sent to the external terminal.
[0007] In some embodiments, the step of selecting a target function program from time-consuming function programs that are not currently being processed, in response to receiving a non-time-consuming interactive instruction from an external terminal during the execution of the main function program of the smart card, includes: In response to receiving a non-time-consuming interactive command from an external terminal during the operation of the smart card's main function program, query the execution status of each registered time-consuming function program; Select a target function program from the time-consuming function programs whose execution status is incomplete according to preset rules.
[0008] In some embodiments, the target function program includes multiple program steps; executing the target function program includes: executing at least one program step of the target function program that is currently to be completed; when the last program step of the target function program is completed, updating the execution status of the target function program to a completed status; The step of responding to the completion of the execution of the target function program by sending the non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed in the target function program by sending the non-time-consuming interactive instruction response to the external terminal.
[0009] In some embodiments, for each time-consuming function program in at least a portion of the time-consuming function programs, the time-consuming function program is pre-divided into multiple program steps according to a preset time threshold, and the execution time of each program step is less than or equal to the preset time threshold.
[0010] In some embodiments, the smart card has a built-in virtual machine for running applications of the smart card. After querying the execution status of each registered time-consuming function program, the method further includes: if there is a time-consuming function program whose execution status is incomplete, pointing the current runtime information space of the virtual machine to a first runtime information space, wherein the first runtime information space is used to maintain the runtime information of the time-consuming function program. The execution of the target function program includes: executing the target function program through the virtual machine based on the runtime information of the target function program in the first runtime information space.
[0011] In some embodiments, the step of selecting a target function program from time-consuming function programs that are not currently being processed, in response to receiving a non-time-consuming interactive instruction from an external terminal during the execution of the main function program of the smart card, includes: In response to receiving a non-time-consuming interactive command from an external terminal during the operation of the smart card's main function program, check whether there is a target card application associated with the non-time-consuming command event; If there is a target card application associated with a non-time-consuming instruction event, a non-time-consuming instruction event is generated, and the time-consuming function program that the associated target card application needs to run or call is taken as the target function program.
[0012] In some embodiments, the target function program includes multiple program steps; executing the target function program includes: in response to the non-time-consuming instruction event, triggering the associated target card application to execute or call at least one program step of the target function program that is currently pending completion; when the last program step of the target function program finishes execution, updating the execution status of the target function program to a completed status; The step of responding to the completion of the execution of the target function program by sending the non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed in the target function program by sending the non-time-consuming interactive instruction response to the external terminal.
[0013] In some embodiments, after the non-time-consuming instruction event is triggered, the method further includes: The current runtime information space of the virtual machine is pointed to the first runtime information space, which is used to store the runtime information of time-consuming function programs. The execution of the target function program includes: in response to the non-time-consuming instruction event, triggering the execution of the associated target card application, and executing the target function program through the virtual machine based on the runtime information of the target function program in the first runtime information space.
[0014] In some embodiments, after executing the target function program, the method further includes: Record the execution time of the target function program; In response to the execution time of the target function program reaching an execution time threshold, the execution of the target function program is interrupted, and the execution interruption position of the target function program is recorded; Jump to the step of executing the non-time-consuming interactive command response to the external terminal.
[0015] In some embodiments, after executing the target function program, the method further includes: Record the execution time of the target function program; During the execution of each bytecode instruction of the target function program by the virtual machine, in response to the execution time of the target function program reaching the execution time threshold, the current runtime information space of the virtual machine is pointed to the second runtime information space, which is used to store the runtime information of the main function program of the smart card; Suspend the execution of the target function program and update the runtime information of the target function program in the first runtime information space; Through the virtual machine, the main function program continues to be executed based on the runtime information of the main function program in the second runtime information space, and the non-time-consuming interactive instruction response is sent to the external terminal.
[0016] In some embodiments, the step of responding to the non-time-consuming interactive instruction response to the external terminal upon completion of the target function program includes: In response to the target function program completing execution before the execution time threshold is reached, the execution status of the target function program is updated to the completion status, and the current runtime information space of the virtual machine is pointed to the second runtime information space; The main function program continues to be executed through the virtual machine based on the runtime information of the main function program in the second runtime information space; The non-time-consuming interactive command response is sent to the external terminal.
[0017] In some embodiments, the method further includes: When the target card application needs to call the execution result of a time-consuming function program during its operation, query the execution status of the time-consuming function program to be called; If the execution status of the time-consuming function program to be called is complete, obtain the execution result of the time-consuming function program to be called; If the execution status of the time-consuming function program to be called is incomplete, the program execution interface will be called to execute the time-consuming function program to be called.
[0018] Secondly, the present invention provides a program execution device for a smart card, wherein the smart card has at least one target card-side application installed therein, the at least one target card-side application including one or more of the following: a time-consuming function program, a card-side application containing the time-consuming function program, and an application that needs to call the execution result of the time-consuming function program during runtime, wherein the time-consuming function program is a function program whose execution time is greater than a preset time threshold, and the device includes: An execution module is used to respond to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, select a target function program from the time-consuming function programs that have not yet been processed, and execute the target function program; The response module is used to respond to the completion of the execution of the target function program by sending the non-time-consuming interactive command response to the external terminal.
[0019] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the program execution method of the smart card described in the first aspect or any corresponding embodiment thereof.
[0020] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the program execution method of the smart card according to the first aspect or any corresponding embodiment thereof.
[0021] According to the program execution method of the smart card provided in the embodiments of the present invention, during the operation of the main function program of the smart card, each time a non-time-consuming interaction instruction is received from an external terminal, the time-consuming target function program that the target card application needs to execute or that the target card application needs to call and execute is scheduled in advance during the execution of the non-time-consuming interaction instruction. Therefore, when the target card application is triggered to run by an instruction and the execution result of the target function program is required, it is not necessary to execute the target function program again or only the remaining part of the target function program needs to be executed. This allows for a quick acquisition of the execution result of the target function program for instruction response, thereby improving the instruction response speed of the target card application and reducing the instruction execution time of the target card application. Attached Figure Description
[0022] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of a smart card system architecture according to an embodiment of the present invention; Figure 2 A flowchart illustrating a program execution method for a smart card provided in an embodiment of the present invention; Figure 3 A block diagram illustrating the composition of a program execution device for a smart card, provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0026] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0027] Figure 1 This is a schematic diagram of a smart card system architecture according to an embodiment of the present invention, such as... Figure 1 As shown, a smart card is a Java Card, such as a SIM card or a USIM card. The hardware resources of a smart card provide underlying physical support for the entire system, including basic hardware modules such as processors, memory, encryption processing units, and communication interfaces. It is the physical foundation for the operation of the operating system, the Java Card virtual machine, and applications.
[0028] The smart card's operating system (COS) runs directly on the smart card's hardware resources, responsible for hardware resource scheduling, underlying communication protocol processing, data storage management, security protection, and exception handling, providing a stable and secure underlying operating environment for the upper-layer Java Card Virtual Machine (JCVM).
[0029] The Java Card Virtual Machine (JCVM) is deployed on top of the operating system. As a bytecode execution engine and application runtime framework, it provides core capabilities such as class loading, bytecode interpretation and execution, object management, and application isolation, and shields the differences between the underlying hardware and operating system through standardized interfaces.
[0030] The applications (applications) carried by a smart card include one or more card-side applications, which are Applet applications. Applet applications are small applications that run within the smart card. They are business logic programs developed based on the Java Card specification, running on the Java Card Virtual Machine. They do not directly access the hardware or operating system, but only implement business functions such as data reading and writing, encryption operations, and identity authentication through the application programming interface provided by the Java Card Virtual Machine. These include, but are not limited to, identity authentication Applets, financial payment Applets, communication authentication Applets, security key and encryption / decryption Applets, industry-specific business Applets, and card management and security control Applets. Multiple Applet applications are independent of each other through the security isolation mechanism of the Java Card Virtual Machine and do not interfere with each other. It should be noted that... Figure 1 This example illustrates a scenario where a smart card has three card-end applications running: card-end application 1, card-end application 2, and card-end application 3. This scenario is not limited to the embodiments of the present invention.
[0031] In at least one card application, the card application includes one or more time-consuming function programs, or the card application needs to call the execution results of one or more time-consuming function programs when it runs, or the time-consuming function program is an independent card application. The time-consuming function program includes, but is not limited to, asymmetric cryptographic operations, large-scale data encryption and decryption, key derivation, hash calculation, batch storage operations and complex security protocol processing, etc., which require a long execution time for computation and processing logic. The time-consuming function program is developed based on the Java Card specification, and its running time is greater than a preset time threshold. Figure 1 The example illustrates a scenario where a smart card includes two time-consuming function programs, time-consuming function program 1 and time-consuming function program 2. Embodiments of the present invention include, but are not limited to, this scenario.
[0032] APDU is a standard command format and communication carrier for interaction between external terminals and the internal card applications of a smart card. The external terminal initiates an operation request by sending an APDU command. Upon receiving the APDU command, the smart card forwards it to the currently selected card application. The card application parses the command code, parameters, and data content in the APDU command, executes the corresponding business logic processing, and returns the processing result to the external terminal in the form of a response APDU. The card application's function calls, data interactions, and status control all rely on APDU commands. During the processing of APDU commands, various predefined functional events can be generated, such as a call being connected or disconnected, triggering the card application to execute the event and return response data upon completion.
[0033] In related technologies, when the card application itself is a time-consuming function program, or when the card application executes a time-consuming function program, or when the card application needs to call and execute a time-consuming function program during runtime, the card application runs for too long, that is, the instruction execution time is too long, the instruction response delay increases, affecting the real-time performance of communication, and thus affecting the normal function implementation on the terminal side.
[0034] Therefore, the present invention provides a program execution method, apparatus, device and medium for smart cards, which aims to effectively optimize the instruction execution time of the target card application and reduce instruction response latency.
[0035] According to an embodiment of the present invention, a method for executing a program on a smart card is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0036] Example 1 This embodiment provides a program execution method for a smart card, which can be used for smart cards. Figure 2 This is a flowchart illustrating a program execution method for a smart card according to an embodiment of the present invention. The smart card contains at least one target card-side application. This target card-side application includes one or more of the following: a time-consuming function program, an application containing a time-consuming function program, and an application that needs to call the execution result of the time-consuming function program during runtime. The time-consuming function program is a function program whose execution time exceeds a preset time threshold, such as... Figure 2 As shown, the program execution method includes the following steps: Step S201: In response to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, a target function program is selected from the time-consuming function programs that have not yet been processed, and the target function program is executed.
[0037] In this embodiment of the invention, the business logic of the smart card is pre-divided into main function programs and time-consuming function programs. The time-consuming function programs are function programs whose running time exceeds a preset time threshold, such as algorithm calculation, encryption key generation, key derivation, etc. The main function programs are regular function programs other than the time-consuming function programs, such as network attachment and maintenance, regular data transmission and reception, instruction parsing and distribution, status reporting and heartbeat maintenance, regular event processing, etc.
[0038] In this embodiment of the invention, all interaction instructions between the smart card and the external terminal are pre-divided into non-time-consuming interaction instructions and time-consuming interaction instructions according to their execution time (time consumption). Non-time-consuming interaction instructions are non-time-consuming instructions (such as SELECT instructions, STATUS instructions, etc.), that is, instructions whose execution time is less than or equal to a preset time threshold (e.g., 100 milliseconds). Time-consuming interaction instructions (such as Get Identity instructions) are instructions whose execution time is greater than the preset time threshold.
[0039] During the operation of the main function program of the smart card, when an interactive instruction is received from an external terminal, the instruction type of the interactive instruction is identified. If the interactive instruction is a non-time-consuming interactive instruction, a time-consuming function program is selected from the currently unprocessed time-consuming function programs as the target function program and executed.
[0040] Step S202: In response to the completion of the target function program execution, a non-time-consuming interactive command response is sent to the external terminal.
[0041] The completion of the target function program can mean that one or more program steps in the currently executing target function program have been completed, or that the currently executing target function program is interrupted because the execution time has reached an execution time threshold. For example, the target card application exits the execution of the target function program after completing each program step.
[0042] According to the program execution method of the smart card according to the embodiments of the present invention, during the operation of the main function program of the smart card, each time a non-time-consuming interaction instruction is received from an external terminal, the time-consuming target function program that needs to be executed or needs to be called and executed by the target card application is scheduled in advance during the execution of the non-time-consuming interaction instruction. Therefore, when the target card application is triggered to run by the instruction and needs to call the execution result of the target function program, it is not necessary to execute the target function program again or only the remaining part of the target function program needs to be executed. This allows for quick acquisition of the execution result of the target function program for instruction response, thereby improving the instruction response speed of the target card application and reducing the instruction execution time of the target card application.
[0043] Example 2 This embodiment provides a program execution method for a smart card, which can be used for smart cards. The method includes steps S201 and S202 of the above embodiment.
[0044] In some embodiments, in step S201 above, in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, selecting a target function program from the time-consuming function programs that are currently not completed includes: in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, querying the execution status of each registered time-consuming function program; and selecting a target function program from the time-consuming function programs whose execution status is incomplete according to a preset rule.
[0045] In some embodiments, the system provides a registration interface for registering all time-consuming function programs with the system; a status setting interface for recording the execution status of each registered time-consuming function program, including a completed status and an incomplete status; a status query interface for querying the execution status of each registered time-consuming function program; and a program execution interface for running a target function program for calling a specified target function program to execute.
[0046] In some embodiments, time-consuming functional programs that need to be executed during the execution of non-time-consuming interactive instructions are pre-registered with the system through a registration interface.
[0047] In some embodiments, in response to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, the execution status of each registered time-consuming function program is obtained through a status query interface.
[0048] In some embodiments, the priority of each time-consuming function program is set in advance according to actual needs. The preset rule is to call the execution of each time-consuming function program in descending order of priority when the execution status is incomplete. According to the preset rule, the time-consuming function program with the highest current priority is selected from the time-consuming function programs in the execution status incomplete as the target function program.
[0049] In some embodiments, for each time-consuming function program in at least a portion of the time-consuming function programs, the time-consuming function program is pre-divided into multiple program steps according to a preset time threshold. The multiple program steps are executed sequentially in the execution order, and the execution time of each program step does not exceed the preset time threshold (e.g., 100 milliseconds).
[0050] In some embodiments, the target function program includes multiple program steps; in step S201 above, executing the target function program includes: executing at least one program step of the target function program that is currently to be completed; when the last program step of the target function program is completed, the execution status of the target function program is updated to the completion status.
[0051] In some embodiments, each time a non-time-consuming interactive instruction is received from an external terminal, the target function program executes multiple program steps that are currently to be completed. After each set of multiple program steps is completed, the execution of the target function program is exited, and the next set of multiple program steps is marked as the program steps to be completed, so that execution can continue when a non-time-consuming interactive instruction is received again, until all program steps of the target function program are completed.
[0052] In some embodiments, each time a non-time-consuming interactive instruction is received from an external terminal, the target function program executes one program step that is currently to be completed. After each program step is completed, the execution of the target function program is exited, and the next program step is marked as the program step to be completed, so that execution can continue when a non-time-consuming interactive instruction is received again, until all program steps of the target function program are completed.
[0053] When the last program step of the target function program finishes execution, the execution status of the target function program is updated to the completed state; when the program step to be completed in the target function program is not the last program step, the execution status of the target function program is kept in the incomplete state.
[0054] It is understandable that if the execution status of the target function program remains in the incomplete state, since the target function program is selected based on priority, when a non-time-consuming interactive instruction is received again, the target function program will continue to be selected for execution until all program steps of the target function program are completed and the execution status changes to the completed state.
[0055] In some embodiments, to prevent the unexpected occurrence of an excessively long execution time for at least one program step currently pending completion in the target function program, an execution time threshold is set, for example, 200 milliseconds. After executing the target function program, the method further includes: recording the execution time of the target function program; in response to the execution time of the target function program reaching the execution time threshold, interrupting the execution of the target function program and recording the execution interruption position of the target function program; and jumping to the step of executing a non-time-consuming interactive instruction response to an external terminal.
[0056] In some embodiments, after executing the target function program, an execution time timer can be started to record the execution time of the target function program; if the execution time of the target function program reaches the execution time threshold and has not been completed, the execution of the target function program is interrupted by the virtual machine, and the execution interruption position of the target function program is recorded (e.g., interruption at the i-th program step), and the process jumps to the step of executing a non-time-consuming interactive instruction response to an external terminal, waiting for the next non-time-consuming interactive instruction to arrive.
[0057] When a non-time-consuming interactive instruction is received again, the execution of the target function program can continue from the last interrupted position of the target function program.
[0058] In some embodiments, in step S202 above, responding to the completion of the execution of the target function program by sending the non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed by the target function program by sending a non-time-consuming interactive instruction response to the external terminal.
[0059] In some embodiments, if at least one program step to be completed is completed before the execution time of the target function program reaches the execution time threshold, the execution of the target function program is exited, and a non-time-consuming interactive instruction response is sent to the external terminal, waiting for the next non-time-consuming interactive instruction to arrive.
[0060] In some embodiments, the method further includes: when the target card application needs to call the execution result of a time-consuming function program during its operation, querying the execution status of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is completed, obtaining the execution result of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is incomplete, calling the program execution interface to execute the time-consuming function program to be called until execution is completed; if the time-consuming function program to be called has previously completed the execution of some program steps, continuing to execute the remaining subsequent program steps until the time-consuming function program to be called is completed.
[0061] In some embodiments, when the input data of the time-consuming function changes, the execution status of the time-consuming function is reset to an incomplete state.
[0062] Example 3 This embodiment provides a program execution method for a smart card, which can be used for smart cards. The method includes steps S201 and S202 of the above embodiment.
[0063] In some embodiments, in step S201 above, in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, selecting a target function program from the time-consuming function programs that are currently not completed includes: in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, querying the execution status of each registered time-consuming function program; and selecting a target function program from the time-consuming function programs whose execution status is incomplete according to a preset rule.
[0064] In some embodiments, the system provides a registration interface for registering all time-consuming function programs with the system; a status setting interface for recording the execution status of each registered time-consuming function program, including a completed status and an incomplete status; a status query interface for querying the execution status of each registered time-consuming function program; and a program execution interface for running a target function program for calling a specified target function program to execute.
[0065] In some embodiments, time-consuming functional programs that need to be executed during the execution of non-time-consuming interactive instructions are pre-registered with the system through a registration interface.
[0066] In some embodiments, in response to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, the execution status of each registered time-consuming function program is obtained through a status query interface.
[0067] In some embodiments, the priority of each time-consuming function program is set in advance according to actual needs. The preset rule is to call the execution of each time-consuming function program in descending order of priority when the execution status is incomplete. According to the preset rule, the time-consuming function program with the highest current priority is selected from the time-consuming function programs in the execution status incomplete as the target function program.
[0068] In some embodiments, the smart card has a built-in virtual machine for running the card-side application of the smart card. The virtual machine is pre-configured with a first runtime information space and a second runtime information space. The runtime information space (Runtime Information Space / Runtime Data Area) refers to the set of memory areas dynamically maintained by the virtual machine after the card is powered on to manage the execution, execution state, data and instruction flow of the application. It is the execution environment of the application, consisting of stack space, program counter, stack pointer, etc.
[0069] The first runtime information space is used to maintain the runtime information of time-consuming function programs, including but not limited to: instruction execution, method calls, execution status, and running context of the time-consuming function programs; the second runtime information space is used to maintain the runtime information of the main function programs, including but not limited to: instruction execution, method calls, execution status, and running context of the main function programs.
[0070] When the smart card system is powered on, the virtual machine's current runtime information space points to the second runtime information space to start the main function program.
[0071] In some embodiments, after the step of querying the execution status of each registered time-consuming function program, the method further includes: if there is a time-consuming function program whose execution status is incomplete, pointing the current runtime information space of the virtual machine to the first runtime information space, the first runtime information space being used to store the runtime information of the time-consuming function program.
[0072] In step S201 above, executing the target function program includes: executing the target function program through a virtual machine based on the runtime information of the target function program in the first runtime information space until the target function program is completed.
[0073] Specifically, by calling the program execution interface through the virtual machine, the current runtime information space of the virtual machine is pointed to the first runtime information space, and the target function program is executed based on the runtime information of the target function program in the first runtime information space.
[0074] In some embodiments, in response to the completion of the target function program, the execution status of the target function program is set to the completed state by calling the state setting interface through the virtual machine, and the current runtime information space of the virtual machine is pointed to the second runtime information space. The main function program continues to be executed according to the runtime information of the main function program in the second runtime information space, so as to perform the step of responding to non-time-consuming interactive instructions to the external terminal.
[0075] In some embodiments, after executing the target function program, the method further includes: recording the execution time of the target function program; during the execution of each bytecode instruction of the target function program by the virtual machine, in response to the execution time of the target function program reaching an execution time threshold, pointing the current runtime information space of the virtual machine to a second runtime information space, the second runtime information space being used to maintain the runtime information of the main function program of the smart card; pausing the execution of the target function program and updating the runtime information of the target function program in the first runtime information space; and continuing to execute the main function program through the virtual machine based on the runtime information of the main function program in the second runtime information space, and responding to non-time-consuming interactive instructions to the external terminal.
[0076] In some embodiments, in step S202 above, responding to the completion of the execution of the target function program and sending a non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of the target function program before the execution time reaches the execution time threshold, updating the execution status of the target function program to the completion status, and pointing the current runtime information space of the virtual machine to the second runtime information space; continuing to execute the main function program through the virtual machine based on the runtime information of the main function program in the second runtime information space; and sending a non-time-consuming interactive instruction response to the external terminal.
[0077] In some embodiments, the execution time of the target function program is recorded by an execution time timer. When the execution of the target function program begins, the execution time timer is started and the execution time of the target function program is recorded. During the execution of each bytecode instruction of the target function program by the virtual machine, it is checked whether the execution time timer has reached the execution time threshold. If the execution time recorded by the timer reaches the execution time threshold (e.g., 100 milliseconds) and the target function program has not finished execution, the runtime information space of the virtual machine is pointed to the second runtime information space, the execution of the time-consuming target function program is paused, and the main function program continues to execute. If the execution time recorded by the timer is completed before the execution time threshold is reached, the runtime information space of the virtual machine is pointed to the second runtime information space, the main function program continues to execute, and the execution status of the completed target function program is set to the completion status.
[0078] In some embodiments, the method further includes: when the target card application needs to call the execution result of a time-consuming function program during its operation, querying the execution status of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is completed, obtaining the execution result of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is incomplete, calling the program execution interface to execute the time-consuming function program to be called until execution is completed; if the time-consuming function program to be called has previously completed the execution of some program steps, continuing to execute the remaining subsequent program steps until the time-consuming function program to be called is completed.
[0079] In some embodiments, when the input data of the time-consuming function changes, the execution status of the time-consuming function is reset to an incomplete state.
[0080] Example 4 This embodiment provides a program execution method for a smart card, which can be used for smart cards. The method includes steps S201 and S202 of the above embodiment.
[0081] In some embodiments, based on the event mechanism of a Java smart card, a corresponding non-time-consuming instruction event is defined for a specific non-time-consuming interaction instruction, and the target card application that needs to be associated with the non-time-consuming instruction event is registered and associated with the required non-time-consuming instruction event. The target card application associated with the non-time-consuming instruction event can be a time-consuming function program, a card application containing a time-consuming function program, or a card application that needs to call the execution result of a time-consuming function program at runtime.
[0082] In some embodiments, in step S201 above, in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, selecting a target function program from the currently unprocessed time-consuming function programs includes: in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, checking whether there is a target card application associated with the non-time-consuming instruction event; if there is a target card application associated with the non-time-consuming instruction event, generating a non-time-consuming instruction event, and using the time-consuming function program that the associated target card application needs to run or call as the target function program.
[0083] If there are multiple target card applications associated with non-time-consuming instruction events, then one time-consuming function program is selected as the target function program from the time-consuming function programs that need to be run or called by the multiple target card applications according to preset rules.
[0084] In some embodiments, for each time-consuming function program in at least a portion of the time-consuming function programs, the time-consuming function program is pre-divided into multiple program steps according to a preset time threshold. The multiple program steps are executed sequentially in the execution order, and the execution time of each program step does not exceed the preset time threshold (e.g., 100 milliseconds).
[0085] In some embodiments, the target function program includes multiple program steps; in step S201 above, executing the target function program includes: in response to a non-time-consuming instruction event, triggering the associated target card application to execute or call at least one program step of the target function program that is currently to be completed; when the last program step of the target function program finishes execution, updating the execution status of the target function program to a completed status, and unbinding the association between the non-time-consuming instruction event and the target card application to which the target function program belongs, so as to prevent the target function program from being triggered to be executed repeatedly when the next non-time-consuming instruction event occurs.
[0086] In some embodiments, in response to a non-time-consuming instruction event, multiple program steps of the associated target function program that are currently to be completed are executed. After each set of multiple program steps is completed, the execution of the target function program is exited, and the next set of multiple program steps is marked as the program steps to be completed, so that execution can continue when the next non-time-consuming instruction event is triggered, until all program steps of the associated target function program are completed.
[0087] In some embodiments, in response to a non-time-consuming instruction event, one program step of the associated target function program that is currently pending is executed. After each program step is executed, the execution of the target function program is exited, and the next program step is marked as the program step to be completed, so that execution can continue when the next non-time-consuming instruction event is triggered, until all program steps of the associated target function program are completed.
[0088] When the last program step of the target function program finishes execution, the execution status of the target function program is updated to the completed state; when the program step that the target function program is currently executing is not the last program step, the execution status of the target function program is kept in the incomplete state.
[0089] In some embodiments, in step S202 above, responding to the completion of the execution of the target function program by sending a non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed in the target function program by sending a non-time-consuming interactive instruction response to the external terminal.
[0090] In some embodiments, to prevent the unexpected occurrence of an excessively long execution time for at least one program step currently pending completion in the target function program, an execution time threshold is set, for example, 200 milliseconds. After executing the target function program, the method further includes: recording the execution time of the target function program; in response to the execution time of the target function program reaching the execution time threshold, interrupting the execution of the target function program and recording the execution interruption position of the target function program; and jumping to the step of executing a non-time-consuming interactive instruction response to an external terminal.
[0091] In some embodiments, after executing the target function program, an execution time timer is started to record the execution time of the target function program; if the execution time of the target function program reaches the execution time threshold and has not been completed, the execution of the target function program is interrupted by the virtual machine, and the execution interruption position of the target function program is recorded (e.g., interruption at the i-th program step), and the process jumps to the step of executing a non-time-consuming interactive instruction response to an external terminal, waiting for the next non-time-consuming interactive instruction to arrive.
[0092] When a non-time-consuming instruction event is received and execution is triggered again, the execution of the target function program can continue from the last interrupted position of the target function program.
[0093] In some embodiments, if at least one program step to be completed is completed before the execution time of the target function program reaches the execution time threshold, the execution of the target function program is exited, and a non-time-consuming interactive instruction response is sent to the external terminal, waiting for the next non-time-consuming interactive instruction to arrive.
[0094] In some embodiments, the method further includes: when the target card application needs to call the execution result of a time-consuming function program during its operation, querying the execution status of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is completed, obtaining the execution result of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is incomplete, calling the program execution interface to execute the time-consuming function program to be called until execution is completed; if the time-consuming function program to be called has previously completed the execution of some program steps, continuing to execute the remaining subsequent program steps until the time-consuming function program to be called is completed.
[0095] Example 5 This embodiment provides a program execution method for a smart card, which can be used for smart cards. The method includes steps S201 and S202 of the above embodiment.
[0096] In some embodiments, based on the event mechanism of a Java smart card, a corresponding non-time-consuming instruction event is defined for a specific non-time-consuming interaction instruction, and the target card application that needs to be associated with the non-time-consuming instruction event is registered and associated with the required non-time-consuming instruction event. The target card application associated with the non-time-consuming instruction event can be a time-consuming function program, a card application containing a time-consuming function program, or a card application that needs to call the execution result of a time-consuming function program at runtime.
[0097] In some embodiments, in step S201 above, in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, selecting a target function program from the currently unprocessed time-consuming function programs includes: in response to receiving a non-time-consuming interaction instruction from an external terminal during the operation of the main function program of the smart card, checking whether there is a target card application associated with the non-time-consuming instruction event; if there is a target card application associated with the non-time-consuming instruction event, generating a non-time-consuming instruction event, and using the time-consuming function program that the associated target card application needs to run or call as the target function program.
[0098] If there are multiple target card applications associated with non-time-consuming instruction events, then one time-consuming function program is selected as the target function program from the time-consuming function programs that need to be run or called by the multiple target card applications according to preset rules.
[0099] In some embodiments, for each time-consuming function program in at least a portion of the time-consuming function programs, the time-consuming function program is pre-divided into multiple program steps according to a preset time threshold. The multiple program steps are executed sequentially in the execution order, and the execution time of each program step does not exceed the preset time threshold (e.g., 100 milliseconds).
[0100] In some embodiments, the smart card has a built-in virtual machine for running the card-side application. The virtual machine is pre-configured with a first runtime information space and a second runtime information space. The first runtime information space is used to maintain the runtime information of time-consuming function programs, which includes, but is not limited to, the instruction execution, method calls, execution status, and running context of the time-consuming function programs. The second runtime information space is used to maintain the runtime information of the main function program, which includes, but is not limited to, the instruction execution, method calls, execution status, and running context of the main function program.
[0101] When the smart card system is powered on, the virtual machine's current runtime information space points to the second runtime information space to start the execution of the main function program.
[0102] In some embodiments, after a non-time-consuming instruction event is generated, the method further includes: pointing the current runtime information space of the virtual machine to a first runtime information space, the first runtime information space being used to maintain the runtime information of the time-consuming function program until the target function program is completed.
[0103] In step S201 above, executing the target function program includes: in response to a non-time-consuming instruction event, executing the target function program through a virtual machine based on the runtime information of the target function program in the first runtime information space.
[0104] In some embodiments, the system provides a program execution interface for running a target function program, which is used to call a specified target function program for execution. By calling the program execution interface through the virtual machine, the virtual machine's current runtime information space is pointed to a first runtime information space, and the target function program is executed based on the runtime information of the target function program in the first runtime information space.
[0105] In some embodiments, in response to the completion of the execution of the target function program, the execution state of the target function program is set to the completed state, and the current runtime information space of the virtual machine is pointed to the second runtime information space. The main function program continues to be executed according to the runtime information of the main function program in the second runtime information space, so as to perform the step of responding to non-time-consuming interactive instructions to the external terminal.
[0106] In some embodiments, after executing the target function program, the method further includes: recording the execution time of the target function program; during the execution of each bytecode instruction of the target function program by the virtual machine, in response to the execution time of the target function program reaching an execution time threshold, pointing the current runtime information space of the virtual machine to a second runtime information space, the second runtime information space being used to store the runtime information of the main function program of the smart card; pausing the execution of the target function program and updating the runtime information of the target function program in the first runtime information space; and continuing to execute the main function program through the virtual machine based on the runtime information of the main function program in the second runtime information space, and responding to non-time-consuming interactive instructions to an external terminal.
[0107] In some embodiments, in step S202 above, responding to the completion of the execution of the target function program and sending a non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of the target function program before the execution time reaches the execution time threshold, updating the execution status of the target function program to the completion status, and pointing the current runtime information space of the virtual machine to the second runtime information space; continuing to execute the main function program through the virtual machine based on the runtime information of the main function program in the second runtime information space; and sending a non-time-consuming interactive instruction response to the external terminal.
[0108] In some embodiments, the execution time of the target function program is recorded by an execution time timer. When the execution of the target function program begins, the execution time timer is started and the execution time of the target function program is recorded. During the execution of each bytecode instruction of the target function program by the virtual machine, it is checked whether the execution time timer has reached the execution time threshold. If the execution time recorded by the timer reaches the execution time threshold (e.g., 100 milliseconds) and the target function program has not finished execution, the runtime information space of the virtual machine is pointed to the second runtime information space, the execution of the time-consuming target function program is paused, and the main function program continues to execute. If the execution time recorded by the timer is completed before the execution time threshold is reached, the runtime information space of the virtual machine is pointed to the second runtime information space, the main function program continues to execute, and the execution status of the completed target function program is set to the completion status.
[0109] When the next non-time-consuming instruction event is triggered, the target function program of the target card application that was not completed last time will continue to be executed.
[0110] In some embodiments, the method further includes: when the target card application needs to call the execution result of a time-consuming function program during its operation, querying the execution status of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is completed, obtaining the execution result of the time-consuming function program to be called; if the execution status of the time-consuming function program to be called is incomplete, calling the program execution interface to execute the time-consuming function program to be called until execution is completed; if the time-consuming function program to be called has previously completed the execution of some program steps, continuing to execute the remaining subsequent program steps until the time-consuming function program to be called is completed.
[0111] In some embodiments, when the input data of the time-consuming function changes, the execution status of the time-consuming function is reset to an incomplete state.
[0112] Example 6 This embodiment provides an application scenario for a program execution method. Taking the contact sorting program in the phone book of a smart card as an example of a time-consuming function program, the program execution method of this embodiment is illustrated by way of example.
[0113] A smart card's phonebook can store hundreds to thousands of contacts. A target card application needs to sort these contacts to facilitate subsequent business processes, such as sorting by alphabetical order. The basic functions of the phonebook's contact sorting program are: locate the phonebook file, read the contact information stored in the file, iterate through and compare the sorted entries, and update the sorting results to a separate sorting index file.
[0114] Since contacts may be added or deleted, sorting them in a Java program would be inefficient and time-consuming when there are many contacts.
[0115] According to an embodiment of the present invention, the contact sorting program of the phone book takes a long time to run, so the contact sorting program of the phone book is pre-registered as a time-consuming function program.
[0116] When a non-time-consuming instruction is received during the execution of the main function program of the smart card, the contact sorting program of the phonebook is scheduled to be executed during the execution of the non-time-consuming instruction. Thus, when the target card application receives an APDU instruction that requires calling the contact sorting program of the phonebook to sort the contacts, the target card application does not need to execute the contact sorting program or only needs to execute part of the sorting program steps to quickly obtain the contact sorting results of the phonebook. This can effectively improve the instruction response speed of the target card application and reduce the instruction execution time.
[0117] Whenever the contact information in the phonebook changes, the target card application can reset the execution status of the sorting process to incomplete.
[0118] Example 7 This invention also provides a program execution device for a smart card, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0119] Figure 3 This is a block diagram of a program execution device for a smart card provided in an embodiment of the present invention. The smart card contains at least one target card-side application. This target card-side application includes one or more of the following: a time-consuming function program, an application containing a time-consuming function program, and an application that needs to call the execution result of the time-consuming function program during runtime. The time-consuming function program is a function program whose execution time exceeds a preset time threshold, such as... Figure 3 As shown, the program execution device includes: The execution module 301 is used to respond to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, select a target function program from the time-consuming function programs that have not yet been processed, and execute the target function program. The response module 302 is used to send a non-time-consuming interactive command response to an external terminal in response to the completion of the target function program.
[0120] The program execution apparatus provided in this embodiment of the invention can execute the program execution method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method. Further functional descriptions of the various modules and units described above are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0121] Example 8 Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0122] The following is a detailed reference. Figure 4This diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present invention. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 401, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 402 or a program loaded from memory 408 into random access memory (RAM) 403. RAM 403 also stores various programs and data required for the operation of the electronic device. The processor 401, ROM 402, and RAM 403 are interconnected via bus 404. Input / output (I / O) interface 405 is also connected to bus 404.
[0123] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0124] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 409, or installed from a memory 408, or installed from a ROM 402. When the computer program is executed by the processor 401, it performs the functions defined in the program execution method of the embodiments of the present invention.
[0125] Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0126] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the program execution method shown in the above embodiments is implemented.
[0127] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0128] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for executing a program on a smart card, characterized in that, The smart card has at least one target card application installed. The at least one target card application includes one or more of the following: a time-consuming function program, an application containing a time-consuming function program, and an application that needs to call the execution result of a time-consuming function program during runtime. The time-consuming function program is a function program whose execution time exceeds a preset time threshold. The method includes: In response to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, a target function program is selected from the currently unprocessed time-consuming function programs, and the target function program is executed. In response to the completion of the execution of the target function program, the non-time-consuming interactive command response is sent to the external terminal.
2. The method according to claim 1, characterized in that, The response to receiving a non-time-consuming interactive instruction from an external terminal during the execution of the smart card's main function program, and selecting a target function program from currently incomplete time-consuming function programs, includes: In response to receiving a non-time-consuming interactive command from an external terminal during the operation of the smart card's main function program, query the execution status of each registered time-consuming function program; Select a target function program from the time-consuming function programs whose execution status is incomplete according to preset rules.
3. The method according to claim 2, characterized in that, The target function program includes multiple program steps; executing the target function program includes: executing at least one program step of the target function program that is currently pending completion; when the last program step of the target function program is completed, updating the execution status of the target function program to a completed status; The step of responding to the completion of the execution of the target function program by sending the non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed in the target function program by sending the non-time-consuming interactive instruction response to the external terminal.
4. The method according to claim 3, characterized in that, For each time-consuming function in at least a portion of the time-consuming function program, the time-consuming function program is pre-divided into multiple program steps according to a preset time threshold, and the execution time of each program step is less than or equal to the preset time threshold.
5. The method according to claim 2, characterized in that, The smart card has a built-in virtual machine for running the smart card's application. After querying the execution status of each registered time-consuming function program, the method further includes: if there is a time-consuming function program whose execution status is incomplete, pointing the current runtime information space of the virtual machine to a first runtime information space, the first runtime information space being used to maintain the runtime information of the time-consuming function program. The execution of the target function program includes: executing the target function program through the virtual machine based on the runtime information of the target function program in the first runtime information space.
6. The method according to claim 1, characterized in that, The response to receiving a non-time-consuming interactive instruction from an external terminal during the execution of the smart card's main function program, and selecting a target function program from currently incomplete time-consuming function programs, includes: In response to receiving a non-time-consuming interactive command from an external terminal during the operation of the smart card's main function program, check whether there is a target card application associated with the non-time-consuming command event; If there is a target card application associated with a non-time-consuming instruction event, a non-time-consuming instruction event is generated, and the time-consuming function program that the associated target card application needs to run or call is taken as the target function program.
7. The method according to claim 6, characterized in that, The target function program includes multiple program steps; executing the target function program includes: in response to the non-time-consuming instruction event, triggering the associated target card application to execute or call at least one program step of the target function program that is currently pending completion; when the last program step of the target function program finishes execution, updating the execution status of the target function program to a completed status; The step of responding to the completion of the execution of the target function program by sending the non-time-consuming interactive instruction response to the external terminal includes: responding to the completion of the execution of at least one program step currently to be completed in the target function program by sending the non-time-consuming interactive instruction response to the external terminal.
8. The method according to claim 6, characterized in that, After generating the non-time-consuming instruction event, the method further includes: The current runtime information space of the virtual machine is pointed to the first runtime information space, which is used to store the runtime information of time-consuming function programs. The execution of the target function program includes: in response to the non-time-consuming instruction event, triggering the execution of the associated target card application, and executing the target function program through the virtual machine based on the runtime information of the target function program in the first runtime information space.
9. The method according to claim 2, 3 or 6, characterized in that, After executing the target function program, the method further includes: Record the execution time of the target function program; In response to the execution time of the target function program reaching an execution time threshold, the execution of the target function program is interrupted, and the execution interruption position of the target function program is recorded; Jump to the step of executing the non-time-consuming interactive command response to the external terminal.
10. The method according to claim 5 or 8, characterized in that, After executing the target function program, the method further includes: Record the execution time of the target function program; During the execution of each bytecode instruction of the target function program by the virtual machine, in response to the execution time of the target function program reaching the execution time threshold, the current runtime information space of the virtual machine is pointed to the second runtime information space, which is used to store the runtime information of the main function program of the smart card; Suspend the execution of the target function program and update the runtime information of the target function program in the first runtime information space; Through the virtual machine, the main function program continues to be executed based on the runtime information of the main function program in the second runtime information space, and the non-time-consuming interactive instruction response is sent to the external terminal.
11. The method according to claim 10, characterized in that, The response, which occurs upon completion of the execution of the target function program, involves sending the non-time-consuming interactive command response to the external terminal, including: In response to the target function program completing execution before the execution time threshold is reached, the execution status of the target function program is updated to the completion status, and the current runtime information space of the virtual machine is pointed to the second runtime information space; The main function program continues to be executed through the virtual machine based on the runtime information of the main function program in the second runtime information space; The non-time-consuming interactive command response is sent to the external terminal.
12. The method according to claim 1, characterized in that, The method further includes: When the target card application needs to call the execution result of a time-consuming function program during its operation, query the execution status of the time-consuming function program to be called; If the execution status of the time-consuming function program to be called is complete, obtain the execution result of the time-consuming function program to be called; If the execution status of the time-consuming function program to be called is incomplete, the program execution interface will be called to execute the time-consuming function program to be called.
13. A program execution device for a smart card, characterized in that, The smart card has at least one target card application installed within it. The at least one target card application includes one or more of the following: a time-consuming function program, a card application containing a time-consuming function program, and a card application that needs to call the execution result of the time-consuming function program during runtime. The time-consuming function program is a function program whose execution time exceeds a preset time threshold. The device includes: An execution module is used to respond to receiving a non-time-consuming interactive instruction from an external terminal during the operation of the main function program of the smart card, select a target function program from the time-consuming function programs that have not yet been processed, and execute the target function program; The response module is used to respond to the completion of the execution of the target function program by sending the non-time-consuming interactive command response to the external terminal.
14. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the program execution method of any one of claims 1 to 12 by executing the computer instructions.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the program execution method according to any one of claims 1 to 12.