日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

dbms_DBMS | 并发控制

發布時間:2025/3/11 69 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dbms_DBMS | 并发控制 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

dbms

Management of concurrent transaction execution is known as “Concurrency Control”. Transaction management in DBMS handles all transaction, to ensure serializability and isolation of transaction. DBMS implement concurrency control technique so that the consistency and integrity of the database can be hold.

并發事務執行的管理稱為“并發控制” 。 DBMS中的事務管理處理所有事務,以確保事務的可串行性和隔離性。 DBMS實施并發控制技術,以便可以保持數據庫的一致性和完整性。

The processes of managing simultaneously operation such that update, create, insert, delete on the database without having an interface with one another, known as concurrency control. It can be performed by various methods such as locking technique, time stamp technique, validation based technique.

同時管理操作的過程,例如在數據庫上相互更新,創建,插入,刪除而無需相互接口,這稱為并發控制。 它可以通過各種方法執行,例如鎖定技術,時間戳技術,基于驗證的技術。

并發控制的鎖定技術 (Locking Technique for Concurrency Control)

Locking is a procedure which controls concurrent access of the data. If one transaction is accessing the database, a lock may be denied access to other transaction to prevent the incorrect result. Locking technique is one of the most widely used mechanisms to ensure serializability. The principle of locking technique is that a transaction must obtain read or write lock in the database before it can perform a read or write operation.

鎖定是控制并發訪問數據的過程。 如果一個事務正在訪問數據庫,則可以拒絕鎖訪問其他事務,以防止產生錯誤的結果。 鎖定技術是確??尚蛄谢缘淖顝V泛使用的機制之一。 鎖定技術的原理是,事務必須先獲得數據庫中的讀取或寫入鎖定,然后它才能執行讀取或寫入操作。

There are some basic rules for locking technique are as following:

鎖定技術有一些基本規則,如下所示:

  • If a transaction has read lock on the data item, it can read the item but can’t update it.

    如果事務對數據項具有讀取鎖定,則它可以讀取該項目但不能更新它。

  • If a transaction has read lock on the data item, other transaction can read on data item but can’t write on the data item.

    如果事務對數據項具有讀取鎖定,則其他事務可以在數據項上讀取,但不能在數據項上寫入。

  • If a transaction has to write lock on the data item, it can both read and update data item.

    如果事務必須在數據項上寫鎖,則它可以讀取和更新數據項。

  • If a transaction has to write lock on data item then the other transaction neither read nor write on the data item.

    如果一個事務必須在數據項上寫鎖,則另一個事務既不在該數據項上讀寫。

鎖定方式 (Mode of Locking)

There are basically two types of modes in which a data item may be locked:

基本上有兩種模式可以鎖定數據項:

  • Shared Lock

    共享鎖

  • Exclusive Lock

    排他鎖

  • 1)共享鎖 (1) Shared Lock)

    If a transaction T has a shared lock on the data item q, then T can read but can’t write on q data item. It is denoted by (S).

    如果事務T在數據項q上具有共享鎖,則T可以在q數據項上讀取但不能寫入。 用( S )表示。

    2)排他鎖 (2) Exclusive Lock)

    If transaction T has an exclusive lock on data item q, then T can read and write both on the data item. It is denoted by (X).

    如果事務T對數據項q具有排他鎖,則T可以在數據項上進行讀寫操作。 用( X )表示。

    In order to access the data item, these conditions should be followed:

    為了訪問數據項,應遵循以下條件:

    • Transaction T must first lock it. If the data item is already locked by another transaction which is not comparable then T must wait until have been released & unlock.

      事務T必須首先將其鎖定。 如果數據項已經被另一個不可比較的事務鎖定,則T必須等待直到被釋放并解鎖。

    • The transaction must hold a lock on data item when it is accessed.

      事務在訪問時必須對數據項保持鎖定。

    • After that unlock it.

      之后,將其解鎖。

    A matrix given below shows the comparability between two lock modes:

    下面給出的矩陣顯示了兩種鎖定模式之間的可比性:

    Shared (S)Exclusive(X)
    STT
    XFF
    共享的(S) 獨家(X)
    小號 ? ?
    X F F

    Example:

    例:

    Consider the following 2 transaction T(read(a), read(b)).

    考慮以下2個事務T(read(a),read(b)) 。

    T1T2
    read(a) read(b) if a=0 then b=b+1 write(b)
    T1 T2
    read(a) read(b) if a=0 then b=b+1 write(b)

    Find lock and unlock instruction of the transaction T1 & T2. Then observe the locking protocol? The execution of transaction is deadlock?

    查找交易T1和T2的鎖定和解鎖指令。 然后遵守鎖定協議? 交易的執行是否陷入僵局?

    Solution:

    解:

    Lock and unlock instruction:

    鎖定和解鎖說明:

    T1T2
    lock S(a) read(a) lock X(b) read(b) if a=0 then b=b+1 write(b) unlock(b) unlock(a) lock S(b) read(b) lock (a) read(a) if b=0 then a=a+1 write(a) unlock(a) unlock(b)
    T1 T2
    T1T2
    lock S(a)
    lock S(b)
    lock X(b)
    lock X(a)
    T1 T2
    鎖S(a)
    鎖S(b)
    鎖X(b)
    鎖X(a)

    Yes, transaction has deadlock.

    是的,交易陷入僵局。

    翻譯自: https://www.includehelp.com/dbms/concurrency-control.aspx

    dbms

    總結

    以上是生活随笔為你收集整理的dbms_DBMS | 并发控制的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。