Unlock instant, AI-driven research and patent intelligence for your innovation.

A resource sharing protection method and device

A technology for sharing resources and times, applied in the direction of resource allocation, multi-program installation, program startup/switching, etc., can solve the problems of CPU exhaustion and high CPU occupation, reduce times, reduce CPU usage, and solve deadlocks The effect of detecting problems

Active Publication Date: 2019-02-05
TENCENT TECH (BEIJING) CO LTD
View PDF5 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

It can be seen that the spin lock mechanism will lead to high CPU usage, and if a deadlock occurs, the CPU will be exhausted

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A resource sharing protection method and device
  • A resource sharing protection method and device
  • A resource sharing protection method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0043] In this embodiment, the process currently accessing the shared resource is called process A, the process A locks the shared resource, and the process requesting to access the shared resource is called process B. Such as figure 2 It is an implementation flowchart of Embodiment 1 of the present invention, including:

[0044] Step 201: Process B judges whether the shared resource has been locked, if yes, then execute step 202; if not, then process B locks the shared resource, accesses the shared resource, and releases the shared resource after the access is completed Lock.

[0045] Step 202: The CPU executes an idling instruction once, and adds 1 to the number of idling times of the CPU.

[0046] Step 203: Determine whether the number of CPU idling times is less than a preset threshold value of idling times. In this embodiment, the threshold value is 50 times. If it is less, execute step 201 again; if not, execute step 204.

[0047] Step 204: Determine whether the lock...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention provides a resource sharing protecting method and device. The method includes the steps that A, whether a sharing resource is locked or not is judged, and if yes, the step B is executed; B, a CPU executes an idling instruction once, one is added to the number of times of CPU idling, whether the number of times of CPU idling is smaller than a preset threshold value of the number of times of idling or not is judged, if yes, the step A is executed again, and if not, the step C is executed; C, whether a lock of the sharing resource is a deadlock or not is judged, if yes, the lock of the sharing resource is released, the step A is executed again, otherwise, process context switching is executed, one is added to the number of the times of process context switching, the current CPU is released, and when the next process is called by a kernel, the step A is executed again. The number of times of process context switching can be reduced, the use ratio of the CPU is reduced, and the deadlock detection problem is solved.

Description

technical field [0001] The invention relates to the technical field of shared resource protection, in particular to a shared resource protection method and device. Background technique [0002] Mutual exclusion locks and spin locks are both lock mechanisms proposed to protect shared resources. Spin locks are similar to mutexes, they are all to solve the mutually exclusive use of a shared resource. Whether it is a mutex or a spin lock, there can be at most one holder at any time, that is, at most one execution unit can acquire the lock at any time. But the two are slightly different in the scheduling mechanism. For a mutex, if the resource is already occupied, the resource applicant can only enter the sleep state; but the spin lock will not cause the resource applicant to sleep, if the spin lock has been held by other execution units, the resource application The spinner will keep looping to see if the lock holder of the pick has released the lock, hence the name "spin". ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): G06F9/50G06F9/48
Inventor 王勇
Owner TENCENT TECH (BEIJING) CO LTD