Read-write lock control method and device for smart card and medium

By creating a global lock manager in a smart card to manage the mapping relationship between lock objects and read and write locks, the problem that read and write locks cannot be effectively controlled in a multi-threaded environment is solved, and secure access to object instances is achieved and data competition is prevented. It is suitable for embedded resource-constrained devices.

CN120386641APending Publication Date: 2025-07-29EASTCOMPEACE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510321274.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-18
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

Existing read and write locks are valid when the method internal controls access to variables, but cannot effectively control the access of variables during other methods or through object instances, and have poor applicability.

Method used

By creating a global lock manager in a smart card, managing the mapping relationship between lock objects and read and write locks, the application creates lock objects and locks and unlocks through the global lock manager, directly managing object instances and read and write locks, ensuring that the variables can be effectively controlled no matter where they are accessed.

Benefits of technology

It improves the scope of application of read and write locks, ensures the security of access to object instances in a multi-threaded environment, prevents data competition and inconsistency, and is suitable for embedded resource-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386641A_ABST
    Figure CN120386641A_ABST
Patent Text Reader

Abstract

The invention discloses a read-write lock control method and device for an intelligent card and a medium. The method comprises the steps that a global lock manager is created through an application; creating the lock object through an application; the application locks the lock object through the global lock manager to obtain a locked object; under the condition that the application calls the locked object, the locked object is unlocked through the global lock manager to obtain an unlocked object, and the unlocked object represents the object instance in the unlocked state. The global lock manager directly manages the object instance and the read-write lock so as to perform access control on the whole object instance, and the control can be effectively performed no matter the variable is inside or outside the method, or the access is performed through the object instance, so that the application range of the read-write lock in the intelligent card is expanded, and the method can be widely applied to the technical field of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a method, device, and medium for controlling read-write locks of a smart card. Background Art

[0002] Existing read-write locks are usually declared inside a method, and the access to variables is controlled through the control method. However, if the variables are accessed in other methods or directly through an object instance, the read-write locks cannot effectively control them, and the applicability of the read-write locks is poor. Summary of the Invention

[0003] In view of this, an object of an embodiment of the present invention is to provide a method, device, and medium for controlling read-write locks of a smart card, which can improve the applicability of the read-write locks.

[0004] In a first aspect, an embodiment of the present invention provides a method for controlling read-write locks of a smart card, which is applied to the smart card. The smart card is provided with multiple applications, and the multiple applications are driven by different concurrent threads. The method for controlling read-write locks of the smart card includes:

[0005] Create a global lock manager through the application, where the global lock manager is used to manage the mapping relationship between lock objects and read-write locks;

[0006] Create the lock object through the application, where the lock object represents an object instance that needs to be locked;

[0007] The application locks the lock object through the global lock manager to obtain a locked object;

[0008] When the application finishes calling the locked object, unlock the locked object through the global lock manager to obtain an unlocked object, where the unlocked object represents the object instance in an unlocked state.

[0009] In some optional embodiments, creating the global lock manager through the application further includes:

[0010] When the application reads and writes a common library, generate first code, where the common library represents a library package for storing common resources and functions;

[0011] Generate the global lock manager in a virtual machine after the application runs the first code, where the virtual machine is located inside the smart card.

[0012] In some optional embodiments, after generating the global lock manager in the virtual machine, the method further includes:

[0013] When starting the virtual machine, create a first linked list, and the first linked list is an empty linked list;

[0014] When locking a said object instance to obtain a said locked object, insert a node into the linked list, where the node records the mapping relationship between the locked object and the read-write lock;

[0015] When unlocking the locked object to obtain the unlocked object, delete the node from the linked list.

[0016] In some alternative embodiments, the method further includes:

[0017] After locking the object instance, check the flag bit of the object instance;

[0018] When the flag bit of the object instance is configured with a first preset value, insert a said node into the linked list;

[0019] When the flag bit of the object instance is configured with a second preset value, relock the object instance; and

[0020] After unlocking the object instance, check the flag bit of the object instance;

[0021] When the flag bit of the object instance is configured with the second preset value, delete the node from the linked list;

[0022] When the flag bit of the object instance is configured with the first preset value, relock the object instance.

[0023] In some alternative embodiments, creating the lock object by the application includes:

[0024] Call a lock software package through the application, where the software package is used to provide a lock mechanism;

[0025] The application constructs the lock object according to the constructor of the lock software package.

[0026] In some alternative embodiments, the application locks the lock object through the global lock manager to obtain a locked object, including:

[0027] Call the lock method of the read-write lock through the application;

[0028] Bind the lock object to the read-write lock through the lock method, and configure the flag bit in the lock object with a first preset value through the virtual machine to obtain the locked object.

[0029] In some alternative embodiments, before binding the lock object to the read-write lock through the lock method, the method further includes:

[0030] Obtain the flag bit value in the lock object;

[0031] When the flag bit value is equal to the first preset value, find the target lock that locks the lock object in the global lock manager, and add the current thread of the current application to the blocking queue of the target lock;

[0032] When the flag bit value is equal to the second preset value, bind the lock object to the read-write lock through the lock method.

[0033] In some alternative embodiments, the unlocking the locked object by the global lock manager to obtain an unlocked object includes:

[0034] Invoke the unlock method of the read-write lock through the application;

[0035] Unbind the locked object from the read-write lock through the unlock method, and configure the flag bit in the locked object to the second preset value by the virtual machine to obtain the unlocked object.

[0036] In a second aspect, an embodiment of the present invention provides a computer device, which includes a processor, a memory, and a computer program stored on the memory and executable by the processor. When the computer program is executed by the processor, the steps of the above method are implemented.

[0037] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a program executable by a processor is stored. The program executable by the processor is used to execute the method as described above when executed by the processor.

[0038] Implementing the embodiments of the present invention includes the following beneficial effects: The embodiments of the present invention provide a method for controlling read-write locks of a smart card, including: creating a global lock manager through the application, where the global lock manager is used to manage the mapping relationship between lock objects and read-write locks; creating the lock object through the application, where the lock object represents an object instance that needs to be locked; the application locks the lock object through the global lock manager to obtain a locked object; when the application finishes calling the locked object, the global lock manager unlocks the locked object to obtain an unlocked object, and the unlocked object represents the object instance in an unlocked state. The global lock manager directly manages the object instance and the read-write lock, thereby performing access control on the entire object instance. Whether the variable is inside or outside the method, or accessed through the object instance, effective control can be achieved, thereby improving the applicable range of the read-write lock in the smart card. By installing the library package in the smart card and allowing multiple applications to access the content in the library package simultaneously, the traditional virtual machine must modify the library package code to add synchronization locks to implement access control of the content. The read-write lock of the present application can lock the resources by the caller without updating the library package code, preventing data problems caused by concurrent access with other applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 FIG. is a schematic structural diagram of a read-write lock control system for a smart card provided by an embodiment of the present invention;

[0040] Figure 2 FIG. is a flowchart of a method for controlling a read-write lock of a smart card provided by an embodiment of the present invention;

[0041] Figure 3 FIG. is a schematic diagram of thread blocking provided by an embodiment of the present invention;

[0042] Figure 4 FIG. is a schematic flowchart of detecting a read-write lock provided by an embodiment of the present invention;

[0043] Figure 5 FIG. is a schematic block diagram of the structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0044] The embodiments of the present invention will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present invention and should not be construed as a limitation of the present invention.

[0045] In the description of the present invention, it should be understood that with regard to the orientation description, such as the orientation or positional relationship indicated by up, down, front, back, left, right, etc., it is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention.

[0046] In the description of the present invention, the meaning of "several" is one or more, the meaning of "multiple" is two or more. Understandings such as "greater than", "less than", "exceeding", etc. do not include the present number, and understandings such as "above", "below", "within", etc. include the present number. If there is a description of "first" and "second", it is only for the purpose of distinguishing technical features and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features or implicitly indicating the sequence relationship of the indicated technical features.

[0047] In the description of the present invention, unless otherwise clearly defined, words such as "set", "installed", "connected", etc. should be understood in a broad sense. Those skilled in the art can reasonably determine the specific meanings of the above words in the present invention in combination with the specific content of the technical solution.

[0048] The embodiments of the present invention provide a method, device and medium for controlling read-write locks of a smart card. Among them, the method for controlling read-write locks of a smart card includes: creating a global lock manager through the application, and the global lock manager is used to manage the mapping relationship between lock objects and read-write locks; creating the lock object through the application, and the lock object represents an object instance that needs to be locked; the application locks the lock object through the global lock manager to obtain a locked object; when the application finishes calling the locked object, unlocks the locked object through the global lock manager to obtain an unlocked object, and the unlocked object represents the object instance in an unlocked state. The global lock manager directly manages the object instance and the read-write lock, thereby performing access control on the entire object instance. Whether the variable is inside or outside the method, or accessed through the object instance, effective control can be carried out, thereby improving the applicable range of the read-write lock in the smart card. No matter where the members of the object instance are accessed, as long as the object instance is locked, other threads cannot access its members. Ensure the security of object instance access in a multi-threaded environment and prevent data competition and inconsistency. It is a lightweight read-write lock solution suitable for embedded resource-constrained devices.

[0049] First, an exemplary description is made of the implementation environment of the present invention. This example does not limit the specific device structure, but is a specific implementation environment that can execute the technical solution of the present invention. Refer to Figure 1 , Figure 1Schematic diagram of the implementation environment of the embodiments of the present invention. The smart card in this embodiment is provided with multiple applications, and the multiple applications are driven by different concurrent threads. Therefore, the multiple applications of the smart card can be executed synchronously, and the multiple applications are independent of each other. When the multiple applications access the common resources of the common library, read-write locks are started.

[0050] Based on the implementation environment shown below, the control method of the embodiments of the present invention will be further elaborated. Figure 1 Shown in the implementation environment, the control method of the embodiments of the present invention will be further elaborated.

[0051] Refer to Figure 2 , Figure 2 It is a flowchart of a read-write lock control method for a smart card provided by an embodiment of the present invention. The read-write lock control method for the smart card includes but is not limited to the following steps:

[0052] S201, create a global lock manager through the application, and the global lock manager is used to manage the mapping relationship between the lock object and the read-write lock;

[0053] S202, create the lock object through the application, and the lock object represents the object instance that needs to be locked;

[0054] S203, the application locks the lock object through the global lock manager to obtain a locked object;

[0055] S204, when the application finishes calling the locked object, unlock the locked object through the global lock manager to obtain an unlocked object, and the unlocked object represents the object instance in the unlocked state.

[0056] It should be noted that the read-write lock control of this application is the read-write control of the applications of the smart card, that is, the read-write lock control of the multiple applications of the smart card. Each application is executed through an independent thread, so that the multiple applications can be executed concurrently with high execution efficiency; and the multiple applications of the smart card are executed simultaneously, and multiple operations can be completed. Compared with the single-thread and single-application of the traditional smart card, the smart card of this application has a faster execution speed and higher processing efficiency. When the current application needs to access public data, it creates a global lock manager and a lock object, and manages the thread of the current application and the lock object through the global lock manager, and locks the lock object to the thread of the current application, so as to prevent the read-write access of other threads; after the thread of the current application finishes calling the locked object, it unlocks through the global lock manager, so that other threads in the blocked queue can perform read-write access.

[0057] In some alternative embodiments, Figure 2The creation of the global lock manager in step 201 shown includes, but is not limited to: when the application reads and writes a common library, generating first code, where the common library represents a library package for storing common resources and functions; after running the first code through the application, generating the global lock manager within a virtual machine located within the smart card.

[0058] Specifically, during the operation of the application, when it is necessary to read and write access common resources or functions in the common library, the application automatically generates corresponding execution code (i.e., the first code), thereby performing subsequent creation of the global lock manager, lock objects, and read-write lock control through the global lock manager. The first code matches the application, that is, different applications generate different first codes. Specifically, the first code can be preset in the execution file corresponding to the first application, or a common code block can be set in advance, and the parameter information in the code block is modified according to the application's own attribute information when the application references it, so that the code in the code block completes the read-write control of the application after execution in the application. Specifically, the generation and execution are performed in the virtual machine corresponding to the application, thereby protecting the application from interference.

[0059] In some alternative embodiments, after generating the global lock manager within the virtual machine, the method further includes: when starting the virtual machine, creating a first linked list, where the first linked list is an empty linked list; when locking an object instance to obtain a locked object, inserting a node into the linked list, where the node records the mapping relationship between the locked object and the read-write lock; when unlocking the locked object to obtain the unlocked object, deleting the node from the linked list.

[0060] Specifically, when the virtual machine starts, an empty linked list is created. Whenever an object instance is locked, a node is inserted into the linked list; each node records the mapping relationship between the locked object instance and the read-write lock; when each read-write lock is released, a node corresponding to the read-write lock is deleted from the linked list, thereby releasing the object instance locked by the read-write lock. At this time, other threads / threads in the blocked queue can perform read-write access to the object instance.

[0061] In some alternative embodiments, the method further includes: after locking the object instance, checking the flag bit of the object instance; when the flag bit of the object instance is configured with a first preset value, inserting one of the nodes into the linked list; when the flag bit of the object instance is configured with a second preset value, relocking the object instance; and after unlocking the object instance, checking the flag bit of the object instance; when the flag bit of the object instance is configured with the second preset value, deleting the node from the linked list; when the flag bit of the object instance is configured with the first preset value, relocking the object instance.

[0062] Specifically, after locking the object instance, check the flag bit (Lock_flag) of the object instance. If Lock_flag is 1, it indicates that the object instance has been locked. The first preset value is 1, and a node is inserted into the linked list to bind the object instance with the read-write lock. When the flag bit of the object instance is configured with the second preset value (the second preset value is 0, which is specifically set according to requirements and is not limited here), it indicates that the object instance is not locked or the locking fails, and the object instance needs to be relocked. If the locking fails continuously for multiple times, corresponding error reports and warning messages are generated for professionals to handle. After unlocking the object instance, check the flag bit of the object instance to see if the object instance is unlocked according to the flag bit. When the flag bit of the object instance is configured with the second preset value, the object instance is unlocked, and the node corresponding to the object instance and the read-write lock is deleted from the linked list; when the flag bit of the object instance is configured with the first preset value, the object instance is not unlocked, and the object instance is relocked. If the unlocking fails continuously for multiple times, corresponding error reports and warning messages are generated for professionals to handle.

[0063] During the operation of other threads, when executing read-write instructions, it is necessary to check whether the object of the current operation is an object locked by other threads, which is detected through the lock flag bit of the object header; when the flag bit is 0, continue to execute. When the flag bit is 1, it means that the object has been locked. The corresponding lock object (such as readWriteLockObject) is found through the global lock manager. If the owner of the current lock is not the current thread, the current thread is added to the blocking queue of the lock and the current thread is suspended. If it is the current thread, continue to execute.

[0064] In some alternative embodiments, creating the lock object through the application includes: the application calling a lock software package, where the software package is used to provide a lock mechanism; and the application constructing the lock object according to the constructor of the lock software package.

[0065] Specifically, the software package can be stored in the smart card or sent via the cloud, without specific limitation. During the process of the constructor constructing the lock object, a lock object is created by calling the provided read-write lock API (Application Programming Interface). The lock object is a structure that maintains the relationship between the read-write lock and the current thread.

[0066] In some alternative embodiments, the application locks the lock object through the global lock manager to obtain a locked object, including: the application calls the lock method of the read-write lock; through the lock method, the lock object is bound to the read-write lock, and the flag bit in the lock object is configured to a first preset value by the virtual machine to obtain the locked object.

[0067] Specifically, referring to Figure 3 , in the first code, the lock() method of the read-write lock is called for locking. Inside the Lock() method, object instances (such as Figure 3 object_A, object_B, object_C, and object_D) are bound to the read-write locks (such as Figure 3 the read-write locks ReadWriteLock_A, ReadWriteLock_B, ReadWriteLock_C, and ReadWriteLock_D that lock the object instances in Figure 3 . At the same time, the virtual machine sets the flag bit (Lock_flag) in the object instance header of the locked object to 1. During the locking process, it is necessary to detect whether the object instance has been locked (check whether the flag bit is already 1). If it has been locked, the read-write lock of the object instance is searched in the global lock manager, and the current thread of the current application is added to the blocking queue of the read-write lock (such as

[0068] in the blocking queue of ReadWriteLock_A in Figure 3 , thread 1 and thread 3 are arranged in sequence, and thread 1 and thread 3 compete for locking in sequence, that is, when ReadWriteLock_A is unlocked, thread 1 first obtains ReadWriteLock_A for locking). When the object instance is released, it competes again for the locking process.

[0068] In some alternative embodiments, before binding the lock object to the read-write lock through the lock method, the method further includes: obtaining the value of the flag bit in the lock object; in the case where the flag bit value is equal to the first preset value, searching for the target lock that locks the lock object in the global lock manager, and adding the current thread of the current application to the blocking queue of the target lock; in the case where the flag bit value is equal to the second preset value, binding the lock object to the read-write lock through the lock method.

[0069] Specifically, referring to Figure 4 During the running of the current thread, when running read and write instructions, it is necessary to check whether the object instance of the current operation is an object instance locked by other threads, and the check is performed through the flag bit in the object instance header; when the flag bit is 0, the read and write of the current thread continues. When the flag bit is 1, it indicates that the object instance has been locked by other threads. The global lock manager is used to find the read-write lock corresponding to the object instance, and it is determined whether the owner of the read-write lock of the object instance is the current thread. If not, the current thread is added to the blocking queue of the read-write lock, and the current thread is suspended. If so, the read and write instructions are run.

[0070] In some optional embodiments, unlocking the locked object through the global lock manager to obtain an unlocked object includes: the application calls the unlock method of the read-write lock; the unlock method unbinds the locked object from the read-write lock, and the virtual machine configures the flag bit in the locked object to a second preset value to obtain the unlocked object.

[0071] Specifically, in the first piece of code, the unlock / unlockAll method of the lock object is called to release the lock. The object header of the object instance is modified to set the flag bit (lock_flag) to 0, that is, the unlocked state; the node of the object instance is deleted in the global lock manager, and at the same time, other threads suspended on the read-write lock are awakened, and the wake-up operation algorithm adopts the first-in-first-out algorithm. The awakened threads continue to execute subsequent operations.

[0072] Implementing the embodiments of the present invention includes the following beneficial effects: The embodiments of the present invention provide a method for controlling read-write locks of a smart card, including: creating a global lock manager through the application, where the global lock manager is used to manage the mapping relationship between lock objects and read-write locks; creating the lock object through the application, where the lock object represents the object instance to be locked; the application locks the lock object through the global lock manager to obtain a locked object; after the application finishes calling the locked object, the global lock manager unlocks the locked object to obtain an unlocked object, and the unlocked object represents the object instance in the unlocked state. The global lock manager directly manages object instances and read-write locks, thereby performing access control on the entire object instance. Whether the variable is inside or outside a method, or accessed through an object instance, effective control can be performed, thereby improving the applicable range of read-write locks in the smart card. No matter where the members of the object instance are accessed, as long as the object instance is locked, other threads cannot access its members. Ensure the security of object instance access in a multi-threaded environment, and prevent data competition and inconsistency. It is a lightweight read-write lock solution suitable for embedded resource-constrained devices.

[0073] AsFigure 5 As shown in Figure 5 , in a second aspect, an embodiment of the present invention further provides a computer device, which may be a terminal. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, which when executed, can cause the processor to execute any industrial device visualization management method. The processor is used to provide computing and control capabilities to support the operation of the entire computer device. The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, it can cause the processor to execute any industrial device visualization management method. The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art can understand that Figure 5 the structure shown in Figure 5 is only a block diagram of some structures related to the solution of the present disclosure, and does not constitute a limitation on the computer device to which the solution of the present disclosure is applied. The specific computer device may include more or fewer components than Figure 5 those shown in Figure 5 , or combine some components, or have different component arrangements. It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Among them, in one embodiment, the above-mentioned processor is used to run the computer program stored in the memory to implement the following steps: creating a global lock manager through the application, where the global lock manager is used to manage the mapping relationship between lock objects and read-write locks; creating the lock object through the application, where the lock object represents an object instance that needs to be locked; the application locks the lock object through the global lock manager to obtain a locked object; when the application finishes calling the locked object, the global lock manager unlocks the locked object to obtain an unlocked object, and the unlocked object represents the object instance in an unlocked state.

[0074] It can be seen that the content in the above method embodiments is applicable to the device embodiments of the present invention. The functions specifically implemented in the device embodiments of the present invention are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those in the above method embodiments.

[0075] In addition, the embodiments of the present application also disclose a computer program product or a computer program. The computer program product or the computer program is stored in a computer-readable storage medium. The processor of the computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above method. Similarly, the content in the above method embodiments is applicable to the storage medium embodiments of the present invention. The functions specifically implemented in the storage medium embodiments of the present invention are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those in the above method embodiments.

[0076] It can be understood that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and their appropriate combinations. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital information processor, or a microprocessor, or can be implemented as hardware, or can be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassette, tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, a communication medium typically contains computer-readable instructions, data structures, program modules, or other data such as modulated data signals like carrier waves or other transmission mechanisms, and can include any information delivery medium.

[0077] The above has described the embodiments of the present invention in detail with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments, and various changes can be made without departing from the spirit of the present invention within the scope of knowledge possessed by those of ordinary skill in the art.

Claims

1. A method for controlling the read-write lock of a smart card, characterized in that, Applied to a smart card, the smart card is provided with a plurality of applications, and the plurality of applications are driven by different concurrent threads. The read-write lock control method of the smart card includes: Creating a global lock manager through the application, where the global lock manager is used to manage the mapping relationship between lock objects and read-write locks; Creating the lock object through the application, where the lock object represents an object instance that needs to be locked; The application locks the lock object through the global lock manager to obtain a locked object; When the application finishes calling the locked object, the global lock manager unlocks the locked object to obtain an unlocked object, and the unlocked object represents the object instance in an unlocked state.

2. The method according to claim 1, characterized in that The creating a global lock manager through the application further includes: When the application reads and writes a common library, generating first code, where the common library represents a library package for storing common resources and functions; Generating the global lock manager in a virtual machine after the application runs the first code, and the virtual machine is located in the smart card.

3. The method according to claim 2, wherein After generating the global lock manager in the virtual machine, the method further includes: When starting the virtual machine, creating a first linked list, and the first linked list is an empty linked list; When locking an object instance to obtain a locked object, inserting a node into the linked list, and the node records the mapping relationship between the locked object and the read-write lock; When unlocking the locked object to obtain the unlocked object, deleting the node from the linked list.

4. The method according to claim 3, characterized in that, The method further includes: After locking the object instance, checking the flag bit of the object instance; When the flag bit of the object instance is configured with a first preset value, inserting a node into the linked list; When the flag bit of the object instance is configured with a second preset value, relocking the object instance; and After unlocking the object instance, checking the flag bit of the object instance; When the flag bit of the object instance is configured with a second preset value, deleting the node from the linked list; When the flag bit of the object instance is configured with a first preset value, relocking the object instance.

5. The method according to claim 1, wherein The creating the lock object through the application includes: The application calls a lock software package, and the software package is used to provide a lock mechanism; The application constructs the lock object according to the constructor of the lock software package.

6. The method according to claim 2, wherein The application locking the lock object through the global lock manager to obtain a locked object includes: The application calls the lock method of the read-write lock; Binding the lock object to the read-write lock through the lock method, and configuring the flag bit in the locked object with a first preset value through the virtual machine to obtain the locked object.

7. The method according to claim 6, wherein Before binding the lock object to the read-write lock through the lock method, the method further includes: Obtaining the flag bit value in the lock object; When the value of the flag bit is equal to the first preset value, search for a target lock that locks the lock object in the global lock manager, and add the current thread of the current application to the blocking queue of the target lock; When the value of the flag bit is equal to the second preset value, bind the lock object to the read-write lock through the lock method.

8. The method according to claim 2, characterized in that The unlocking the locked object through the global lock manager to obtain an unlocked object includes: Invoking the unlock method of the read-write lock through the application; Unbind the locked object from the read-write lock through the unlock method, and configure the flag bit in the locked object to the second preset value through the virtual machine to obtain the unlocked object.

9. A computer device, wherein, The computer device includes a processor, a memory, and a computer program stored on the memory and executable by the processor. When the computer program is executed by the processor, the steps of the method described in any one of claims 1-8 are implemented.

10. A computer-readable storage medium storing a program executable by a processor, characterized in that, The program executable by the processor is used to execute the method described in any one of claims 1-8 when executed by the processor.