Accessing a shared data set

By recording the reader thread state in the data structure and selectively acquiring shared locks, the blocking problem caused by exclusive locks is solved, achieving efficient reader thread management and reducing resource consumption and overhead.

CN121569280APending Publication Date: 2026-02-24INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202480048877.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-08-09
Filing Date
2024-07-08
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Exclusive locks cause blocking in reader threads accessing shared datasets, and existing transactional storage implementations are resource-intensive and expensive.

Method used

By recording the reader thread state in the data structure, selectively acquiring shared locks and interrupting processing when an exclusive lock request is made, restoring the thread state and releasing the lock, the use of expensive transaction storage is avoided.

Benefits of technology

It reduces resource consumption, improves the recovery efficiency of the reader thread, avoids the high overhead of the transaction storage, and achieves efficient reader thread management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121569280A_ABST
    Figure CN121569280A_ABST
Patent Text Reader

Abstract

A computer-implemented method of accessing a shared data set using a shared lock and an exclusive lock is disclosed herein. The method includes: initiating at least one reader thread configured to perform a read operation; recording a reader thread state for the at least one reader thread in the data structure; selectively obtaining a shared lock for the at least one reader thread; implementing processing of the at least one reader thread; selectively interrupting processing of the at least one reader thread in response to the exclusive lock request; recovering at least one reader thread state using the reader thread state recorded in the data structure, and releasing the shared lock; obtaining an exclusive lock; resuming processing of the at least one reader thread; in response to determining the release of the exclusive lock, the shared lock for the at least one reader thread is reacquired.
Need to check novelty before this filing date? Find Prior Art

Description

Background Technology

[0001] This invention relates to reading and writing shared datasets.

[0002] Exclusive locks can block reader threads when providing read or write access to a shared dataset. Summary of the Invention

[0003] In one aspect, the present invention provides a computer-implemented method for accessing a shared dataset using shared locks and exclusive locks. The method includes initiating at least one reader thread configured to perform a read operation on the shared dataset. The method also includes recording the reader thread state for the at least one reader thread in a data structure in response to a request for a shared lock by the at least one reader thread. The method further includes selectively acquiring the shared lock for the at least one reader thread.

[0004] The method further includes: implementing processing for at least one reader thread after acquiring the shared lock. The method further includes: selectively interrupting the processing of at least one reader thread in response to an exclusive lock request. The method further includes: after the processing of at least one reader thread is interrupted, restoring the state of at least one reader thread using the reader thread state recorded in a data structure, and releasing the shared lock. The method further includes: acquiring an exclusive lock in response to an exclusive lock request once the held shared lock has been fully released.

[0005] The method also includes resuming processing for at least one reader thread to renegotiate the shared lock after acquiring the exclusive lock. The method also includes reacquiring the shared lock for at least one reader thread in response to determining that the exclusive lock has been released.

[0006] According to another aspect of the present invention, a computer program product is provided, comprising a computer-readable storage medium thereon having computer-readable program code thereon. The computer-readable program code is configured to implement the method according to an embodiment.

[0007] According to another aspect, the present invention provides a computer system including a processor configured to control the computer system. The computer system also includes a memory storing machine-executable instructions. Execution of the instructions causes the processor to start at least one reader thread, the at least one reader thread being configured to perform a read operation on a shared dataset. Execution of the instructions further causes the processor to record the reader thread state for the at least one reader thread in a data structure in response to a request for a shared lock by the at least one reader thread. Execution of the instructions further causes the processor to selectively acquire a shared lock for the at least one reader thread.

[0008] The execution of the instructions also causes the processor to perform processing on at least one reader thread after acquiring the shared lock. The execution of the instructions also causes the processor to selectively interrupt the processing of at least one reader thread in response to an exclusive lock request. The execution of the instructions also causes the processor to restore the state of at least one reader thread using the reader thread state recorded in a data structure and release the shared lock after the processing of at least one reader thread has been interrupted. The execution of the instructions also causes the processor to acquire the exclusive lock in response to the complete release of the shared lock holding.

[0009] The execution of the instruction also causes the processor to resume processing of at least one reader thread to renegotiate the shared lock after having already acquired the exclusive lock. The execution of the instruction also causes the processor to reacquire the shared lock for at least one reader thread in response to determining that the exclusive lock has been released. Attached Figure Description

[0010] The embodiments of the present invention will now be explained in more detail by way of example and with reference to the accompanying drawings, wherein:

[0011] Figure 1 An example of a computing environment is shown.

[0012] Figure 2 It shows Figure 1 Another view of the computing environment.

[0013] Figure 3 The instructions are shown. Figure 1 A flowchart of the method for computing environment 2.

[0014] Figure 4 The function is shown for setting a checkpoint for a reader thread that requests a shared lock in a data structure.

[0015] Figure 5 This demonstrates how to remove a reader record from a data structure.

[0016] Figure 6 This demonstrates how to roll back the reader thread to a checkpoint stored in a data structure.

[0017] Figure 7 This illustrates the process of locking the reader thread in kernel space during the addition of a thread to a data structure.

[0018] Figure 8 The process of unlocking the reader thread in kernel space is shown.

[0019] Figure 9 This illustrates exclusive locking in kernel space. Detailed Implementation

[0020] The description of various embodiments of the present invention is presented for illustrative purposes and is not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles of the embodiments, their practical application, or improvements to existing technologies in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

[0021] Database systems can be configured such that at least one reader thread can access a shared dataset. If a writer thread is used to write to or modify the shared dataset, the writer thread can block at least one reader thread. The current approach to handling multiple concurrent threads is using transactional memory implementations, such as hardware or software transactional memory. This provides a shared memory abstraction that can be used to manage multiple threads. Transactional memory implementations can have several drawbacks. Hardware transactional memory can be expensive to implement, for example, while software transactional memory can have significant overhead due to maintaining logs and committing transactions.

[0022] Examples can be beneficial because they can provide a method for resuming a reader thread after it has been interrupted, using minimal machine resources and potentially eliminating the need for a transactional storage implementation. As described below, recording the reader thread state in a data structure allows for storing the processing of at least one reader thread with minimal resources. Selectively acquiring a shared lock for at least one reader thread can include using different criteria to determine whether a reader thread is added to the shared lock. For example, a reader thread can be added to the shared lock if no exclusive lock request is pending.

[0023] The method also includes processing for at least one reader thread. The method further includes processing for selectively interrupting at least one reader thread in response to an exclusive lock request. The exclusive lock request may, for example, be an exclusive lock request for a writer thread to write to a shared dataset. The processing for selectively interrupting at least one reader thread in response to an exclusive lock request may include identifying a reader thread among the at least one reader threads that has already acquired the shared lock, and then using at least one interruption criterion to select a subset of the identified reader threads.

[0024] The method also includes restoring the state of at least one reader thread using the reader thread state recorded in the data structure after the processing of at least one reader thread is interrupted, and releasing the shared lock. At least one reader thread has been restored to the state it had when the reader thread state was recorded in the data structure.

[0025] The method further includes: acquiring an exclusive lock in response to an exclusive lock request once the shared lock has been fully released. Fully releasing the shared lock means there are no other holders of the lock. The method also includes resuming processing of at least one reader thread to retrieve the shared lock after the exclusive lock has been acquired. The method also includes reacquiring the shared lock for at least one reader thread in response to determining that the exclusive lock has been released. Determining that the exclusive lock has been released means determining that there are no longer any threads holding the exclusive lock. The reader thread state of at least one reader thread has been restored by retrieving the reader thread state from a data structure and, for example, loading it into the CPU. This method can be advantageous because it uses the reader thread state recorded in a data structure instead of using expensive transaction memory and avoids the overhead of software transaction memory to restore the reader thread.

[0026] In different examples, access to a shared dataset can be provided in different ways. In one example, the shared dataset is a shared dataset available via a database management system, and the shared dataset can be, for example, a structured file, a database, a memory buffer, a shared data structure (such as a list), or a database view.

[0027] In some examples, if multiple reader threads are started, they can be started simultaneously or added at different times. For instance, different reader threads can be started at different times, in which case, when a reader thread is started, it can be added to an existing shared lock.

[0028] In a further example, the reader thread state for at least one reader thread includes at least one CPU state of at least one reader thread. This allows the thread to revert to the state it was in when it was stored in the data structure.

[0029] In another instance, at least one CPU state includes the register contents and thread stack contents of at least one CPU. This can be beneficial because the data may be useful when restoring at least one reader thread to its previous state.

[0030] In another example, the method also includes using the sigsetjmp function to at least partially construct the reader thread state. This example may be useful because it provides a way to implement the system efficiently.

[0031] In another example, resuming at least one reader thread is performed, at least partially, using the `siglongjmp` function. This example may be useful because it also provides a way to implement the system efficiently.

[0032] In another example, interruption of at least one reader thread is performed at least in part by sending a signal to at least one reader thread.

[0033] In another example, the pthread_kill function is used to send a signal to at least one reader thread.

[0034] In another example, the process of selectively interrupting at least one reader thread in response to an exclusive lock request includes: identifying at least one reader thread that has already acquired the shared lock, and selecting a subset of the identified reader threads using at least one interruption criterion. This allows the method of selecting all reader threads that satisfy at least one interruption criterion to be interrupted. Threads that do not satisfy at least one interruption criterion will not be interrupted, and the exclusive lock request will be effectively blocked.

[0035] In another example, at least one interrupt criterion includes at least one reader thread being identified as uninterruptible. The method also includes delaying the acquisition of the exclusive lock until completion of identifying one of the at least one reader thread as uninterruptible. This can be beneficial because it provides a way to prevent the exclusive lock from being enforced and stopping the specified reader thread.

[0036] In another example, at least one interruption criterion includes an estimate that a thread is nearing completion exceeding a predetermined completion threshold. This might mean there is a model or metric indicating how close a thread is to completion. The method also includes delaying the acquisition of the exclusive lock until at least one of the reader threads is identified as having completed the task because its estimated completion level is above the predetermined completion threshold. In this example, if a reader thread has already completed beyond the predetermined completion threshold, it is not interrupted by the exclusive lock. The exclusive lock waits until those threads complete before being acquired.

[0037] In another example, a data structure stores the lock duration acquired for at least one reader thread. At least one interruption criterion includes a predetermined process age. The method also includes delaying the acquisition of the exclusive lock if the acquired lock duration is earlier than the predetermined process age. This can be beneficial because it provides a way to allow older read threads to complete before granting the exclusive lock.

[0038] In another example, a data structure stores actor priorities for at least one reader thread. Predefined criteria include a predetermined priority. The method also includes delaying the exclusive lock if the actor priority is higher than the predetermined priority. This implementation can be advantageous because it provides a method to prevent important threads from being interrupted by writes to the lock.

[0039] In another example, at least one interruption criterion includes the age of one or more of at least one reader thread. Reader threads selected from at least one reader thread that have a predetermined thread age are allowed a predetermined completion time before the exclusive lock is enforced. This can be beneficial because it allows reader threads that have been running for a long time to continue before they are interrupted.

[0040] In another example, the method also includes delaying the acquisition of the exclusive lock until all locks on the shared dataset have been released. This can be beneficial because if another process accesses the shared dataset, the exclusive lock is not granted.

[0041] In another example, selectively acquiring a shared lock for at least one reader thread includes acquiring the shared lock if no exclusive lock requests are pending.

[0042] In another example, selectively acquiring a shared lock for at least one reader thread includes acquiring the shared lock if an exclusive lock request is pending and other shared reader threads are accessing the shared dataset.

[0043] In another example, selectively acquiring a shared lock for at least one reader thread includes delaying the acquisition of the shared lock when a writer thread performing a write operation on the shared dataset has already acquired an exclusive lock.

[0044] In another example, selectively acquiring a shared lock for at least one reader thread includes acquiring the shared lock if one or more locking criteria are met.

[0045] In another example, one or more locking criteria include at least one reader thread being an interruptible reader thread.

[0046] In another example, other reader threads that request a shared lock after receiving an exclusive lock request are allowed to selectively acquire the shared lock during a predetermined completion time. This implementation can be advantageous because, instead of simply waiting until acquiring and then releasing the exclusive lock, the system is able to accept additional reader threads and allow them to operate for time that would otherwise be wasted.

[0047] In another example, the data structure is stored in the process memory.

[0048] In another example, the data structure is stored in thread-local storage.

[0049] In another example, the data structure is stored in persistent storage.

[0050] In another example, the data structure is stored in disk storage.

[0051] In another example, the data structure is stored in a tape memory.

[0052] In another example, an exclusive lock is an exclusive write lock configured for a writer thread to write to a shared dataset.

[0053] Various aspects of this disclosure are described by narrative text, flowcharts, block diagrams of computer systems, and / or block diagrams of machine logic included in embodiments of a computer program product (CPP). Regarding any flowchart, depending on the technology involved, operations may be performed in a different order than that shown in a given flowchart. For example, again according to the technology involved, two operations shown in consecutive flowchart blocks may be performed in reverse order, as a single integrated step, simultaneously, or in a manner that at least partially overlaps in time.

[0054] Various aspects of this disclosure are described by narrative text, flowcharts, block diagrams of computer systems, and / or block diagrams of machine logic included in embodiments of a computer program product (CPP). For any flowchart, depending on the art involved, operations may be performed in a different order than that shown in a given flowchart. For example, also according to the art involved, two operations shown in consecutive flowchart blocks may be performed in reverse order, as a single integrated step, simultaneously, or with at least partial temporal overlap.

[0055] Computer program product embodiment (“CPP embodiment” or “CPP”) is a term used in this disclosure to describe one or more sets of storage media (also referred to as “media”) collectively contained in one or more sets of storage devices that collectively contain machine-readable code corresponding to instructions and / or data for performing the computer operations specified in a given CPP claim. A “storage device” is any tangible device capable of holding and storing instructions used by a computer processor. Computer-readable storage media can be electronic, magnetic, optical, electromagnetic, semiconductor, mechanical, or any suitable combination of the foregoing, but is not limited thereto. Some known types of storage devices that include these media include: floppy disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), optical disc read-only memory (CD-ROM), digital versatile optical disc (DVD), memory sticks, floppy disks, mechanical encoding devices (e.g., punched cards or pits / protrusions formed on the main surface of an optical disc), or any suitable combination of the foregoing. Computer-readable storage media (as used in this disclosure) should not be construed as storing transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides, optical pulses through fiber optic cables, electrical signals transmitted through wires, and / or other transmission media. Those skilled in the art will understand that data is typically moved at certain incidental points in time during normal operation of the storage device, such as during access, defragmentation, or garbage collection; however, this does not render the storage device temporary, as data is not temporary at the time of storage.

[0056] The computing environment 100 includes an example environment for executing at least a portion of the computer code (database system 200) involved in the methods of the present invention. In addition to block 200, the computing environment 100 also includes, for example, a computer 101, a wide area network (WAN) 102, an end-user equipment (EUD) 103, a remote server 104, a public cloud 105, and a private cloud 106. In this embodiment, the computer 101 includes a processor group 110 (including processing circuitry 120 and cache 121), a communication infrastructure 111, volatile memory 112, persistent storage device 113 (including an operating system 122 and block 200 as described above), a peripheral device group 114 (including a user interface (UI), a device group 123, a storage device 124, and an Internet of Things (IoT) sensor group 125), and a network module 115. The remote server 104 includes a remote database 130. The public cloud 105 includes a gateway 140, a cloud coordination module 141, a host physical machine group 142, a virtual machine group 143, and a container group 144.

[0057] Computer 101 may take the form of a desktop computer, laptop, tablet, smartphone, smartwatch or other wearable computer, mainframe computer, quantum computer, or any other form of computer or mobile device now known or to be developed in the future, capable of running programs, accessing networks, or querying databases, such as remote database 130. As is well known in the field of computer technology, and depending on the technology, the execution of computer-implemented methods can be distributed across multiple computers and / or multiple locations. However, in this introduction to computing environment 100, the detailed discussion focuses on a single computer, specifically computer 101, to keep the introduction as simple as possible. Computer 101 may reside in the cloud, even if it is not physically present in the cloud. Figure 1 The computer 101 is displayed in the cloud. On the other hand, unless explicitly stated otherwise, the computer 101 does not need to be located in the cloud.

[0058] Processor group 110 includes one or more computer processors of any type now known or to be developed in the future. Processing circuitry 120 may be distributed across multiple packages, such as multiple coordinated integrated circuit chips. Processing circuitry 120 may implement multiple processor threads and / or multiple processor cores. Cache 121 is memory located within the processor chip package, typically used for data or code that should be quickly accessed by the threads or cores running on processor group 110. Cache memory is typically organized into multiple levels based on its relative proximity to the processing circuitry. Alternatively, some or all of the processor group's cache may be located "off-chip". In some computing environments, processor group 110 may be designed to process qubits and perform quantum computing.

[0059] Computer-readable program instructions are typically loaded onto computer 101 to cause the processor assembly 110 of computer 101 to perform a series of operational steps to implement a computer-implemented method, wherein the executed instructions instantiate the method specified in the flowcharts and / or the descriptive description of the computer-implemented method contained herein (collectively, the “method of the invention”). These computer-readable program instructions are stored in various types of computer-readable storage media, such as cache 121 and other storage media discussed below. Processor assembly 110 accesses the program instructions and associated data to control and direct the execution of the method of the invention. In computing environment 100, at least a portion of the instructions for performing the method of the invention may be stored in block 200 of persistent storage device 113.

[0060] Communication structure 111 is a signal transmission path that allows the various components of computer 101 to communicate with each other. Typically, this structure consists of switches and conductive paths, such as switches and conductive paths that form buses, bridges, physical input / output ports, etc. Other types of signal communication paths can be used, such as fiber optic communication paths and / or wireless communication paths.

[0061] Volatile memory 112 is any type of volatile memory currently known or to be developed in the future. Examples include dynamically typed random access memory (RAM) or statically typed RAM. Typically, volatile memory 112 is characterized by random access, but this is not required unless explicitly stated otherwise. In computer 101, volatile memory 112 is located in a single package and inside computer 101; however, as an alternative or supplement, volatile memory may be distributed across multiple packages and / or located outside computer 101.

[0062] The persistent storage device 113 is any form of non-volatile storage device known or to be developed for a computer. The non-volatility of this storage device means that the stored data is retained regardless of whether the computer 101 is powered on and / or directly powered to the persistent storage device 113. The persistent storage device 113 may be a read-only memory (ROM), but typically at least a portion of the persistent storage device allows data to be written, deleted, and rewritten. Some common forms of persistent storage devices include hard disks and solid-state storage devices. The operating system 122 may take many forms, such as various known proprietary operating systems or open-source portable operating system interface type operating systems employing a kernel. The code contained in block 200 typically contains at least the portion of computer code involved in performing the methods of the present invention.

[0063] Peripheral device group 114 includes the peripheral device group of computer 101. Data communication connections between peripheral devices and other components of computer 101 can be implemented in various ways, such as Bluetooth connections, near field communication (NFC) connections, connections established via cables (e.g., Universal Serial Bus (USB) type cables), plug-in connections (e.g., Secure Digital (SD) cards), connections established via local area networks (LANs), and even connections established via wide area networks (WANs) such as the Internet. In various embodiments, UI device group 123 may include components such as displays, speakers, microphones, wearable devices (e.g., goggles and smartwatches), keyboards, mice, printers, touchpads, game controllers, and haptic devices. Storage device 124 is an external storage device, such as an external hard drive, or a pluggable storage device, such as an SD card. Storage device 124 may be persistent and / or volatile. In some embodiments, storage device 124 may take the form of a quantum computing storage device for storing data in the form of qubits. In embodiments where computer 101 requires substantial storage (e.g., computer 101 stores and manages a large database locally), this storage device can be provided by a peripheral storage device designed for storing large amounts of data, such as a storage area network (SAN) shared by multiple geographically distributed computers. The IoT sensor group 125 consists of sensors that can be used in Internet of Things (IoT) applications. For example, one sensor could be a thermometer, and another could be a motion detector.

[0064] Network module 115 is a collection of computer software, hardware, and firmware that allows computer 101 to communicate with other computers via WAN 102. Network module 115 may include hardware such as a modem or Wi-Fi transceiver, software for packetizing and / or unpacking data for communication network transmission, and / or web browser software for communicating data over the Internet. In some embodiments, the network control and network forwarding functions of network module 115 are performed on the same physical hardware device. In other embodiments (e.g., embodiments utilizing software-defined networking (SDN), the control and forwarding functions of network module 115 are performed on physically separate devices, such that the control function manages several different network hardware devices. Computer-readable program instructions for performing the methods of the present invention can typically be downloaded to computer 101 from an external computer or external storage device via a network adapter card or network interface included in network module 115.

[0065] WAN 102 is any wide area network (e.g., the Internet) capable of communicating computer data over non-local distances using any technology currently known or to be developed in the future. In some embodiments, WAN 102 may be replaced by and / or supplemented by a local area network (LAN), which is designed for communicating data between devices located in a local area, such as a Wi-Fi network. WANs and / or LANs typically include computer hardware such as copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and edge servers.

[0066] End User Equipment (EUD) 103 is any computer system used and controlled by an end user (e.g., a customer of the enterprise operating computer 101) and may take any of the forms described above in relation to computer 101. EUD 103 typically receives helpful and useful data from the operation of computer 101. For example, assuming computer 101 is designed to provide advice to an end user, this advice is typically communicated to EUD 103 via WAN 102 from network module 115 of computer 101. Thus, EUD 103 may display or otherwise present this advice to the end user. In some embodiments, EUD 103 may be a client device, such as a thin client, a heavy client, a mainframe computer, a desktop computer, etc.

[0067] Remote server 104 is any computer system that provides at least some data and / or functionality to computer 101. Remote server 104 can be controlled and used by the same entity operating computer 101. Remote server 104 represents a machine that collects and stores helpful and useful data for use by other computers, such as computer 101. For example, assuming computer 101 is designed and programmed to provide recommendations based on historical data, that historical data could be provided to computer 101 from a remote database 130 of remote server 104.

[0068] Public cloud 105 is any computer system available to multiple entities, providing on-demand availability of computer system resources and / or other computing capabilities, particularly data storage (cloud storage) and computing power, without requiring direct active management by the user. Cloud computing typically leverages resource sharing to achieve consistency and economies of scale. Direct and active management of the computing resources of public cloud 105 is performed by the computer hardware and / or software of cloud orchestration module 141. The computing resources provided by public cloud 105 are typically implemented by virtual computing environments running on various computers constituting host physical group 142, which is the world of physical computers available in public cloud 105 and / or public cloud 105. Virtual computing environments (VCEs) typically take the form of virtual machines from virtual machine group 143 and / or containers from container group 144. It is understood that these VCEs can be stored as images and can be transferred between various physical host machines, either as images or after the VCEs are instantiated. The cloud orchestration module 141 manages the transmission and storage of images, deploys new instances of VCE, and manages active instances of VCE deployments. Gateway 140 is a collection of computer software, hardware, and firmware that allows the public cloud 105 to communicate via WAN 102.

[0069] Virtualized Computing Environments (VCEs) will now be explained further. A VCE can be stored as an "image." New active instances of a VCE can be instantiated from an image. Two common types of VCEs are virtual machines and containers. A container is a VCE that uses operating system-level virtualization. This refers to the operating system's functionality, where the kernel allows multiple isolated user-space instances, called containers, to exist. From the perspective of the programs running within them, these isolated user-space instances typically behave like a real computer. Computer programs running on a regular operating system can utilize all the resources of that computer, such as connected devices, files and folders, network shares, CPU power, and quantifiable hardware capabilities. However, programs running within a container can only use the contents of the container and the devices assigned to the container; this functionality is called containerization.

[0070] Private cloud 106 is similar to public cloud 105, except that its computing resources are available only to a single enterprise. While private cloud 106 is depicted as communicating with WAN 102, in other embodiments, private cloud may be completely disconnected from the internet and accessible only via a local / private network. A hybrid cloud is a combination of multiple different types of clouds (e.g., private cloud, community cloud, or public cloud types), typically implemented by different vendors. Each of the multiple clouds remains an independent and discrete entity, but the larger hybrid cloud architecture is bound together through standardization or proprietary technologies to enable orchestration, management, and / or data / application portability between the multiple component clouds. In this embodiment, both public cloud 105 and private cloud 106 are part of a larger hybrid cloud.

[0071] Figure 2 Another example of computing environment 100 is shown. Figure 2 Not shown in Figure 1 All the features present in the diagram.

[0072] Persistent storage device 113 is shown to include an implementation of database system 200. Database system 200 can be used to provide access to shared dataset 202. Memory 113 is also shown to include a shared lock request 204 received from at least one reader thread. Memory 113 is also shown to include a data structure 206 for recording the state of at least one reader thread. Memory 113 is also shown to include an exclusive lock request 208 received from a writer thread configured to perform a write operation on shared dataset 202.

[0073] Figure 3 This shows the operation. Figure 1 and 2 The flowchart of a method in computer system 100 shows that, in step 300, at least one reader thread is started and configured to perform a read operation on shared dataset 202. In step 302, in response to receiving a shared lock request 204 from at least one reader thread, the reader thread state for at least one reader thread is recorded in data structure 206. In step 304, a shared lock is selectively acquired for at least one reader thread. In step 306, after at least one reader thread acquires the shared lock, processing is implemented for at least one reader thread. In step 308, processing of at least one reader thread is selectively interrupted by an exclusive lock. Some read threads may have attributes that exclude them from interruption. For example, uninterruptible threads or threads with an age exceeding a predetermined threshold may not be interrupted.

[0074] In step 310, after interrupting the processing of at least one reader thread, the state of at least one reader thread is restored using the reader thread state recorded in the data structure. In step 312, once the holding of the shared lock is completely released, an exclusive lock is acquired in response to an exclusive lock request. The shared lock is completely released when no thread is anymore holding the shared lock.

[0075] In step 314, processing by at least one reader thread resumes to re-request the shared lock. In step 316, in response to the release of the exclusive lock, the shared lock is reacquired by at least one reader thread. Once the shared lock is received, the at least one reader thread can resume its read operation on the shared dataset 202.

[0076] Figure 4 A function is shown for setting a checkpoint in data structure 206 for a reader thread requesting a shared lock. This is equivalent to recording the reader thread state for at least one reader thread in data structure 206. In step 400, the CPU state of the reader thread requesting the shared lock is obtained. Locking the record of the reader thread state in data structure 206 prevents modification of the data structure by another process while the reader thread state is being written to data structure 206. The locking of data structure 206 differs from shared locks and exclusive locks. Data structure 206 is used to store the reader thread state for at least one reader thread. The locking of data structure 206 is used to protect the integrity data structure 206 when accessing it.

[0077] In step 402, the lock protecting data structure 206 is invoked. In step 404, the reader thread requesting the lock records its CPU state in data structure 206. In step 406, the lock on data structure 206 is released. 408 indicates the return of the function provided to the signal handler in block 406. A value of 0 indicates a successful function call. If the thread is reset to its checkpoint, "EAGAIN" is returned. The error code EAGAIN is a predefined POSIX error code that means the reader thread has been interrupted.

[0078] Figure 5 This demonstrates how to remove a record of the reader thread from data structure 206 (removal of the reader thread state). First, 500, data structure 206 is locked, see [link to documentation]. Figure 4The process involves locking the data structure to prevent modification by another process during the removal of the reader thread state. In step 502, the caller ID of the reader thread is obtained. The caller ID of the reader thread is the thread ID or process ID of the reader thread whose reader thread state is removed from data structure 206. In block 504, data structure 206 is modified to remove the reader thread state. The caller ID of the reader thread is used to identify the record of the reader thread in data structure 206. In step 506, data structure 206 is unlocked.

[0079] Figure 6 This illustrates how to roll back a reader thread to its checkpoint stored in data structure 206. This is a recovery of at least one reader thread state using the reader thread states recorded in data structure 206. Rollback is the restoration of a thread to a previous or earlier state. In block 600, the iterator variable "remainder" is set to zero. An iterator variable is a variable used to track the progress of a loop in a program or function. The variable "remainder" represents the state at which the loop continues to run. Figure 6 The function shown indicates how many reader thread states remain in the data structure after the current function, where the number of active reader threads is the variable "N". Next, in step 602, all entries in the data structure are iterated over. If the iterator equals N or the number of entries in data structure 206, the function proceeds to "Yes" and returns the remainder. If the answer is "No", the block proceeds to step 604. In block 604, the thread ID of the next reader thread is obtained. Next, in block 606, it is determined whether "Entry is being selected". In step 606, it is checked whether a particular reader thread state is one that has been selected for rollback. If the answer is "No", the method returns to block 608, and the iterator i and the variable "Remainder" are incremented. The value of "Remainder" is incremented because the reader thread state was not selected for rollback. If the answer is "Yes", in block 610, the execution of the reader thread is reset to a storage checkpoint in data structure 206 (the execution context of the thread identified by the ID is reset to the storage checkpoint). Then, in block 612, the thread is removed from the container (data structure 206). The method then returns to block 602. The method ends when the states of all reader threads in data structure 206 have been iterated through and are maintained for later rollback or removal after rollback.

[0080] Figure 7 , 8 Figures 9 and 1 show flowcharts of several methods using the API in kernel space locking. Kernel space locking is a locking operation performed in the CPU execution space of the (operating system's) kernel. Figure 7 , 8The locking procedure in section 9 describes the locking of data structure 206, which stores the reader thread state of at least one reader thread.

[0081] Figure 7 It shows the use of Figure 4 The `set_checkpoint` function adds at least one reader thread to a shared lock in kernel space during the process of creating a data structure 206. The lock in kernel space prevents data structure 206 from being edited by two sources simultaneously. Block 700 indicates that... Figure 4 The call to `set_checkpoint` shown adds the reader thread to data structure 206 and installs a signal handler for that thread. An exemplary signal handler implementation calls `std::longjmp` to set the return value of `set_checkpoint` to `EAGAIN`. If function 700 returns the error code `EAGAIN` (indicating that the call to `set_checkpoint` was interrupted), then arrow 702 is followed, and the process is repeated until the thread is not interrupted. Upon success in step 700, the reader thread state is successfully logged in data structure 206, and then in block 704, kernel space locking is performed. Next, in step 706, the signal handler is configured. The signal is unmasked, and a kernel space jump is invoked. The kernel space jump causes the current process to return from operations in kernel space, for example, to user space.

[0082] Figure 8 The call was shown Figure 5 The `unset_checkpoint` function is shown, which unlocks the reader thread in kernel space. In step 800, the `unset_checkpoint` function removes the calling thread from data structure 206 and removes the signal handler. In step 802, the lock on the reader thread in data structure 206 is released.

[0083] Figure 9 This demonstrates exclusive locking in kernel space. The function is used to... Figure 3 Step 308 provides an exclusive lock in kernel space. The first function, 900 `adjust_selection`, defines which type of reader thread to remove if locking is no longer desired. The `adjust_selection` function can be used to determine which type of reader thread or under what conditions a reader thread is suspended or not suspended. For example, this function call can be used to selectively interrupt the processing of a shared lock acquired by at least one reader thread using at least one predetermined criterion. As an example, it is possible to prevent reader threads that have been running for a long time from being interrupted.

[0084] Block 902 is used to block such as Figure 4 The function `set_checkpoint` is shown to avoid loops. When a reader is reset to its checkpoint, it can attempt to reset its checkpoint immediately. Without locks, the algorithm could remove threads from the beginning of data structure 206, and then the reader thread would insert itself at the end of data structure 206. This could lead to an infinite loop where writer threads remove reader threads from the beginning, and they subsequently insert reader threads at the end.

[0085] In step 904, it is checked whether the shared dataset 202 is already locked by another thread with an exclusive lock. If the answer is "yes", the block proceeds to step 906, where the lock on data structure 206 set in step 902 is released. The block then proceeds to block 908, where the process waits and sleeps (e.g., waits for a predetermined delay), and then returns to block 900. Returning to block 904, if no existing exclusive lock exists for the shared dataset 202, the method proceeds to block 910. In block 910, an attempt is made to acquire an exclusive lock on the shared dataset 202 (using the function `try_kernel_lock_x`). If this is successful, it proceeds to block 912, where the lock on data structure 206 is released. If unsuccessful, it proceeds to block 914, and the individual threads are rolled back to the checkpoint stored in data structure 206. In this function, the remainder value is used to identify the number of remaining reader threads. If more than zero threads reside in shared dataset 202 (remainder > 0), data structure 206 is unlocked in block 906, allowing other threads (even those recently removed) to (re)set their checkpoints and enter shared dataset 202. Then, in block 900, the selection criteria can be readjusted and the process retried. For example, at least one predetermined criterion can be changed so that more reader threads may be removed than before, resulting in a writer thread successfully writing to the exclusive lock of shared dataset 202. If the remainder is zero, this means no reader threads remain attempting to access data in shared dataset 202, and you can return to step 910 to try the kernel lock again.

[0086] Various examples may be described by one or more of the following features in the clauses numbered below:

[0087] Clause 1. A computer-implemented method for accessing a shared dataset using shared locks and exclusive locks.

[0088] The method includes:

[0089] At least one reader thread is started, the reader thread being configured to perform read operations on the shared dataset;

[0090] In response to the request for a shared lock by the at least one reader thread, the reader thread state for the at least one reader thread is recorded in a data structure;

[0091] Selectively acquire the shared lock for the at least one reader thread;

[0092] After acquiring the shared lock, the processing of the at least one reader thread is performed;

[0093] In response to an exclusive lock request, the processing of the at least one reader thread is selectively interrupted;

[0094] After the processing of the at least one reader thread is interrupted, the state of the at least one reader thread is restored using the state of the reader thread recorded in the data structure, and the shared lock is released;

[0095] Once the holding of the shared lock is completely released, the exclusive lock is acquired in response to the exclusive lock request;

[0096] After the exclusive lock has been acquired, the processing of the at least one reader thread is resumed to re-request the shared lock;

[0097] In response to determining that the exclusive lock is released, the shared lock for the at least one reader thread is reacquired.

[0098] Clause 2. The computer-implemented method according to Clause 1, wherein the reader thread state for the at least one reader thread includes at least one CPU state of the at least one reader thread.

[0099] Clause 3. The computer-implemented method according to Clause 2, wherein the at least one CPU state includes at least one CPU register contents and thread stack contents.

[0100] Clause 4. A computer-implemented method according to Clause 1, 2 or 3, wherein the method further comprises: using the sigsetjmp function to at least partially construct the reader thread state.

[0101] Clause 5. A computer-implemented method according to any one of Clauses 1 to 4, wherein the recovery of the at least one reader thread is performed at least in part using the siglongjmp function.

[0102] Clause 6. A computer-implemented method according to any one of Clauses 1 to 5, wherein the interruption of the at least one reader thread is performed at least in part by sending a signal to the at least one reader thread.

[0103] Clause 7. The computer-implemented method according to Clause 6, wherein sending the signal to the at least one reader thread is implemented using the pthread_kill function.

[0104] Clause 8. A computer-implemented method according to any one of Clauses 1 to 7, wherein selectively interrupting the process of the at least one reader thread in response to an exclusive lock request comprises:

[0105] Identify the reader thread among the at least one reader thread that has acquired the shared lock; and

[0106] Use at least one interrupt criterion to select a subset of the identified reader threads.

[0107] Clause 9. The computer-implemented method according to Clause 8, wherein the at least one interruption criterion includes identifying one of the at least one reader threads as uninterruptible, wherein the method further comprises: delaying the acquisition of the exclusive lock until the identification of the one of the at least one reader threads as uninterruptible is completed.

[0108] Clause 10. A computer-implemented method according to Clause 8 or 9, wherein the at least one interruption criterion includes an estimate of thread completion exceeding a predetermined completion threshold, wherein the method further comprises: delaying the acquisition of the exclusive lock until one of the at least one reader threads is identified as having completed the task as the estimate of thread completion exceeding the predetermined completion threshold.

[0109] Clause 11. A computer-implemented method according to Clause 8, 9 or 10, wherein the data structure stores lock times acquired for the at least one reader thread, wherein the at least one interruption criterion includes a predetermined process age, wherein the method further comprises: delaying the acquisition of the exclusive lock if the acquired lock time is earlier than the predetermined process age.

[0110] Clause 12. A computer-implemented method according to any one of Clauses 8 to 11, wherein the data structure stores actor priorities for the at least one reader thread, wherein the at least one interruption criterion includes a predetermined priority, wherein the method further comprises: delaying the acquisition of the exclusive lock if the actor priority is higher than the predetermined priority.

[0111] Clause 13. A computer-implemented method according to any one of Clauses 8 to 12, wherein the at least one interruption criterion includes the age of one or more reader threads among the at least one reader threads, wherein a reader thread selected from the at least one reader thread having a predetermined thread age is allowed a predetermined completion time prior to the reader thread being selected to interrupt.

[0112] Clause 14. A computer-implemented method according to any one of Clauses 1 to 13, wherein the method further comprises: delaying the acquisition of the exclusive lock until all locks on the shared dataset have been released.

[0113] Clause 15. A computer-implemented method according to any one of Clauses 1 to 14, wherein selectively acquiring the shared lock for the at least one reader thread comprises any one of the following:

[0114] If no exclusive lock request is pending, then acquire the shared lock;

[0115] If the exclusive lock request is pending and another shared reader thread is accessing the shared dataset, then acquire the shared lock;

[0116] If one or more locking criteria are met, the shared lock is acquired;

[0117] When an exclusive lock has already been acquired by a writer thread performing a write operation on the shared dataset, the acquisition of the shared lock is delayed; and

[0118] Its combination.

[0119] Clause 16. The computer-implemented method according to Clause 15, wherein the one or more locking criteria include the at least one reader thread being an interruptible reader thread.

[0120] Clause 17. A computer-implemented method according to Clause 15 or 16, wherein other reader threads that request the shared lock after the exclusive lock request are allowed to selectively acquire the shared lock during a predetermined completion time.

[0121] Clause 18. A computer-implemented method according to any one of Clauses 1 to 17, wherein the data structure is stored in any one of: process memory, thread-local storage, persistent storage, disk storage, and tape memory.

[0122] Clause 19. A computer program product comprising a computer-readable storage medium having computer-readable program code configured to implement the method of any one of Clauses 1 to 18.

[0123] Clause 20. A computer system comprising:

[0124] A processor configured to control the computer system; and

[0125] A memory that stores machine-executable instructions, the execution of which causes the processor to:

[0126] Start at least one reader thread, which is configured to perform read operations on the shared dataset;

[0127] In response to the request for a shared lock by the at least one reader thread, the reader thread state for the at least one reader thread is recorded in a data structure;

[0128] Selectively acquire the shared lock for the at least one reader thread;

[0129] After acquiring the shared lock, the processing of the at least one reader thread is performed;

[0130] In response to an exclusive lock request, the processing of the at least one reader thread is selectively interrupted;

[0131] After the processing of the at least one reader thread is interrupted, the state of the at least one reader thread is restored using the state of the reader thread recorded in the data structure, and the shared lock is released;

[0132] Once the holding of the shared lock is completely released, the exclusive lock is acquired in response to the exclusive lock request;

[0133] After the exclusive lock has been acquired, the processing of the at least one reader thread is resumed to re-request the shared lock;

[0134] In response to determining that the exclusive lock is released, the shared lock for the at least one reader thread is reacquired.

Claims

1. A computer-implemented method for accessing a shared dataset using shared and exclusive locks. The method includes: At least one reader thread is started, the reader thread being configured to perform read operations on the shared dataset; In response to the request for a shared lock by the at least one reader thread, the reader thread state for the at least one reader thread is recorded in a data structure; Selectively acquire the shared lock for the at least one reader thread; After acquiring the shared lock, the processing of the at least one reader thread is performed; In response to an exclusive lock request, the processing of the at least one reader thread is selectively interrupted; After the processing of the at least one reader thread is interrupted, the state of the at least one reader thread is restored using the state of the reader thread recorded in the data structure, and the shared lock is released; Once the holding of the shared lock is completely released, the exclusive lock is acquired in response to the exclusive lock request; After the exclusive lock has been acquired, the processing of the at least one reader thread is resumed to re-request the shared lock; In response to determining that the exclusive lock is released, the shared lock for the at least one reader thread is reacquired.

2. The computer-implemented method according to claim 1, wherein, The reader thread state for the at least one reader thread includes at least one CPU state of the at least one reader thread.

3. The computer-implemented method according to claim 2, wherein, The at least one CPU state includes the register contents and thread stack contents of at least one CPU.

4. The computer-implemented method according to any one of claims 1, 2, or 3, wherein, The method further includes using the sigsetjmp function to at least partially construct the reader thread state.

5. The computer-implemented method according to any one of claims 1 to 4, wherein, The restoration of at least one reader thread is performed, at least in part, using the siglongjmp function.

6. The computer-implemented method according to any one of claims 1 to 5, wherein, The interruption of the at least one reader thread is performed at least in part by sending a signal to the at least one reader thread.

7. The computer-implemented method according to claim 6, wherein, Sending the signal to the at least one reader thread is achieved using the pthread_kill function.

8. The computer-implemented method according to any one of claims 1 to 7, wherein, The process of selectively interrupting the at least one reader thread in response to an exclusive lock request includes: Identify the reader thread among the at least one reader thread that has acquired the shared lock; and Use at least one interrupt criterion to select a subset of the identified reader threads.

9. The computer-implemented method according to claim 8, wherein, The at least one interrupt criterion includes identifying one of the at least one reader threads as uninterruptible, wherein the method further includes: delaying the acquisition of the exclusive lock until the identification of the one of the at least one reader threads as uninterruptible is completed.

10. The computer-implemented method according to claim 8 or 9, wherein, The at least one interruption criterion includes an estimate of thread completion that is higher than a predetermined completion threshold, wherein the method further includes: delaying the acquisition of the exclusive lock until one of the at least one reader threads is identified as having completed the task as the estimate of thread completion being higher than the predetermined completion threshold.

11. The computer-implemented method according to claim 8, 9, or 10, wherein, The data structure stores the lock time acquired for the at least one reader thread, wherein the at least one interruption criterion includes a predetermined process age, and the method further includes: if the acquired lock time is earlier than the predetermined process age, then delaying the acquisition of the exclusive lock.

12. The computer-implemented method according to any one of claims 8 to 11, wherein, The data structure stores the actor priority for the at least one reader thread, wherein the at least one interruption criterion includes a predetermined priority, and the method further includes: delaying the acquisition of the exclusive lock if the actor priority is higher than the predetermined priority.

13. The computer-implemented method according to any one of claims 8 to 12, wherein, The at least one interruption criterion includes the age of one or more reader threads among the at least one reader threads, wherein a reader thread selected from the at least one reader thread that has a predetermined thread age is allowed a predetermined completion time before the reader thread is selected to interrupt.

14. The computer-implemented method according to any one of claims 1 to 13, wherein, The method further includes delaying the acquisition of the exclusive lock until all locks on the shared dataset have been released.

15. The computer-implemented method according to any one of claims 1 to 14, wherein, Selectively acquiring the shared lock for the at least one reader thread includes any of the following: If no exclusive lock request is pending, then acquire the shared lock; If the exclusive lock request is pending and another shared reader thread is accessing the shared dataset, then acquire the shared lock; If one or more locking criteria are met, the shared lock is acquired; When an exclusive lock has already been acquired by a writer thread performing a write operation on the shared dataset, the acquisition of the shared lock is delayed; and Its combination.

16. The computer-implemented method according to claim 15, wherein, The one or more locking criteria include the fact that at least one reader thread is an interruptible reader thread.

17. The computer-implemented method according to claim 15 or 16, wherein, Other reader threads that request the shared lock after the exclusive lock request are allowed to selectively acquire the shared lock during a predetermined completion time.

18. The computer-implemented method according to any one of claims 1 to 17, wherein, The data structure is stored in any of the following: process memory, thread-local storage, persistent storage, disk storage, and tape storage.

19. A computer program product comprising a computer-readable storage medium having computer-readable program code configured to implement the method of any one of claims 1 to 18.

20. A computer system, comprising: A processor configured to control the computer system; as well as A memory that stores machine-executable instructions, the execution of which causes the processor to: Start at least one reader thread, which is configured to perform read operations on the shared dataset; In response to the request for a shared lock by the at least one reader thread, the reader thread state for the at least one reader thread is recorded in a data structure; Selectively acquire the shared lock for the at least one reader thread; After acquiring the shared lock, the processing of the at least one reader thread is performed; In response to an exclusive lock request, the processing of the at least one reader thread is selectively interrupted; After the processing of the at least one reader thread is interrupted, the state of the at least one reader thread is restored using the state of the reader thread recorded in the data structure, and the shared lock is released; Once the holding of the shared lock is completely released, the exclusive lock is acquired in response to the exclusive lock request; After the exclusive lock has been acquired, the processing of the at least one reader thread is resumed to re-request the shared lock; In response to determining that the exclusive lock is released, the shared lock for the at least one reader thread is reacquired.