IP Library Granted Patent US 11,119,832
Granted Patent B2
US 11,119,832 · App. 16/552,340 · Granted Sep 14, 2021

Method and device for implementing read-write lock reentry, terminal and storage medium

Inventors: Kaiwen Feng (Beijing, CN); Zhuo Chen (Beijing, CN); Yuedong Dang (Beijing, CN); Ronggui Peng (Beijing, CN); Wanyu Bao (Beijing, CN); Zhongjun Ni (Beijing, CN)
Assignee: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
G06F9/524G06F9/5005
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,119,832
App. No.
16/552,340
Granted
Sep 14, 2021
Kind
B2
Abstract

The embodiments of the present disclosure provide a method and a device for implementing read-write lock reentry, a terminal and a storage medium. The method includes: receiving a write lock request of a thread to a target resource; in response to determining that the target resource is in a write-lock-exclusive state, acquiring a historical write-lock thread to the target resource that is in the write-lock-exclusive state; in response to determining that the thread is identical to the historical write-lock thread, adding a new lock of the thread to the target resource.

Claims (33)

1. A method for implementing read-write lock reentry, comprising:

receiving a lock request of a thread to a target resource;

in response to determining that the target resource is in a write-lock-exclusive state, acquiring a historical write-lock thread to the target resource that is in the write-lock-exclusive state;

in response to determining that the target resource is in an unlocked state, adding a write lock of the thread to the target resource and taking the thread as a write-lock thread to the target resource under as case that the lock request is a write-lock request, and adding a read lock of the thread to the target resource and taking the thread as a read-lock thread to the target resource under a case that the lock request is a read-lock request;

in response to determining that ID of the thread is identical to ID of the historical write-lock thread, adding a new lock of the thread to the target resource; and

in response to determining that the ID of thread is different from the ID of the historical write-lock thread, rejecting the lock request of the thread.

2. The method according to claim 1 , after adding the new lock of the thread to the target resource, further comprising:

in response to detecting that all locks of the target resource are unlocked, determining that the target resource is in an unlocked state.

3. The method according to claim 1 , after adding the new lock of the thread to the target resource, further comprising:

receiving and responding to an access instruction of the thread to the target resource.

4. A terminal, comprising:

one or more processors;

a storage device, configured to store one or more programs; and

wherein, when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement a method for implementing read-write lock reentry, the method comprising:

receiving a lock request of a thread to a target resource;

in response to determining that the target resource is in a write-lock-exclusive state, acquiring a historical write-lock thread to the target resource that is in the write-lock-exclusive state;

in response to determining that the target resource is in an unlocked state, adding a write lock of the thread to the target resource and taking the thread as a write-lock thread to the target resource under as case that the lock request is a write-lock request, and adding a read lock of the thread to the target resource and taking the thread as a read-lock thread to the target resource under a case that the lock request is a read-lock request;

in response to determining that ID of the thread is identical to ID of the historical write-lock thread, adding a new lock of the thread to the target resource; and

in response to determining that the ID of thread is different from the ID of the historical write-lock thread, rejecting the lock request of the thread.

5. The terminal according to claim 4 , after adding the new lock of the thread to the target resource, further comprising:

in response to detecting that all locks of the target resource are unlocked, determining that the target resource is in an unlocked state.

6. The terminal according to claim 4 , after adding the new lock of the thread to the target resource, further comprising:

receiving and responding to an access instruction of the thread to the target resource.

7. A non-transitory storage medium having computer programs stored thereon, wherein when the programs are executed by a processor, a method for implementing read-write lock reentry is implemented, the method comprising:

receiving a lock request of a thread to a target resource;

in response to determining that the target resource is in a write-lock-exclusive state, acquiring a historical write-lock thread to the target resource that is in the write-lock-exclusive state;

in response to determining that the target resource is in an unlocked state, adding a write lock of the thread to the target resource and taking the thread as a write-lock thread to the target resource under as case that the lock request is a write-lock request, and adding a read lock of the thread to the target resource and taking the thread as a read-lock thread to the target resource under a case that the lock request is a read-lock request;

in response to determining that ID of the thread is identical to ID of the historical write-lock thread, adding a new lock of the thread to the target resource; and

in response to determining that the ID of thread is different from the ID of the historical write-lock thread, rejecting the lock request of the thread.

8. The non-transitory storage medium according to claim 7 , after adding the new lock of the thread to the target resource, further comprising:

in response to detecting that all locks of the target resource are unlocked, determining that the target resource is in an unlocked state.

9. The non-transitory storage medium according to claim 7 , after adding the new lock of the thread to the target resource, further comprising:

receiving and responding to an access instruction of the thread to the target resource.

Assignments (3)
CORRECTIVE ASSIGNMENT TO CORRECT THE APPLICANT NAME PREVIOUSLY RECORDED AT REEL: 057933 FRAME: 0812. ASSIGNOR(S) HEREBY CONFIRMS THE ASSIGNMENT. Recorded Dec 28, 2021
From: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
To: APOLLO INTELLIGENT DRIVING TECHNOLOGY (BEIJING) CO., LTD.
Reel/Frame 058594/0836 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 13, 2021
From: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
To: APOLLO INTELLIGENT DRIVING (BEIJING) TECHNOLOGY CO., LTD.
Reel/Frame 057933/0812 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 27, 2019
From: FENG, KAIWEN; CHEN, ZHUO; DANG, YUEDONG; PENG, RONGGUI; BAO, WANYU; NI, ZHONGJUN
To: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
Reel/Frame 050182/0220 →
Priority Claims (1)
CN 201810987084.0 · Aug 28, 2018 · national
Continuity (1)
Related Publication 20200073728A1 · Mar 5, 2020