TW201112125A - Method and system for operating an instance of a data structure - Google Patents

Method and system for operating an instance of a data structure Download PDF

Info

Publication number
TW201112125A
TW201112125A TW98131255A TW98131255A TW201112125A TW 201112125 A TW201112125 A TW 201112125A TW 98131255 A TW98131255 A TW 98131255A TW 98131255 A TW98131255 A TW 98131255A TW 201112125 A TW201112125 A TW 201112125A
Authority
TW
Taiwan
Prior art keywords
lock
free
data structure
entity
capability
Prior art date
Application number
TW98131255A
Other languages
Chinese (zh)
Inventor
Zhi Gan
Yao Qi
xiao-jun Dai
Mo-Jiong Qiu
yuan-hong Wang
Original Assignee
Ibm
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ibm filed Critical Ibm
Priority to TW98131255A priority Critical patent/TW201112125A/en
Publication of TW201112125A publication Critical patent/TW201112125A/en

Links

Abstract

The invention provides a method and system for operating an instance of a data structure. The method comprises the following operations. Request a weak lock of a first lock for at least one lock free capable operation to operate the instance of the data structure. In response to obtaining the weak lock for the at least one lock free capable operation, perform the at least one lock free capable operation to operate the instance of the data structure. Request a strong lock of the first lock for one lock free incapable operation to operate the instance of the data structure. In response to obtaining the strong lock for the one lock free incapable operation, perform the lock free incapable operation to operate the instance of the data structure. According to the method and the system, the efficiency is improved for operating instances of a data structure.

Description

201112125 六、發明說明: 【發明所屬之技術領域】 詳言之,係關 本發明係關於開發並處理多執行緒軟體 於操作資料結構之實體之方法及系統。 【先前技術】 :過去二十年中,隨著微電子學技術的快速發展,電腦 ==及能力顯著增加。更多計算資源意謂可平行執 更多細作》因此,平行系統6士 處理中發揮愈來愈重要的作用Γ平行軟體開發在資訊 =里:序為在計算系統中執行之程式或程 為由程式執行之相關序列步驟。 ' 個執行緒。執行緒為指令集,或程式之拉:序;:3一或多 程式"蜀立地執行一執ζ χ 、疋區奴。可在-U视仃一執仃緒。因此,勐 處理程序,兑自4… 執仃緒基本上為輕型 ”負貝執行早一程式中之任務。通常,作孝奉 統將負責若干執行緒之排程及執行。 作業系 列資:::為—種資料組織解決方案,例如記錄或資料陣 體為資分;:或對資料執行操作。資料結構之實 在-處理程“—種貧施物件。處理資料結構之實體通常 利用系統資源心程式中使用多執行緒處理程序。此舉可 在-程式㈣# „_切應_且改良❹者體驗。若 度及回應時間。執行緒,則將大大妨礙程式執行速 行以完成任務,:緒軟體使複數個執行緒能夠平行執 同一時段期間完改良系統效率。在用於複數個任務之 凡執仃緒。然而,必須考慮執行緒之排程 143290.doc 201112125 右排程不合適,則 已知與循序地執行 以使執行緒在(5J-時簡間完成任務。 程式將發生錯誤或引起不合理的結果。 之軟體相比,難以開發多執行緒軟體。 ’所以具有平行系統結構 不存在合適的同步機制, 引起不可預知的錯誤。迄 執行緒軟體,亦即基於鎖 因為多執行緒間可能存在矛盾 之程式通常有缺陷。特別是,若 則對共用資料結構之平行存取將 今為止,使用兩種方法來開發多 之方法及無鎖方法。 夕執行緒程式化之 ㈣方法係❹鎖來同步化對共用資 ^存取。諸如互斥—β吟旗號(難咖e)及關鍵區 二;—Ο11)之同步基71均為程式員可藉以確保程式 的^ 分並不同時執行(否則將破壞共用記憶體結構) =:若—執行緒試圖獲得已由另-執行緒持有之鎖, 仃緒將丈阻’直至該鎖被釋放。舉例而言,在一程 執特定順序來執行許多執行緒。若必須按順序 令為…執行緒’則可使用執行緒鎖。執行緒鎖之基本概 =1執行緒Α及執行_將分別操作兩個功能心, 直須tB之前執行,❹可經排程而進入等待設定, 保無从在P作功月b a,接者B從等待設定被啟動。此將雄 在執行前續8之順序如何,叫將在a之後執行。 制直,為用於處理程序或執行緒之間的同步之常用機 2施簡易。在用於高效能應用之平行計算環境中, 互斥鎖 °當使料多鎖且平行執行許多執行緒時, 鎖之可擴充性不佳。對共用資料之平行存取需要複雜 143290.doc 201112125 的改進之鎖策略以排程將被 ' ^ ^ 十仃執仃之無矛盾的操作。很 難《•什该朿略以保持良妊蚪 。可能存在隱含問題,例如 死鎖(dead lock)或反向優先權。 由於許多原因,不希望封锚妯/ _ / 平罡封鎖執仃緒。明顯原因是,當執 /行緒受阻時’其在此時段期間無法完成任何事。若受阻執 灯,者正在執订尚優先權任務或即時任務,則很不希望停止 其進度。 此外,鎖之間的特定干擾可導致諸如死鎖、活鎖及優先 權反轉之錯誤狀態。使用鎖亦涉及在可顯著降低平行性之 機會之粗粒度鎖定盥堂i Φ 頻疋〃、而要更精心的設計且更易於發生錯誤 之細粒度鎖定之間的取捨。 無鎖方法係多執行緒軟體開發及處理的-種選擇。使用 硬體必3提供之原子基元…仙叫來書寫無鎖及 等/寺廣算去。可在最風行的硬體之指令集中找到此等原 子基元。不可部分完成的基元之最值得注意之處為「比較 及調K通常記為「CAS」)’其需要三個引數:記憶體 舊值及新值。若位址含有舊值,則用新值替換舊 值,否則不改變舊值,關鍵在於,硬體確保以原子方式 (atonucally)執行此「比較及調換」操作。接著使用值丄或 0將此操作之成功報告回程式。此允許演算法自記惚體讀 取資料,修改資料且寫回資料(僅當與此同時無其他執行 緒修改該資料時)。上述兩種方法具有如下表中所示之優 點及缺點。 143290.doc 201112125 可擴充性 穩定性 開發難易度 基於鎖之ϋ____ 不佳。執行緒在進入及離開關鍵區 段前需等一會兒_201112125 VI. Description of the invention: [Technical field to which the invention pertains] In particular, the present invention relates to a method and system for developing and processing a multi-threaded software entity for operating a data structure. [Prior Art]: With the rapid development of microelectronics technology over the past two decades, computer == and capacity have increased significantly. More computing resources mean that you can do more in parallel. Therefore, the parallel system is playing an increasingly important role in the processing of parallelism. Parallel software development in information = in order to execute the program or program in the computing system. Sequence steps related to program execution. ' Threads. The thread is the instruction set, or the program pulls: the order;: 3 one or more programs " stand by the execution of a stubborn χ, 疋 zone slave. You can take a look at the -U. Therefore, the 勐 processing program, from the 4... 仃 基本上 basically is a light “negative” to perform the task in the early program. Usually, filial piety will be responsible for the scheduling and execution of several threads. : For a data organization solution, such as records or data Arrays as capital; or to perform operations on the data. The actual structure of the data structure - the process of "--------- Entities that process data structures typically use multithreaded handlers in the system resource family. This can be done in -program (four) # „ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Improve system efficiency during the same period of time. It is used in a variety of tasks. However, the schedule of threads must be considered 143290.doc 201112125 If the right schedule is not suitable, it is known and executed sequentially to enable execution. The thread completes the task between 5J-time. The program will make mistakes or cause unreasonable results. Compared with the software, it is difficult to develop multi-threaded software. 'So there is no suitable synchronization mechanism with parallel system structure, causing unpredictable The error. As of the thread software, that is, based on the lock, there may be defects in the program that may be contradictory between multiple threads. In particular, if the parallel access to the shared data structure will be used today, two methods are used to develop The method and the lock-free method. The idiom stylization (4) method is a shackle to synchronize the access to the shared resource. Such as mutual exclusion - β 吟 flag (difficult coffee e) and off Keypad 2; -Ο11) Synchronization base 71 is a program that can be used by the programmer to ensure that the program's scores are not executed at the same time (otherwise the shared memory structure will be destroyed) =: If - the thread tries to get the other thread If there is a lock, the thread will block the 'until the lock is released. For example, a number of threads are executed in a specific order. If you have to order the thread in order, you can use the thread lock. The basics of the locks are as follows: executor and execution _ will operate two function cores separately, and must be executed before tB, and can be entered into the waiting setting by scheduling, and there is no slave in Ba. It is started from the wait setting. This will be executed in the order of 8 before execution, and will be executed after a. Straightening, it is simple for the common machine 2 for processing synchronization between programs or threads. In parallel computing environments for high-performance applications, the mutex is not scalable when the material is locked and many threads are executed in parallel. Parallel access to shared data requires complex improvements in 143290.doc 201112125 Lock strategy to schedule will be ' ^ ^ Shiyan There is no contradictory operation. It is difficult to maintain a good pregnancy. There may be hidden problems, such as deadlock or reverse priority. For many reasons, it is not desirable to seal the anchor / _ / The reason is that the lockout is blocked. The obvious reason is that when the execution/implementation is blocked, 'it can't do anything during this time. If the light is blocked, the person who is holding the priority task or the immediate task is not hopeful. Stopping its progress. In addition, specific disturbances between locks can lead to error states such as deadlocks, livelocks, and priority reversals. The use of locks also involves coarse-grained locking of the opportunity to significantly reduce parallelism. A trade-off between fine-grained locks that are more carefully designed and more prone to errors. The lock-free method is a choice of multi-thread software development and processing. Use the atomic primitives provided by the hardware 3. The singer is used to write without locks and etc. These primitive primitives can be found in the most popular hardware instruction set. The most notable aspect of a partially incomplete primitive is "Comparative and K is usually referred to as "CAS"). It requires three arguments: the old value of the memory and the new value. If the address contains an old value, the old value is replaced with the new value. Otherwise, the old value is not changed. The key is that the hardware ensures that this "comparison and swap" operation is performed atonucally. The success of this operation is then reported back to the program using the value 丄 or 0. This allows the algorithm to read the data, modify the data, and write back the data (only when there are no other threads to modify the data at the same time). Both of the above methods have the advantages and disadvantages shown in the following table. 143290.doc 201112125 Scalability Stability Development Difficulties based on locks ____ Poor. The thread needs to wait a while before entering and leaving the critical section.

-執行緒。 —▼ I I», -t/vtj *«g j·他執行緒仍在谁扞B 2常與順f演算法(機制)完全i- Threads. —▼ I I», -t/vtj *«g j·His thread is still in the 捍B 2 often with the f algorithm (mechanism) completely i

Z 意外 t 止(S i、L:些操作之執行效率报低。 常需要證實執行緒間的正確 5¾¾¾^具有鎖 緒的執行。、他&有鎖之執+Z Accident t (S i, L: The execution efficiency of these operations is low. It is often necessary to verify that the correct inter-thread is executed.) He & lock +

Fraser提到一種基於^ ^ 2004年Keir Fraser的 鎖之混合式方案(參看 ractical l〇c]c r 執行時期效能回饋來根 4reedom)。可接著使用 像备前競& 種技術。使用同步基元 程度動態地選擇使用哪 【發明内容】 1的執仃時期分布及切換。 鑒於先前技術之缺點, 本發明招* 構之實體之方法及系統。 托供—種新的操作資料結 操作資料結構之實體之該方法包人 無鎖能力之操作之—第—鎖 3 · Μ求對至少一具備 體;回應於獲得對該至卜 弱鎖以操作資料結構之實 鎖,執行該至少一具傷” 一備無鎖能力之操作之該弱 實體;請求對一不夏供— .〈钿作以操作資料結構之 卜一備無鎖能力 鎖以操作資料結構之實體.。〈輛作之該第一鎖之一強 能力之操作之該強鎖,執行=應於獲得對該一不具備無鎖 操作資料結構之實體。 ^ 不具備無鎖能力之操作以 本發明亦提供一種操作資 包含:弱鎖模組,其用於技/° #之實體之系統。該系統 作之一第一鎖之一弱鎖,^至上一具備無鎖能力之操 貝从%作資料姓m ^ α 叶、、。構之貫體;執行具備 143290.doc 201112125 無鎖能力之操作夕措& * · 4,、,其用於回應於獲得對該至少— 備無鎖能力之摇祚夕# 22 & ^ 之操作以r“行該至少一具備無鎖能力 I裸作以操作資料έ士播夕魯:ja* - 強鎖模組,其用於請求對 不具備無鎖能力之操作 — 結構之實體;及執行不且借1鎖之一強鎖以操作資料 私佐 執订不具備無鎖能力之操作之模組,苴用 二二於獲得對該-不具備無鎖能力之操作之該強鎖而執 订具備無鎖能力之操作以操作資料結構之實體。 ::前技㈣比,本發明之上述方法及系統可改良操作 資料結構之霄體之效率。 【實施方式】 資料結構為-種資料組織解決方案,例如記錄或資料陣 列’ ^有助於資料分析或對資料執行操作。資料結構之實 體^資料結構之-種實施物件。對於與多執行緒處理有關 之資料結構或資料結構之實體’為確保資料結構在多執行 緒間的-致性或為確保對資料結構之實體之操作之正確 性’常見方法係對資料結構使用鎖。鎖理論本身或本發明 所使用之用鎖來保護資料結構之鎖機制與先前技術中所使 用之鎖理論或鎖機制類似。舉例而言,對於在處理前需要 獲得鎖之f料結構H —㈣僅在純得鎖後可處 理。本發明之-實施例在兩個態樣上與先前技術不同,亦 即’哪種操作需要鎖及需要哪種鎖。此外,根據本發明之 另-實施例’在獲得不同鎖後,可允許一操作執行不同操 作。此與先前技術不同。將參看諸圖描述以下内容。 不同先前技術應用了不同策略(在什麼情況下需要鎖)。 143290.doc 201112125 舉例而言,對基於鎖之 中 序或操作。因此,確心 用鎖來保護所有處理程 確保相關資料結構之安全。然而,可擴 充性不佳。舉例而言,請參擴 個執圖==:基於鎖之方法_,,有四 行,則其他三個執行二:破:行。若al獲得鎖且開始執 持有之鎖。[在al完成執行後’其釋放所 、 接者,其他三個執行緒々式圖猎;r德 命 似,獲得了鎖之執行緒…/式圖獲付鎖。與31類 因此,在、隹 行,且其他執行緒將受阻》 4入關鍵部分與離開關鍵部分之時段期 個執行緒需要望彡主> 複數 之執行緒類4 。執行緒之演算法或機制與順序地執行 I现仃緒類似。稽得 行緒。缺而封鎖其他沒有鎖之執 佳。’,,、而’如圖2a中所示,基於鎖之方法之穩定性不 圖2a說明先前技術之基於鎖之方法中的異常中止装 中,具有鎖之執行緒(例如la)之異常中止將封鎖其二 緒。舉例而言,若執行緒la為死鎖’且其持有仃 放,則其他在等待的執行緒將無 需長時間等待。* 二先:::::之一詳細實施係…實例B舉例 寻、、先堆唛具有以下配置。在先前技術中,該 於多執打緒或將被平行執行之執行緒而言並不安全。且 實例1 i αFraser refers to a hybrid scheme based on the 2004 ^Keir Fraser lock (see ractical l〇c)c r performance-time performance feedback to the root 4reedom). It can then be used like a pre-competition & Dynamically selecting which one to use using the degree of synchronization primitives [Summary] The execution period distribution and switching of 1. In view of the shortcomings of the prior art, the present invention contemplates methods and systems of entities.托 托 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — The real lock of the data structure, the execution of the at least one wounded "the weak entity of the operation without the lock ability; the request for the supply of a non-summer - the operation of the data structure is a lock-free lock to operate The entity of the data structure. The strong lock of the operation of one of the first locks of the vehicle, the execution = should be obtained for the entity that does not have the structure of the lock-free operation. ^ No lock-free capability Operation The present invention also provides an operating resource comprising: a weak lock module, which is used for a system of technology/°#. The system is one of the first locks, and the first lock has a lock-free capability. From the %, the data is surnamed m ^ α leaves, and the structure is constructed; the implementation has 143290.doc 201112125 lock-free operation operation & * · 4, which is used to respond to the acquisition of the at least No lock ability, shake 祚 # # 22 & ^ operation with r "row At least one has the ability to lock-free I naked to operate data gentleman broadcast Xilu: ja* - strong lock module, which is used to request the operation of the structure without the lock-free ability; and the implementation does not borrow 1 lock One of the strong locks is a module that does not have the ability to operate without locks, and the second lock is used to obtain the lock-free ability to obtain the strong lock for the operation without the lock-free operation. The entity that operates to manipulate the data structure. The foregoing method (4) of the present invention can improve the efficiency of the carcass of the operational data structure. [Embodiment] The data structure is a kind of data organization solution, such as a record or data array '^ to facilitate data analysis or perform operations on the data. The physical structure of the data structure ^ the data structure - the implementation of the object. The common method for the structure of data structures or data structures related to multi-thread processing is to ensure the correctness of the data structure in multiple threads or to ensure the correct operation of the entity of the data structure. lock. The lock theory itself or the lock mechanism used by the present invention to protect the data structure with locks is similar to the lock theory or lock mechanism used in the prior art. For example, for a material structure H that needs to acquire a lock before processing, (4) can be processed only after the lock is pure. The embodiment of the invention differs from the prior art in two aspects, namely, which operation requires a lock and which lock is required. Moreover, another embodiment in accordance with the present invention may allow an operation to perform different operations after obtaining different locks. This is different from the prior art. The following will be described with reference to the drawings. Different prior art techniques apply different strategies (when under what circumstances locks are required). 143290.doc 201112125 For example, a lock-based order or operation. Therefore, it is safe to use locks to protect all processes to ensure the security of the relevant data structure. However, the expandability is not good. For example, please refer to the extension chart ==: based on the lock method _, there are four rows, then the other three execution two: broken: line. If al gets the lock and starts holding the lock. [After al completes execution, it releases its receivers, picks up the other three executors, and sings the executors of the locks. So with 31 classes, therefore, the other threads will be blocked. 4 Into the critical part and the time period of leaving the key part. The thread needs to be the main class> complex thread class 4. The algorithm or mechanism of the thread is similar to the sequential execution of I. Judged in the line. Lack and block other good locks. ',, and ' as shown in Figure 2a, the stability of the lock-based method is not shown in Figure 2a. In the abnormal abort in the prior art lock-based method, the abort with the lock thread (e.g., la) Will block its second line. For example, if the thread la is a deadlock' and it holds a hold, the other waiting threads will not have to wait for a long time. * Two first::::: One detailed implementation system... Example B example Finding, first stacking has the following configuration. In the prior art, it is not safe to have multiple threads or threads that will be executed in parallel. And example 1 i α

top:Node sizerint H3290.doc 201112125 j確保對該堆#之操作之正確性,先前技術制以下基 於鎖之方法⑽k:L〇ckType)。舉例而言,對堆疊之實體使 鎖因此纟對堆疊執行操作前請求鎖。獲得了鎖之操 作或執行緒可處理該堆疊,且在完成處理程序後釋放鎖、、 夺&期間’其他需要處理該堆疊之執行緒將受阻。此 等受阻執行緒可試圖獲得鎖,直至其獲得鎖。 實例2Top: Node sizerint H3290.doc 201112125 j ensures the correctness of the operation of the heap #, the prior art system based on the lock method (10) k: L〇ckType). For example, the entity that is stacked causes the lock to request a lock before performing an operation on the stack. The lock operation or thread is processed to process the stack, and the locks are released after the handler is completed, and other threads that need to process the stack will be blocked. These blocked threads can attempt to acquire a lock until it acquires a lock. Example 2

--- 對隹養之母一操作(例如,Push()、P〇P()或cloneO)可調 ^1〇ck-1〇ck()at^^^^ ^l〇c^ 〇 0 此,允許僅一個執行緒處理該堆疊。 根據本發明之-實施例,如以下實例3中所示,可使用 設定讀取鎖及寫人鎖之方法(與先前㈣類似— 含弱鎖rL〇Ck:WeakLock及強鎖之鎖。= ::許複數個操作/執行緒在同一時段期間分別獲得弱 ’允許僅一個操作/執行緒獲得強鎖,不允許在 段期間獲件弱鎖及強鎖H堆疊執行獲得弱鎖或強鎖之 操作此外,平行執行獲得第—鎖之弱鎖之複數個操作, 如圖lb、@2b及圖4a中所示。在獲得強鎖之操作處理該 疊之時段期間,其他用於處理該堆疊之操作將受阻 受阻操作可試圖獲得鎖,例如,週期性地試圖獲得 獲得弱鎖之操作處理該堆#之時段期間,其他請求強鎖之 J43290.doc 201112125 操作將受阻,且其他請求弱鎖 輝邛將獲侍弱鎖。類似 也’此等受阻操作可試圖獲得強销 , 设付涵鎖例如,週期性地試圖 獲得強鎖。 實例3 堆疊實體: wLock: WeakLock —-----sLock.'StrongLnrir -- top-TMnHA ----------------- --- 圖lb說明先前技術之無鎖實施方法的機制。無鎖方法之 目的為克服基於鎖之方法的可擴充性不佳之缺點。如圖 中所不’在無鎖方法中,可平行執行複數個執行緒、 b2、w㈣良執行緒或程式之效率。無射法不僅呈 有良好的可擴充性,而且亦穩定,如圖2艸所示。 圖2b說明先前技術之無鎖實施方法中之異常中止。如圖 2b中所示’若執行緒bl中止’則將仍然執行其他執行緒 bi、b3及b4。然而,難以開發無鎖方法。無鎖方法之執行 緒演算法(或機制)通常與順序演算法(或機制)完全不同。 其通常需要證實執行緒複雜邏輯間的正確性。此外,一此 操作之執行效率很低。 二 根據本發明之—實施例,無鎖方法之平行執行機制與基 於鎖之方法之順序執行機制經整合以用於多執行緒處理。 熟習此項技術者可理解,可在硬體、作業系統或應用程式 中設定鎖之保護範料功能域。在先前技術中,經由設^ 弱鎖(wl〇ck:WriteL〇ck)及強鎖(wL〇ck:WriteL〇叫之保== 疇或功能域,複數個具有弱鎖之操作可平行執行其操作, 143290.doc 201112125 且一具有強鎖之操作將獨佔式地執行其操作。 熟習此項技術者可理解,方法與先前技術類似,可在硬 體、作業系統或應用程式中設定弱鎖及強鎖之保護範嘴或 p域。因此’複數個具有弱鎖之操作可平行執行其操 ’且-具有強鎖之操作將獨佔式地執行其 3中所示,經由設定弱销r τ t 上圖 又疋弱鎖(wLock:WmeL〇ck)及強鎖 (wLock:WriteLock)之保護範疇哎功 胥一飞功月b域,複數個具有弱鎖 之操作可平行執行其择作,__ 、’、 且一具有強鎖之操作將獨佔式 地執行其操作。在該情 滑兄T可4由另夕卜的機制確保多執 處理程序之開發之可擴充性、穩定性或特性。 圖3說明根據本發明之—實施例的操作資料結構之實體 之方法。在步驟S1 00處,方法門 一 地方去開始。在步驟suo處,將 貧料結構之實體之操作分類成 取丹備無鎖能力之操作及不呈 Γ 之操作。如以下段^所描述,複數種方㈣ 用於將對賴結構之實體之㈣分㈣具❹鎖 作及不具備無鎖能力操 ^ 保作热習此項技術者可理解,此 步驟可藉由軟體開發工具戋 θ #式之執行時期環境來執行, 且可獨立於步驟812〇 ' S丨6〇。 此外’可在程式或執行時期 、十-产成舰 十(例如,如上文所描 述:在硬體、作業系統或應用程式中)組態鎖之功能。允 许複數個#作在同一時段期間 + Ά t j刀乃J獲得第一鎖之弱鎖,允 ΓΓ獲得第—鎖之強鎖,不允許在同—時段^ 獲得第-鎖之弱鎖及強鎖;其中,平行執行 ^ 弱鎖的複數個操作。由具備A 鎖之 備無鎖能力之操作執行之操作可 I43290.doc 201112125 包含寫入操作。換言之,根據本發明之一實施例,某一具 =無鎖能力之操作可僅包含讀取操作,且某―具備無㈣ 力之知作可包含寫入操作。此外,以上描述中之片任「第 =實「質上係指鎖。使用「第-」僅出於指代需二舉 錯:吕,帛一鎖」在上下文令指代前文提及之「第一 ί」’以避免使用「鎖」會混淆指代上文提及之「鎖」或 别文提及之「弱鎖」之情況。 在步驟S120處,請求對至少—且 —鎖之弱鎖㈣作資^構之# ^力之操作之第 一蚀 料',·口構之貫體。若其他操作已獲得第 鎖之弱鎖,則允許該至少—且 _ ^ ^ 備無鎖能力之操作獲得第 至少卞已獲传第-鎖之強鎖,則該 孰之操作將受阻,直至該強鎖被釋放。 可項技術者可理解,根據本發明之實施例的鎖之使用 了與其他鎖分配機制結人,你丨上 機制等結合。 °、根據優先權之鎖分配 在步驟SU0處,回應於獲得對至少一具備 作之弱鎖,執行該至少一 ·、、、把 呆 么士槿夕眘Μ , ^ 備無鎖此力之操作以操作資料 、,-。構之實體。根據本發明之— 之摔作ϋ ~ m 例,某一具備無鎖能力 又梯作可僅執仃讀取操作, , 某具備無鎖能力之操作可 m 根據本發明之另-實_,該方法可進- 步包含.回應於具備無鎖能力之^ 體,釋放該弱鎖。 匕探作貢枓結構之實 在步驟S14 0處,培书 不具備無鎖能力之操作之第一 鎖之強鎖以操作資料結構之 ^ 芡第 貫體。右其他操作已獲得第一 143290.doc -13. 201112125 阻 鎖之弱鎖或強鎖’則該一不具備無鎖能力之操作將受 直至該弱鎖或強鎖被釋放。 作=ΓΓ’回應於獲得對該一不具備無鎖能力之操 構之實體:行該一不具備無鎖能力之操作以操作資料結 入貫體。根據本發明之另一實施例,該方法可進一步勺 :::::不具備無鎖能力之操作已操作資料結構之ΐ 釋放忒強鎖。在步驟S160處,方法結束。 熟習此項技術者可理解,步驟5120至8160 =術解決方案,且將藉由上述強鎖及弱鎖在 兄或工具軟體中直接實施。 t月 資料結構之實體指代資料結構之實施例物件 Ο-㈣為常用之資料結構。其他常用之資料;2 循序串msequential㈣、樹、圖表及跳 ,:3 連、,。串列」為一種連結串列結構。連結串列 -節點具有指向下—節點之指標。資料結構「連 之%作通常包含添加元素、刪除」 音;钗哥兀素、遍曆元 :及排序…在本發明之一實施例中,說明一 實體;該串列包含複數個元素。 1 之一實施例’可使用強鎖及弱鎖以保護-類另i足弱鎖及強鎖之保護料或功能域,複數個 具有弱鎖之操作可平行執行其操作,且一 ' ϋ# ^ /J: -V' 1J, Jto. , ^ 具有強鎖之操作 將獨佔式地執行其操作。對於具備無鎖能力之操 職猜0,可使用弱鎖以平行執行其操作。強鎖可供不呈 備無鎖能力之操作用來獨伯式地存取以,且封料他操 143290.doc •14· 201112125 作存取List。 接下來藉由實例描述具備無鎖能力之操作及不具備無鎖 能力之操作。在以下實施例中,操作add為具備無鎖能力 之操作,操作remove為具備無鎖能力之操作,且操作sort • 為不具備無鎖能力之操作。在操作add獲得了 List之弱鎖 - 後,操作remove亦可獲得List之弱鎖。因此,可平行執行 操作add及操作remove。將不允許平行執行操作sort與操作 add或操作 remove 0 class List { private Lock weaklock, stronglock ; public List() {--- Adjust the mother's operation (for example, Push(), P〇P() or cloneO) ^1〇ck-1〇ck()at^^^^ ^l〇c^ 〇0 Allows only one thread to process the stack. According to an embodiment of the present invention, as shown in Example 3 below, a method of setting a read lock and a write lock can be used (similar to the previous (4) - a lock containing a weak lock rL〇Ck: WeakLock and a strong lock. A number of operations/executions are weakly allowed during the same time period to allow only one operation/execution to obtain a strong lock, and it is not allowed to obtain a weak lock and a strong lock during the segment to perform a weak lock or strong lock operation. Parallel execution of a plurality of operations for obtaining a weak lock of the first lock, as shown in FIG. 1b, @2b, and FIG. 4a. During the period in which the operation of obtaining the strong lock is processed, other operations for processing the stack will A blocked obstruction operation may attempt to acquire a lock. For example, during a period of periodically attempting to obtain a weak lock operation, the J43290.doc 201112125 operation will be blocked, and other requests for weak locks will be blocked. A weak lock. Similarly, 'the blocked operation can try to get a strong sales, set the culvert lock, for example, periodically to try to obtain a strong lock. Example 3 Stacking entity: wLock: WeakLock —-----sLock.'StrongLnrir - - top-TMnH A ----------------- --- Figure lb illustrates the mechanism of the prior art lock-free implementation method. The purpose of the lock-free method is to overcome the scalability of the lock-based method. The shortcomings of the good. As shown in the figure, in the lock-free method, the efficiency of multiple threads, b2, w (four) good threads or programs can be executed in parallel. The non-shot method is not only good scalability, but also stable. Figure 2b illustrates the abort in the prior art lock-free implementation method. As shown in Figure 2b, 'If the thread bl is aborted', other threads bi, b3, and b4 will still be executed. It is difficult to develop a lock-free method. The execution-free algorithm (or mechanism) of a lock-free method is usually completely different from the sequential algorithm (or mechanism). It usually needs to verify the correctness of the complex logic of the thread. In addition, the execution of this operation The efficiency is very low. According to the embodiment of the invention, the parallel execution mechanism of the lock-free method and the sequential execution mechanism of the lock-based method are integrated for multi-thread processing. Those skilled in the art understand that it can be hard. Body, operating system or application Set the protection scope of the lock. In the prior art, by setting the weak lock (wl〇ck: WriteL〇ck) and the strong lock (wL〇ck: WriteL 〇 之 = = domain or functional domain, a plurality of Operations with weak locks can perform their operations in parallel, 143290.doc 201112125 and a strong lock operation will perform its operations exclusively. As is familiar to those skilled in the art, the method is similar to the prior art and can be used in hardware and work. The system or application sets the protection threshold or p-domain of the weak lock and the strong lock. Therefore, 'a plurality of operations with weak locks can perform their operations in parallel' and the operation with strong locks will exclusively perform the operations in the 3 It is shown that, by setting the weak pin r τ t, the above figure is weakly locked (wLock: WmeL〇ck) and strong lock (wLock: WriteLock), and the protection field of the strong lock (wLock: WriteLock) is a fly-of-flight b domain. Execution of its choice, __, ', and a strong lock operation will perform its operations exclusively. In this situation, the slick brother T 4 ensures the scalability, stability or characteristics of the development of the multi-processing process by an additional mechanism. Figure 3 illustrates a method of operating an entity of a data structure in accordance with an embodiment of the present invention. At step S1 00, the method gate is started. At step suo, the operation of the entity of the lean structure is classified into the operation of the non-locking capability and the operation of the non-presentation. As described in the following paragraph ^, the plural kinds of parties (4) are used to understand the (4) points (4) of the entities of the Lai structure and the non-locking ability to operate as a heat learner. This step can be borrowed. It is executed by the software development tool 戋θ# execution period environment, and can be independent of step 812〇'S丨6〇. In addition, the function of the lock can be configured during the program or execution period, ten-generation ship (for example, as described above: in hardware, operating systems or applications). Allow multiple # during the same period + Ά tj knife is J to obtain the first lock weak lock, allow to obtain the first lock strong lock, not allowed in the same - period ^ to obtain the first lock weak lock and strong lock ; in which, a plurality of operations of the weak lock are performed in parallel. The operation performed by the lock-free operation with A lock can be I43290.doc 201112125 Contains write operations. In other words, according to an embodiment of the present invention, an operation with a lock-free capability may only include a read operation, and a knowledge of having a (four) force may include a write operation. In addition, the film in the above description is "the first = the real" refers to the lock. The use of "the first" is only for the reference to two mistakes: Lv, 帛一锁" in the context of the reference to the above mentioned " The first 」"' to avoid the use of "locks" would confuse the "lock" mentioned above or the "weak lock" mentioned in the text. At step S120, the first etching of the operation of the at least - and - the weak lock of the lock (four) is requested. If the other operation has obtained the weak lock of the first lock, the operation of the at least - and _ ^ ^ ready lock-free capability is allowed to obtain the strong lock of the at least the first-locked lock, and the operation of the lock will be blocked until the operation The strong lock is released. It will be appreciated by those skilled in the art that locks in accordance with embodiments of the present invention are used in conjunction with other lock assignment mechanisms, such as a mechanism or the like. °, according to the priority of the lock assigned in step SU0, in response to the acquisition of at least one of the weak locks, the implementation of the at least one,,,,,,,,,,,,,,,,,,, To operate the information, -. Constructed entity. According to the invention, in the case of a falling ϋ~m example, a lock-free capability can be performed only for a read operation, and a certain lock-free operation can be performed according to the present invention. The method can be further included. In response to the non-locking capability, the weak lock is released. In the case of step S14 0, the book does not have the strong lock of the first lock of the operation without lock capability to operate the structure of the data structure. The other right operation has obtained the first 143290.doc -13. 201112125 blocking the weak or strong lock', then the operation without the lock-free ability will be affected until the weak lock or strong lock is released. The action = ΓΓ 'in response to the acquisition of an entity that does not have the ability to lock-free: the operation of the non-lock-capable operation to operate the data into the body. According to another embodiment of the present invention, the method can further scoop the ::::: non-locking operation operation data structure to release the bare lock. At step S160, the method ends. Those skilled in the art will appreciate that steps 5120 through 8160 = the solution and will be implemented directly in the brother or tool software by the above described strong and weak locks. The entity of the data structure refers to the embodiment of the data structure. Ο-(4) is a commonly used data structure. Other commonly used data; 2 sequential string msequential (four), tree, chart and jump,: 3, ,,. "Listing" is a concatenated string structure. Linked Columns - Nodes have metrics that point to the next-node. The data structure "% of the work usually includes adding elements, deleting" sounds; 钗 兀, ergonomics: and sorting... In one embodiment of the invention, an entity is illustrated; the string contains a plurality of elements. 1 One embodiment can use a strong lock and a weak lock to protect - a different kind of weak lock and strong lock protection material or functional domain, a plurality of operations with weak lock can perform its operation in parallel, and a 'ϋ# ^ /J: -V' 1J, Jto. , ^ Operations with strong locks will perform their operations exclusively. For jobs with lock-free capabilities, you can use weak locks to perform their operations in parallel. Strong locks are available for non-lock-capable operations for exclusive access, and the device is 143290.doc •14· 201112125 for accessing the List. Next, an example is given to describe the operation with lock-free capability and the operation without lock-free capability. In the following embodiment, the operation add is an operation with no lock capability, the operation remove is a lock-free operation, and the operation sort is an operation without a lock-free capability. After the operation add gets the weak lock of the List - after the operation remove, the weak lock of the List can also be obtained. Therefore, the operation add and the operation remove can be performed in parallel. Will not allow parallel execution of the operation sort and operation add or operation remove 0 class List { private Lock weaklock, stronglock ; public List() {

WeakStrongLock wslock=new WeakStrongLock(); weaklock=wslock. weaklockQ; stronglock=wslock.stronglock(); } 在以上程式中,首先定義List類別,接著用private Lock weaklock, stronglock定義對List類別之鎖。在程式開始期 間,將產生鎖 WeakStrongLock wslock=new WeakStrongLock() ’ 其包含弱鎖 weaklock=wslock.weaklock()及強鎖 stronglock=wslock.stronglock()。 public void add(Object obj){ try{ weaklock. lock(); // do the lock free add 143290.doc -15- 201112125 } finally { weaklock.unlock(); } } 在以上程式中,用於添加物件obj至List之操作add可包 含一或多個不可部分完成的操作。因此,操作add為具備 無鎖能力之操作。在將執行操作add時,首先用 weaklock.lock()請求弱鎖。回應於獲得弱鎖,執行具備無 鎖能力之操作add以添加物件obj至List ;回應於完成操 作,weaklock.unlock()將釋放弱鎖。 若該鎖之強鎖被其他操作或執行緒獲得,則操作add將 受阻。於是,僅在強鎖被釋放後,操作add可獲得所請求 之弱鎖。 public void remove(Object obj){ try{ weaklock.lock(); // do the lock free remove } finally{ weaklock.unlockQ; } } 在以上程式中,用於自List刪除物件obj之操作remove包 含一或多個不可部分完成的操作。因此,操作remove為具 備無鎖能力之操作。在將執行操作remove時,首先用 143290.doc -16- 201112125 weaklock.lockO請求弱鎖。回應於獲得弱鎖,執行具備無 鎖能力之操作remove以添加物件obj至Ust ;且回應於完成 操作,weaklock.unlocko將釋放弱鎖。若該鎖之強鎖被其 他操作或執行緒獲得,則操作remove將受阻。於是,僅在 強鎖被釋放後,操作remove可獲得所請求之弱鎖。然而, 若該鎖之弱鎖被其他操作或執行緒獲得,則操作remove可 獲得該鎖之另一弱鎖。 public void sort() { try{ stronglock.lock(); // do sorting } finally{ stronglock.unlock(); 在以上程式中,用於排序類別List中之物件〇bj之操作 sort不能分成預定義的一或多個不可部分完成的操作。所 需要之不可部分完成的操作數目將根據List中之元素數目 而變化。因此,操作sort為不具備無鎖能力之操作。在將 執行操作sort時,首先用stronglock l〇ck()請求強鎖。回應 於獲得強鎖,執行不具備無鎖能力之操作s〇rt;且回應於 完成操作,stronglock.unlock〇將釋放弱鎖。若該鎖之強鎖 或弱鎖被其他操作或執行緒獲得,則操作s〇rt將受隍。於 143290.doc 201112125 疋僅在強鎖或弱鎖被釋对铋4- JtA- 強鎖。 襌放後刼作sort可獲得所請求之 在圖3之]· α ^WeakStrongLock wslock=new WeakStrongLock(); weaklock=wslock. weaklockQ; stronglock=wslock.stronglock(); } In the above program, first define the List category, then use private lock weaklock, stronglock to define the lock on the List category. At the beginning of the program, a lock is generated WeakStrongLock wslock=new WeakStrongLock() ′ which contains the weak lock weaklock=wslock.weaklock() and the strong lock stronglock=wslock.stronglock(). Public void add(Object obj){ try{ weaklock. lock(); // do the lock free add 143290.doc -15- 201112125 } finally { weaklock.unlock(); } } In the above program, used to add objects The operation add of obj to List may contain one or more operations that are not partially complete. Therefore, the operation add is an operation with no lock capability. When the operation add is to be executed, the weak lock is first requested with weaklock.lock(). In response to obtaining a weak lock, execute the lock-free operation add to add the object obj to List; in response to the completion operation, weaklock.unlock() will release the weak lock. If the strong lock of the lock is obtained by another operation or thread, the operation add will be blocked. Thus, the operation of add can obtain the requested weak lock only after the strong lock is released. Public void remove(Object obj){ try{ weaklock.lock(); // do the lock free remove } finally{ weaklock.unlockQ; } } In the above program, the operation remove used to delete the object obj from the List contains one or Multiple non-partial operations. Therefore, the operation remove is a lock-free operation. When the operation will be removed, first ask for a weak lock with 143290.doc -16- 201112125 weaklock.lockO. In response to obtaining a weak lock, a lock-free operation remove is performed to add objects obj to Ust; and in response to the completion operation, weaklock.unlocko will release the weak lock. If the strong lock of the lock is obtained by another operation or thread, the operation remove will be blocked. Thus, only after the strong lock is released, the remove can be operated to obtain the requested weak lock. However, if the weak lock of the lock is obtained by another operation or thread, then operating remove can obtain another weak lock of the lock. Public void sort() { try{ stronglock.lock(); // do sorting } finally{ stronglock.unlock(); In the above program, the operation sort for sorting the object 〇bj in the category List cannot be divided into predefined ones. One or more operations that are not partially complete. The number of operations that are not necessarily partially completed will vary depending on the number of elements in the List. Therefore, the operation sort is an operation that does not have a lock-free capability. When the operation sort is to be executed, the strong lock is first requested with stronglock l〇ck(). In response to obtaining a strong lock, the operation does not have the lock-free operation s〇rt; and in response to the completion of the operation, stronglock.unlock〇 will release the weak lock. If the strong or weak lock of the lock is obtained by other operations or threads, the operation s〇rt will be accepted. On 143290.doc 201112125 疋 Only in strong or weak locks are released against 铋 4- JtA- strong lock. After the release, the sort can be obtained by the sort. Figure 3] α ^

對資料結構之實:之T 具備益鎖2 類成具備無鎖能力之操作及不 、.…,貞鲍力之操作之步驟S11 〇。 根據本發明之一實 之不可部分nit 無鎖演算法所需要 為具備無鎖能力之摔作.* ^ 則將5亥—抽作分類 不可部分…二 無鎖演算法所需要之 刀凡成的操作之數gx β 為不具備益… 疋吊數,則將該-操作分類 二備無鎖…操作。在本發明之 —才呆作之盔铛.,當管、、t 一 Α 只u〜r 右 為常數,且該常數與資料刀4的插作之數目 將該一操作八魅主目、’° 4之實體之元素數目無關,則 鎖演算法所需| 锢作,且右—刼作之無 所*要之不可部分完成的 且該數目與資料結構之實體之元辛^目^疋奉數, 作分類為不且備’、有關,則將該一操 ^ 一梅無鎖能力之操作。 對資料結構之實體之具備無鎖能 定義數目個不可部分 #作可分成包含預 結構之實體之具備盔 、較佳地,對資料 完成的操作。其中 成1至5個不可部分 ί資料結構之實體 之操作不可分成包含預定義數目=不具備無鎖能力 操作。 不可部分完成的操作之 舉例而言,力田# + 在用於處理List之上 僅需要一彻τ π 成貫例中,添加~亓去 僅^要個不可部分完成的冊π素 且唰除一 7C素僅需要— 143290.doc 201112125 或兩個不可部分完成的操作。因此,可將此等兩種操作分 類為具備無鎖能力之操作。而對List之操作s。讀資料社構 之元素數目有關’因此屬於不具備無鎖能力之操作。可。將 堆疊中之push或P〇P分類為具傷無鎖能力之操作,·而添加 用於圖之圖框將被分類為不具備無鎖能力之操作。 在本發明之先前技術中,基於鎖之方法使用鎖以用於保 護。此資料結構為安全的,但具有低擴展性。若對資料結 構之-些操作可以無鎖且對於多執行緒而言安全,例如, 對ust之add()及謂。ve()。而其他操作對於多執行緒而古 並不安全,例如,對^之叫)。資料結構之使用受限。 在使用對於執行緒而言並不安全之方法時,程式員必須很 小心’專待安全時間,且在此安全時間中調用對於執行绪 而,並不安全之方法。此模式需要程式員的更多注意力, 因此開發效率及執行效率將受影響。 根據本發明之p實施例,若待由—操作修改之記 單元之數目為常數,則將該一操作分類為具備無鎖能力\ 細作;若待由-操作修改之記憶體單元之數目 續-操作分類為不具備無鎖能力之操作。根據本發明 之另實施例’待由具備無鎖能力之操作修改之記憶體 元之數目與資料結構之實體之元素數目無關;待由;具備 無鎖能力之操作修改之記憶體單元之數目與資料結構 體之-素數目有關。較佳地’具備無鎖能力之 記憶體單元之小於加—々雒〜 什取 可存取記憶體輸鎖能力之操作 干疋之大於雙子或兩個非後續字。 143290.doc .19- 201112125 對於用於處理List之上述實例,添加—元素僅需要修正 原始Llst中之—指標;且刪除一元素僅需要修正原始List 2之-或兩個指標。因此,可將此等兩種操作分類為且備 之操作。而對於排序一之元素’將修正之指 二力之^⑻中之元素數目成正比,因此屬於不具備無鎖 月&力之操作。 Λ 根據本發明之另一實施例,其中在嚴 共〒在早一執仃緒處理中, 對於對資料結構之同一 之效能效率與在心鎖作,…鎖… 義值,則將— 模式中之效能效率的差小於預定 广母-操作分類為具備無鎖能力之操作;否則, :母操作分類為不呈備盤鎖能力之ρ从 、 有…鎖此力之刼作。較佳地,苴中 在早一執行緒處理中,對於對資 ,、 操作,若在w… 構之同一實體之每- …果式中之效能效率與在基於鎖之模式中< 效能效率的差切丨.5倍,料每 料中之 能力之操作.否目, 千母#作分類為具備無鎖 操作。 ,將每-操作分類為不具備無鎖能力之 對貝料結構之每—操作可 鎖實施,且另―/ 肽本果只施,一個是無 另個是基於鎖之實施。在用;^ τ. 述實例中,沃j· 用於處理List之上 4、加—元素之操作及刪除一元 與基於鎖之實施類似。因此 素之知作之效率 無鎖能力之摔作 ^兩個操作分類為具備 爻钿作。而用於排序Ust2 很低,因此將、之…、鎖實施效率 此知作分類為不具備盔鎖 外,對於添加用於鎖月匕力之操作。此 低。 於圖之圖框而言’無鎖實施例之效率很 143290.doc 201112125 根據本發明之另一實施例,在圖3中所示之 口 允許複數個操作/執行緒分別擁:法中’可 ,. 頌之弱鎖,分畔楛For the data structure: T has the benefit lock 2 class into the operation without lock ability and does not, ...., step S11 贞 operation of Bao Baoli. According to one of the aspects of the present invention, the non-locking algorithm is required to be a lock-free ability. * ^ The 5 hai-classification is not part of the... The second lock-free algorithm requires a knife. The number of operations gx β is not beneficial... When the number of cranes is ,, the operation is classified into two devices without lock... operation. In the present invention, the helmet is only used, when the tube, t, and only u~r are constant, and the number of the constant and the data knife 4 is inserted into the operation of the eight charms, ' If the number of elements of the entity of ° 4 is irrelevant, then the lock algorithm needs to be used, and the right--there is nothing to be done, and the number and the entity of the data structure are The number, classified as not and prepared ', related, then the operation of a single operation without lock ability. The possession of an entity with no data to the data structure defines a number of non-partial parts that can be divided into helmets containing pre-structured entities, preferably, operations that complete the data. The operations of entities that are 1 to 5 incapable of the data structure cannot be divided into a predefined number = no lock-free capability. For example, the operation that cannot be partially completed, Litian # + only needs a τ π in the case of processing List, adding ~ 仅 only ^ can not be partially completed π 素 and remove A 7C element only needs to be - 143290.doc 201112125 or two operations that cannot be partially completed. Therefore, these two operations can be classified as operations with no lock capability. And the operation of the List s. The number of elements in the reading data structure is related to 'therefore, it is an operation that does not have the ability to lock. can. The push or P〇P in the stack is classified as an operation with no lock and lock, and the frame for adding the map will be classified as an operation without lockability. In the prior art of the present invention, a lock-based method uses a lock for protection. This data structure is secure but has low scalability. If the data structure - some operations can be unlocked and safe for multiple threads, for example, add () and ust. Ve(). Other operations are not safe for multiple threads, for example, for ^). The use of data structures is limited. When using methods that are not safe for the thread, the programmer must be careful to treat the safe time, and it is not safe to call the thread during this safe time. This mode requires more attention from the programmer, so development efficiency and execution efficiency will be affected. According to the p embodiment of the present invention, if the number of units to be modified by the operation is constant, the operation is classified as having a lock-free capability and fine-grained; if the number of memory units to be modified by the operation is continued - Operations are classified as operations that do not have lock-free capabilities. According to another embodiment of the present invention, the number of memory cells to be modified by the operation without lock capability is independent of the number of elements of the entity of the data structure; the number of memory cells having operational modifications without lock capability and The number of primes in the data structure is related. Preferably, the memory unit having the lock-free capability is smaller than the add-to-snap operation. The operation of the memory lock-capable capability is greater than the twin or two non-subsequent words. 143290.doc .19- 201112125 For the above example for processing List, the add-element only needs to correct the metric in the original Llst; and deleting an element only needs to correct the original List 2 - or both metrics. Therefore, these two operations can be classified into and prepared for operation. For the element of sorting one, the number of elements in the correction (2) is proportional to the number of elements, so it is an operation that does not have a lock-free month & force. Λ According to another embodiment of the present invention, in the processing of the first one, in the processing of the same data, for the same performance efficiency and in the lock of the data structure, ... lock ... meaning, then - in the mode The difference in efficiency is less than the predetermined wide-mother-operation classification as an operation with no lock capability; otherwise, the parent operation is classified as ρ slave, which has no lock-up capability. Preferably, in the early thread processing, in the case of the right, the operation, if the performance efficiency in the same entity of the w... is in the lock-based mode < performance efficiency The difference is 55 times, the operation of the material in each material. No, the thousand mother # is classified as having a lock-free operation. Each operation is classified as having no lock-free capability. Each operation of the material structure can be locked, and the other is only applied to the peptide, and the other is based on the implementation of the lock. In the example of ^^τ., Wo j· is used to process the List 4. The operation of adding the element and deleting the element are similar to the implementation based on the lock. Therefore, the efficiency of the knowledge is not the ability to lock. ^Two operations are classified as having a work. The sorting used for Ust2 is very low, so it will be..., lock implementation efficiency. This is classified as not having a helmet lock, and is added for the operation of locking the moon. This is low. The efficiency of the lock-free embodiment is very high. 143290.doc 201112125 According to another embodiment of the present invention, the port shown in FIG. 3 allows a plurality of operations/executors to be respectively: , 颂的弱锁,分楛楛

一個操作獲得第一鎖之強鎖,不允 — D ^ 矸在冋—時段期間獲得 第一鎖之弱鎖及強鎖;其中,平行執行獲 的複數個操作。其中,圖3之方法 貞之弱鎖 J ^ 步包含:回應於 具備無鎖能力之操作已操作資料 〜、 0 ^ 竹、·,°構之貫體,釋放弱鎖; 回應於不具備無鎖能力之操作已操作詩 釋放強鎖。 苒貫體 圖^及圖4b㈣根據本料之—實施敎料效能。圖 4a中,可平打執行兩個或兩個以上具備無鎖能力之操作。 在該情況下’-或多個不具備無鎖能力之操作受阻。舉例 而言,平行執行圖4a中所示之操作add〇及rem〇ve()等而 不具備無鎖能力之操作如()等受阻。圖朴中,平行執行 一或多個不具備無鎖能力之操作,而其他不具備無鎖能力 之細作及具備無鎖能力之操作受阻。循序執行圖朴中之摔 作心〇等,而其他不具備無鎖能力之操作及具備無鎖能 力之操作add()及remove()等受阻。 在先前技術中,在無鎖方法中有許多益處U,難以 開發該等方法。因此’無鎖機制通常用於簡單操作。例 如,操作資料結構之實體(連結串列⑽員別)之以下操 作。 class List{ public void add(Object obj); public void remove(Object obj); 143290.doc -21 . 201112125 public void sortQ; 不難對add()及remove()方法實施無鎖機制。add()用於添 加元素’ public void add(Object obj)表示添加用於Ust類別 之物件元素,且用於此List之add可由其他執行緒之操作調 用。removeO用於刪除元素,pubHc v〇id rem〇ve(〇bje^ 〇bj)表示自List類別刪除物件元素,且用於此心之__ 可由其他執行緒之操作調用。s〇rt()用於排序元素,puWc void sort〇表示排序List之物件元素,且用於此List《s⑽ 可由其他執行緒之操作調用。然而,難以對⑽叫)方法實 施無鎖機制。原因是,資料結構之實體List通常包含複數 個元素。因此’在排序Li狀素期間,若其他執行緒添加 物件元素至List或自List移除物件元素,則將產生矛盾。 於疋,自然方法為用鎖來保護s〇rt()。因此將程式碼 重寫如下。 class List{ public void add(Object obj); public void remove(Object obj); public synchronized void sortQ; } public synchronized void s〇n()表示執行扣以需要 i〇ck unlock對。在該情況下,用同步方法修正s〇rt()。在將執行 該操作時,首先試圖獲得鎖;在獲得鎖後執行操作; 在執行sort操作後釋放鎖。因此,允許僅一個執行緒進入 143290.doc 201112125 該方法以在任何時間調用sort。然而,上述方法不正確。 若在一執行緒進入sort方法時,另一執行緒正試圖用 remove方法刪除節點,則sort方法可能失效。 此係因為add〇方法之執行有時可能提供sort()方法。此 外,儘管sort()方法經鎖定;但add係無鎖的。此允許可在 任何時間執行add。可能有矛盾。因此,安全版本將使用 以下方法,其中使用同步(或經鎖定的)方法執行所有操 作。 class List{ public synchronized void add(Object obj); public synchronized void remove(Object obj); public synchronized void sort(); } 以上 public synchronized void add(Obj ect obj)表示執行 add 需要 lock unlock對。public synchronized void remove (Object obj)表示執行remove 需要 lock unlock對。現在, List為安全的。然而,三種方法均用鎖加以保護。於是, 如圖1及圖2中所示,允許僅一個執行緒進入上述三種方法 中之一者。在圖1中,簡單操作獲得互斥鎖,且封鎖其他 操作獲得互斥鎖。在圖2中,複雜操作獲得互斥鎖,且封 鎖其他操作獲得互斥鎖。此模式妨礙平行執行軟體執行。 圖5a及5b說明與本發明之一實施例相比的先前技術之操 作效能。先前技術應用基於鎖之操作。在圖5a中,因為 add()需要執行寫入操作而非僅執行讀取操作,所以在執行 143290.doc -23- 201112125 add()的時段m 需要=用鎖封鎖其他操作。在圖对,因為 行如0的# 操作而非僅執行讀取操作,所以在執 、時段期間用鎖封鎖其他操作。 對應於上述操作資 操作資料結構之實體之 方法,本發明亦提供 用於-七似實體統。該系統包含:弱鎖模組,其 用於6月求對至少― 操作資料_ 、備‘,,、鎖能力之操作之第一鎖之弱鎖以 其用 ,執丁八備無鎖能力之操作之模組, 具用於回應於獲得對 — 而執行該至少—……備無鎖能力之操作之弱鎖 體.強^…、鎖能力之操作以操作資料結構之實 篮’強鎖模組,其用於咬+ Λ 第一L 用於辦求對-不具備無鎖能力之操作之 第鎖之強鎖以操作資料紝構之. 能力之操作之心及執行不具備無鎖 能力之H 、、且’其用於回應於獲得對該一不具備無鎖 月b力之知作之強鎖而 貝 ^ ^ ^ 亥不具備無鎖能力之操作以摔 作貧枓結構之實體β Ρ 乂铞 其中,弱鎖模組及強鎖模組 .^ ^ 操作在同-時人丄組態.允許複數個 時奴期間分別獲得第一鎖之弱 操作獲得第一鎖之魅“ν 鎖允#僅-個 鎖之弱鎖及強鎖—時段期間獲得第-個操作 其中平行執行獲得第-鎖之弱鎖的複數 二系統:進—步包含封鎖模組’該封鎖模組進-步經 =以.回應於執行不具備無鎖能力之操作,封鎖請求第 之強鎖之-知作;且回應於執 作,封鎖喑犮坌^ 个,、侑無鎖能力之操 鎖°月求第—鎖之弱鎖的一操作或請求第H 的其他操作。 鎖〜強鎖 I43290.doc •24- 201112125 此外,弱鎖模組進一步經組態 ^ ^a ^ u應於具備無鎖能力 之^ 料結構之實體,釋放弱鎖’·且強鎖模組進 結構之實體,釋放強鎖。 力之操作已操作資料 作此外’由具備無鎖能力之操作執行之操作可包含寫入操 上述系統可進一步包含操作分 結構之實體之操作分類㈣二用於將對資料 鎖能力之操作1作分_且:鎖:力之操作及不具備無 法… •作刀_組進-步經組態以藉由上述方 二:::者或其組合來將對資料結構之實體之操作分類 成具備無鎖能力之操作及不具備無鎖能力之操作。 與先前技術相比,本發明整合了基於鎖之方法❹鎖方 擴展ιΓ文所料,無鎖㈣碼可平行執行,具有良好的 擴展性,但難以程式化。 民好的 佳η 基於鎖之方法擴展性不 但易於理解及程式化。當在執行绪中平行勤…“ 無鎖操作時,具備無鎖能力之操作可確=丁 =複數個 特性及變數一致性一 確保不可部分完成的 田而要執行不具備無鎖能力之摔作及 其他不具備無鎖刀之钿作及 時,使用強鎖以確伴、…、八備無鎖能力之操作 把攄太Γ 部分完成的特性及變數一致性。 根據本發明之一 y 法時,m 當僅存在無複雜操作之簡單方 法時,可平行執行具備 】早方 作資料結構之實體。、勃 ㈣。可執行操作以操 操作資料結構之實體複雜方法時,可使用強鎖以 能力之操作。 4要時將不會封鎖不具備無鎖 143290.doc •25· 201112125 本發明亦提供儲存媒體或信號_,其包含用於執行根 據本發明之方法之指令。 雖然已特定地參考較佳實施例來說明並描述本發明,但 熟習此項技術者將理解,在不脫離本發明之精神及範鳴的 情況下可在形式及細節上對其作出各種改變。 【圖式簡單說明】 圖la說明先前技術中之基於鎖之方法的機制 圖lb說明先前技術中之無鎖方法之機制; 圖2a說明先前技術中之基於鎖之方法中的異常中止; 圖2b說明先前技術中之無鎖方法中之異常中止; 圖3說明根據本發明之— 之方法; 實施例的操作資料結構之實體 明之一實施例之操作效能;及 之一實施例相比的先前技術之操 圖4a及4b說明根據本發 圖5a及5b說明與本發明 作效能。 【主要元件符號說明】 a 1 執行緒 a2 執行緒 a3 執行緒 a4 執行緒 bl 執行緒 b2 執行緒 b3 執行緒 b4 執行緒 143290.doc •26·An operation obtains a strong lock of the first lock, and does not allow - D ^ 获得 to obtain a weak lock and a strong lock of the first lock during the 冋-time period; wherein, the plurality of operations obtained are performed in parallel. Among them, the weak lock J ^ step of the method of FIG. 3 includes: in response to the operation of the data having the lock-free capability, the operation of the data, ~ 0 ^ bamboo, ·, °, the release of the weak lock; in response to the lack of lock-free ability The operation has been manipulated to release a strong lock. Figure 4 and Figure 4b (4) According to the material - the effect of the implementation of the material. In Figure 4a, two or more operations with lock-free capability can be performed in a flat stroke. In this case, '- or multiple operations that do not have lock-free capability are blocked. For example, the operations such as add〇 and rem〇ve() shown in Fig. 4a in parallel and without the lock-free operation such as () are blocked. In the map, one or more operations that do not have the ability to lock are not performed in parallel, while other operations that do not have the ability to lock without lock and the operation without lock are blocked. Sequential execution of the slap in the map, etc., while other operations that do not have the ability to lock and the lock-capable operations add () and remove () are blocked. In the prior art, there are many benefits in the lock-free approach, and it is difficult to develop such methods. Therefore, the lock-free mechanism is usually used for simple operations. For example, the following operations operate on the entity of the data structure (linking the serial (10) members). Class List{ public void add(Object obj); public void remove(Object obj); 143290.doc -21 . 201112125 public void sortQ; It is not difficult to implement a lock-free mechanism on the add() and remove() methods. Add() is used to add an element' public void add(Object obj) to add an object element for the Ust class, and the add for this List can be called by other thread operations. removeO is used to delete elements, pubHc v〇id rem〇ve(〇bje^ 〇bj) means to delete object elements from the List category, and __ for this heart can be called by other thread operations. S〇rt() is used to sort elements, puWc void sort〇 represents the object elements of the sorted list, and is used for this List "s(10) can be called by other thread operations. However, it is difficult to implement a lock-free mechanism for the (10) call method. The reason is that the entity list of the data structure usually contains a plurality of elements. Therefore, during the sorting of Li-like elements, if other threads add object elements to the List or remove the object elements from the List, a contradiction will arise. Yu Yu, the natural method is to use locks to protect s〇rt(). Therefore, the code is rewritten as follows. Class List{ public void add(Object obj); public void remove(Object obj); public synchronized void sortQ; } public synchronized void s〇n() means that the execution of the buckle requires the i〇ck unlock pair. In this case, s〇rt() is corrected by the synchronization method. When the operation is to be performed, the lock is first attempted; the operation is performed after the lock is acquired; and the lock is released after the sort operation is performed. Therefore, only one thread is allowed to enter 143290.doc 201112125 This method calls sort at any time. However, the above method is not correct. If another thread is trying to delete a node with the remove method when one thread enters the sort method, the sort method may fail. This is because the add() method may sometimes provide the sort() method. In addition, although the sort() method is locked, add is unlock-free. This allows add to be executed at any time. There may be contradictions. Therefore, the secure version will use the following method, where all operations are performed using the synchronous (or locked) method. Class List{ public synchronized void add(Object obj); public synchronized void remove(Object obj); public synchronized void sort(); } The above public synchronized void add(Obj ect obj) means that the lock is required to execute add. Public synchronized void remove (Object obj) means that the lock unlock pair is required to execute remove. List is now safe. However, all three methods are protected with a lock. Thus, as shown in Figures 1 and 2, only one thread is allowed to enter one of the above three methods. In Figure 1, a simple operation acquires a mutex and blocks other operations to obtain a mutex. In Figure 2, a complex operation acquires a mutex and blocks other operations to obtain a mutex. This mode prevents parallel execution of software execution. Figures 5a and 5b illustrate prior art operational performance as compared to an embodiment of the present invention. Prior art applications were based on lock operations. In Figure 5a, because add() needs to perform a write operation instead of just a read operation, the time period m at which 143290.doc -23- 201112125 add() is executed requires = lock other operations with a lock. In the figure pair, because the line operates as #0 instead of just the read operation, other operations are blocked with locks during the execution and time periods. The present invention also provides a method for the entity corresponding to the entity of the operational data structure described above. The system comprises: a weak lock module, which is used for seeking the weak lock of the first lock of at least the operation data _, the backup ', and the lock capability in June, and the lock is capable of being locked. The operation module has a weak lock body for responding to obtaining the right--- performing the at least-lock-free operation. Strong ^..., the operation of the lock capability to operate the real structure of the data structure 'strong lock mode Group, which is used for bite + Λ The first L is used to solve the problem - the lock of the first lock that does not have the ability to lock-free operation to operate the data structure. The operation of the ability and execution does not have the ability to lock. H, and 'in response to obtaining a strong lock on the knowledge of a force that does not have a lock-free month b. ^ ^ ^ Hai does not have the ability to operate without locks to fall into a poor structure of the entity β Ρ乂铞 Among them, the weak lock module and the strong lock module. ^ ^ Operation in the same time-time configuration. Allow multiple slaves to obtain the first lock weak operation to obtain the first lock charm "v lock #only - a weak lock and a strong lock of the lock - the first operation is obtained during the period, in which the plural of the weak lock of the first lock is executed in parallel System: the step-by-step includes the blocking module 'The blocking module enters the step-by-step=in response to the execution of the operation without the lock-free capability, and the block-off request is the strongest lock; and in response to the execution, the blockade喑犮坌 ^ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , The group is further configured ^ ^ a ^ u should be in the entity with the structure of the lock-free ability, release the weak lock '· and strongly lock the module into the structure of the entity, release the strong lock. The operation of the force has been operated 'Operation performed by a lock-free operation may include a write operation. The system may further include an operation classification of the entity that operates the substructure. (4) Two is used to divide the operation 1 of the data lock capability _ and: lock: force Operation and not available... • Knife_Group In-Step Configuration to classify the operation of the entity of the data structure into a lock-free operation and not with the above-mentioned two::: or a combination thereof Operation without lock capability. Compared with the prior art, this issue The lock-based method is integrated to expand the ιΓ文, and the lock-free (four) code can be executed in parallel, which has good scalability, but is difficult to program. The good η based on the lock method is not only easy to understand and program When it is in the thread, it is parallel... "Without lock operation, the operation with lock-free ability can be confirmed = D = multiple characteristics and variable consistency - to ensure that the field can not be partially completed and to perform without lock-free ability Falling and other non-locking knives are used in a timely manner, using strong locks to ensure companionship, ..., and eight-capacity lock-free operation to complete the characteristics and variable consistency of the 摅太Γ. According to the y method of the present invention, when there is only a simple method without complicated operation, an entity having an early data structure can be executed in parallel. Bo (4). A strong lock can be used to perform operations when performing operations to manipulate complex methods of data structures. 4 If necessary, it will not be blocked without lock. 143290.doc • 25· 201112125 The present invention also provides a storage medium or signal_, which contains instructions for performing the method according to the present invention. While the invention has been described and illustrated with reference to the preferred embodiments of the embodiments of the present invention, it will be understood that various changes may be made in the form and details without departing from the spirit and scope of the invention. BRIEF DESCRIPTION OF THE DRAWINGS Figure la illustrates the mechanism of the lock-based method in the prior art. Figure lb illustrates the mechanism of the lock-free method in the prior art; Figure 2a illustrates the abort in the lock-based method of the prior art; Figure 2b Illustrating an abort in the lock-free method of the prior art; FIG. 3 illustrates a method according to the present invention; an operational performance of an embodiment of an operational data structure of an embodiment; and a prior art compared to an embodiment Figures 4a and 4b illustrate the performance of the present invention as illustrated in Figures 5a and 5b of the present invention. [Main component symbol description] a 1 Thread a2 Thread a3 Thread a4 Thread bl Thread b2 Thread b3 Thread b4 Thread 143290.doc •26·

Claims (1)

201112125 七、申請專利範圍: 1 · 一種操作一資料結構之一實體之方法,包含. 弱 請求對至少一具備無鎖能力之操作之一第一鎖之 鎖以操作該資料結構之該實體; 之操作之該弱 操作該資料結 回應於獲得對該至少一具備無鎖能力 鎖,執行該至少一具備無鎖能力之操作以 構之該實體; 鎖之一強鎖 請求對一不具備無鎖能力之操作之該 以操作該資料結構之該實體;及 ,執 該實 回應於獲得對該不具備無鎖能力之操作之該強鎖 行該不具帛無鎖能力之操作以操作該資料結構之 體0 〜奴调锞作在同— 間分別獲得該第-鎖之弱鎖,允許僅_個操作獲得— 一鎖之該強鎖,不允許在同—時段期間獲得該第1 一弱鎖及該強鎖;其中,平行執行獲得該第 的複數個操作。 頌< I 3. 4. 如請求項2之方法,進一步包含: 回應於執行該不具備無鎖能力之操作 一鎖之該_之-操作;相應 力之操作,封鎖請求該第一鎖之一=不;備無《 該第—鎖之該強鎖的其他操作。相作或讀 St方法’進一步包含:回應於該具備-鎖 作已操作該請結構之該實體,釋放該㈣ 143290.doc 201112125 :應於該不具備無鎖能力之操作已操作該資料結構之該 實體,釋放該強鎖。 ^ :求項1之方法’其中由該具備無鎖能力之操作執行 之操作可包含寫入操作。 6·=求項1之方法,進—步包含:將對該資料結構之令 貫體之操作分類成具備無鎖能" 力之操作。 料及不具備無鎖能 7_如凊求項li6中之任_項之方法其中,若 =算法所需要之不可部分完成的操作之數目1 數作則將該-操作分類為—具備無鎖能力之操作;若: 刼作之-無鎖演算法所需要 數目不是 I刀疋成的刼作之該 力之操作。 刀顏為不具備無鎖能 8 ·如請求項7 $古. 需要之不可Λ ^ ' ,右一操作之一無鎖演算法所 °。卩分完成的操作的該數目為一常數,且1 ^ 數與該資料姓椹— 數且5亥吊 针w構之该貫體之元素數 作分類為…關則將该一操 具備無鎖能力之操作;且 操作之_無鎖演算法所需要之不可八— 作的該數目不县 口 P刀7L成的操 體之元素數目右關日,、X資科結構之該實 有關,則將S亥一操作分類為— 能力之操作。 為不具備無鎖 9.如請求項1 ^. 法’其中對該資料結構之嗲會黔夕兮 備無鎖能力之操作可分成包含預定義數2貫體之该具 成的操作之操作。 疋義數目個不可部分完 143290.doc 201112125 10.如請求項7之方法,其中對該資料結構之 備無鎖能力之操作可分成丨 ° ' η 珉1至5個不可部分完成的操作。 π·如請求項1至6中之任—項 铞邗 修改之記憶體單元之數 刼作 双曰马*數,則將該一操作分麵 為具備無鎖能力之操作 ” .^ 右待由—操作修改之記憶體單 疋之5亥數目不是一常數,則將兮 心 鎖能力之操作。 ’、備…、 12. 如請求項丨i之方法,盆中 ^ ’、寺由该具備無鎖能力之操作修 改之記憶體單元之該數目愈 、夕 〇忑貧枓結構之該實體之元去 數目無關;待由該不具備盔韹 、 … 佾無鎖此力之操作修改之記憶體 早兀之該數目與該資料結構 〜 該實體之疋素數目有關。 13. 如研求項丨丨之方法,其中 八備無鎖能力之操作可存敢 記憶體單元之小於一個字€ j仔取 椏祚子次雙予,該*具備無鎖能力之 操作可存取記憶體單元之大於雙字或兩個非後續字。 14. 如凊未項1至6中之任-項之方法,其中在一單一執行緒 處理中,對於對該資料結構之同一實體之每—操作,“ =無鎖模式中之效能效率與在_基於鎖之模式中之: 月b效率的差小於一箱定益姑 , $ π預疋義值,則將該操作分類為益 鎖能力之操作;否則,將該操作、“'、 之操作。 “類為不具備無鎖能力 κ如請求項u之方法’其中在一單—執行緒處理中,對於 對該資料結構之同-實體之每—操作4在—益鎖模式 中之該效能效率與在一基於鎖之模式中之該效能效率的 差小於μ倍,則將該操作分類為具備無鎖能力之摔作. 143290.doc 201112125 16. 17 18. 19. 否則:將該操作分類為不具備無鎖能力之操作。 種操作資料結構之—實體之系統,包含: 弱鎖模組,其用於請求對至少一具備無鎖能力之操作 之—第―鎖之―弱鎖以操作該資料結構之該實體; 執仃具備無鎖能力之操作之模組,其用於喊於獲得 二°亥至夕一具備無鎖能力之操作之該弱鎖而執行該至少 一具備無鎖能力之操作以操作該f料結構之該實體; 強鎖模組’其用於請求對—不具備無鎖能力之操作之 Λ第鎖之一強鎖以操作該資料結構之該實體;及 作執二不具備無鎖能力之操作之模組,其用於回應於獲 IIί不具備無鎖能力之操作之該強鎖而執行該不具備 …^力操作該資料結構之該實體。 、、項1 6之系統’其令該弱鎖模組及該強鎖模組進一 第=、、且態·允許複數個操作在同—時段期間分別獲得該 —鎖之弱鎖,允許僅—個操作獲得該第—鎖之該強 強鎖不在同:時段期間獲得該第一鎖之-弱鎖及該 作。。、中’平行執行獲得該第—鎖之弱鎖的複數個操 ::亡項!7之系統’進一步包含一封鎖模組,該封鎖模 作7步經組態以:回應於執行該不具備無鎖能力之操 二:鎖請求該第-鎖之該強鎖之-操作;且回應於: 備無鎖能力之操作,封鎖請求該第—鎖之 如於々作或4求該第-鎖之該㈣的其他操作。 員16之系統,其中該弱鎖模組進一步經組態以: M3290.doc 201112125 回應於該具備無鎖能力之操作已操作該資料結構之該實 體,釋放該弱鎖;且該強鎖模組進一步經組態··回應於 該不具備無鎖能力之操作已操作該t料結構之該實體, 釋放該強鎖。 20.如請求項16之方法,其中 之操作可包含寫入操作。 由該具備無鎖能力之操作執行 21.如請求項16之系統,進一步包含— 於將對該資料結構之該實體之操作 之操作及不具備無鎖能力之操作。 操作分類模組,其用 分類為具備無鎖能力 A如:求項21之系統’其中該操作分類模組進 以藉由如請求項7至丨5之方法中之任— ^ 對該資料結構之該實體之操作分類為具備5無其、、且合來將 作及不具備無鎖能力之操作。 鎖能力之操 I43290.doc201112125 VII. Patent application scope: 1 . A method for operating an entity of a data structure, comprising: a weak request to at least one lock of a first lock having a lock-free operation to operate the entity of the data structure; The weak operation of the data node is in response to obtaining the at least one lock-free capability lock, performing the at least one lock-free operation to construct the entity; the lock one strong lock request is not capable of lock-free capability The operation of the entity to operate the data structure; and, in response to obtaining the strong lock operation for the non-lock-free operation, the non-lock-free operation to operate the data structure 0 ~ 奴 锞 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 获得 奴Strong lock; wherein, the plurality of operations for obtaining the first are performed in parallel.颂< I 3. 4. The method of claim 2, further comprising: responding to the operation of the lock that does not have the lock-free capability; the operation of the corresponding force, the request for the first lock One = no; there is no other operation of the strong lock of the first lock. The method of reading or reading the St method further comprises: in response to the entity having the lock-operated structure, releasing the (four) 143290.doc 201112125: the data structure should be operated in the operation without the lock-free capability The entity releases the strong lock. ^ : The method of claim 1 wherein the operation performed by the lock-free operation may include a write operation. 6·=The method of claim 1, the step-by-step includes: classifying the operation of the data structure into a non-locking energy operation. And the method of not having the lock-free energy 7_, such as the request item li6, wherein if the number of operations that are not partially completed by the algorithm is one, the operation is classified as having no lock capability. The operation; if: The number of operations required for the lock-free algorithm is not the operation of the force of the I-cut. Knife face does not have no lock energy 8 · If the request item 7 $ ancient. Need not to Λ ^ ', one of the right one operation without lock algorithm °. The number of operations performed by the division is a constant, and the number of elements of the division is 1 ^ and the number of elements of the data and the number of elements of the body is classified as ... The operation of the ability; and the operation of the _ lock-free algorithm is not required to do the same - the number of the number of the elements of the state of the P-knife 7L into the right-hand day, the X-based structure of the actual, then Classify the S-operation as the operation of the capability. In order to not have no lock 9. If the request item 1 ^. method ', the operation of the data structure, the operation without lock capability can be divided into the operation including the predefined number of operations. The number of derogatory ones cannot be partially completed. 143290.doc 201112125 10. The method of claim 7, wherein the operation of the data structure without lock capability can be divided into ' ° ' η 珉 1 to 5 non-partial operations. π·If the number of memory cells modified in any of the items 1 to 6 is double-horse*, the operation is divided into operations with lock-free capability. - The number of 5 hais of the memory file that is modified by operation is not a constant, and the operation of the 锁心锁能力. ',备..., 12. If the method of requesting 丨i, the pot ^', the temple is equipped with no The number of the memory unit modified by the operation of the lock capability is different from the number of the element of the entity that is inferior to the structure of the lock; the memory to be modified by the operation without the lock, ... The number of 兀 is related to the data structure of the entity ~ the number of elements of the entity. 13. If the method of research is used, the operation of the eight-capacity-free operation can save less than one word of the unit.桠祚 次 双 , , 该 该 该 该 该 该 该 该 该 该 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. In a single thread processing, the same for the data structure Each operation of the entity - ", the efficiency efficiency in the lock-free mode and the _ lock-based mode: the difference in the efficiency of the month b is less than a box of the fixed value, the value of the $ π pre-existing value, then the operation is classified as The operation of the benefit lock capability; otherwise, the operation, "', the operation. "The class is a method that does not have the lock-free capability κ such as the request item u", in a single-thread processing, for the data structure The operation-class-in-operation-in-the-benefit mode has a performance difference of less than μ times in the performance of a lock-based mode, and the operation is classified as having a lock-free ability. 143290.doc 201112125 16. 17 18. 19. Otherwise: classify the operation as an operation that does not have lock-free capabilities. An operating system structure-physical system comprising: a weak lock module for requesting an entity that has at least one lock-capable operation - a lock - a weak lock to operate the data structure; A module having a lock-free operation for performing the at least one lock-free operation to operate the f-structure by obtaining the weak lock of a lock-free operation The entity; the strong lock module 'is used to request the pair - the lock that does not have the lock-free operation, one of the locks to lock the entity to operate the data structure; and the second operation that does not have the lock-free capability The module is configured to perform the entity that does not have the power to operate the data structure in response to the strong lock that is not capable of operation without lock capability. , the system of item 1 'which makes the weak lock module and the strong lock module enter a first =, and state · allows a plurality of operations to obtain the weak lock of the lock during the same period, allowing only - The operation obtains the strong lock of the first lock not in the same period: the first lock-weak lock and the action are obtained. . , in the 'parallel execution of the first lock to obtain the weak lock of the first lock:: the death of the system! 7 further includes a lock module, the blockade model is configured in 7 steps to: in response to the execution of the non-existence Locking ability 2: The lock requests the strong lock-operation of the first-lock; and responds to: the operation without the lock capability, the block request for the first-lock is the same as the lock or the fourth lock The other operations of (4). The system of member 16, wherein the weak lock module is further configured to: M3290.doc 201112125 responsive to the entity having the lock-free operation that has operated the data structure, releasing the weak lock; and the strong lock module Further configured to respond to the non-lock-capable operation of the entity that has operated the t-material structure, releasing the strong lock. 20. The method of claim 16, wherein the operations can include a write operation. Execution by the lock-free operation 21. The system of claim 16 further comprising - operating the operation of the entity of the data structure and having no lock-free operation. An operation classification module, which is classified as having a lock-free capability A such as: a system of claim 21, wherein the operation classification module is advanced by any of the methods of claims 7 to 5 - ^ The operation of the entity is classified as having 5 operations that are omnipotent, combined, and non-lockable. Locking ability I43290.doc
TW98131255A 2009-09-16 2009-09-16 Method and system for operating an instance of a data structure TW201112125A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW98131255A TW201112125A (en) 2009-09-16 2009-09-16 Method and system for operating an instance of a data structure

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW98131255A TW201112125A (en) 2009-09-16 2009-09-16 Method and system for operating an instance of a data structure

Publications (1)

Publication Number Publication Date
TW201112125A true TW201112125A (en) 2011-04-01

Family

ID=44909151

Family Applications (1)

Application Number Title Priority Date Filing Date
TW98131255A TW201112125A (en) 2009-09-16 2009-09-16 Method and system for operating an instance of a data structure

Country Status (1)

Country Link
TW (1) TW201112125A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9652289B2 (en) 2012-04-27 2017-05-16 Microsoft Technology Licensing, Llc Systems and methods for S-list partitioning

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9652289B2 (en) 2012-04-27 2017-05-16 Microsoft Technology Licensing, Llc Systems and methods for S-list partitioning
TWI605340B (en) * 2012-04-27 2017-11-11 微軟技術授權有限責任公司 Systems and methods for s-list partitioning
US10223253B2 (en) 2012-04-27 2019-03-05 Microsoft Technology Licensing, Llc Allocation systems and method for partitioning lockless list structures

Similar Documents

Publication Publication Date Title
Herlihy et al. Transactional boosting: a methodology for highly-concurrent transactional objects
Dayal et al. A transactional model for long-running activities
Biliris et al. ASSET: A system for supporting extended transactions
Wang et al. Scaling multicore databases via constrained parallel execution
Scherer III et al. Scalable synchronous queues
CN102282548B (en) Transaction processing in transactional memory
CN103262036A (en) Non-blocking wait-free data-parallel scheduler
US8176022B1 (en) Locking protocol using dynamic locks and dynamic shared memory
TW200947302A (en) Retargetting an application program for execution by a general purpose processor
TW200903256A (en) Parallelizing sequential frameworks using transactions
CN113205417B (en) Alliance chain oriented transaction parallel processing method and system
JP2019505916A (en) Recoverable stream processing
Chrysanthis ACTA, A framework for modeling and reasoning about extended transactions
WO2010034777A1 (en) Method and system for parallel processing of a data structure instance
TW201112125A (en) Method and system for operating an instance of a data structure
Ponge Fork and Join: Java can excel at painless parallel programming too!
Siek et al. Towards a fully-articulated pessimistic distributed transactional memory
Herlihy The multicore revolution: the challenges for theory
Posner Load Balancing, Fault Tolerance, and Resource Elasticity for Asynchronous Many-Task Systems
Kalin et al. Clojure for number crunching on multicore machines
Tamura et al. Concurrency control program generation by decreasing nodes of program trees in genetic programming
Siek et al. Atomic RMI 2: Highly parallel pessimistic distributed transactional memory
Aumann et al. Efficient execution of nondeterministic parallel programs on asynchronous systems
Tasmere et al. Concurrency control in database systems
Kaiser et al. Making progress in cooperative transaction models