Method and device of accessing restriction on resource and terminal equipment

A resource limitation and resource technology, applied in the Internet field, can solve problems such as low system operation efficiency and usage

Inactive Publication Date: 2018-08-24
WUHAN DOUYU NETWORK TECH CO LTD
View PDF4 Cites 6 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0005] At present, the most common implementation methods of spin locks are to use a mutex variable of a system resource to protect the lock count variable. This implementation method is simple to implement, but still uses the mutex resource of the system, resulting in low system operation efficiency.

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
  • Method and device of accessing restriction on resource and terminal equipment
  • Method and device of accessing restriction on resource and terminal equipment
  • Method and device of accessing restriction on resource and terminal equipment

Examples

Experimental program
Comparison scheme
Effect test

no. 1 example

[0036] Create a spin lock through class SpinLock, which includes a constructor, a locking function lock, and an unlocking function unlock. Wherein, the lock count variable is defined in the constructor, and the initial value of the lock count variable is 0, which means that the spin lock is an idle spin lock not occupied by other threads. The locking function lock is placed in the while loop. In the body of the while loop, the lock count variable is read and written through the InterlockedCompareExchange system function (specified function). The InterlockedCompareExchange system function is an atomic operation function provided by the Windows platform. Among them, the while loop body of the locking function is:

[0037]

[0038] It can be seen that, by int old=InterlockedCompareExchange((volatile long*)&m_spin, 1,0); three parameters of the interlockedCompareExchange system function are defined, and these three parameters are respectively the lock count variable, the first ...

no. 2 example

[0041] In the first embodiment, two atomic API operation functions, InterlockedCompareExchange and InterlockedExchange, are used. These two operation functions are atomic operation functions provided by the Windows platform, and cannot be transplanted to systems such as Linux, Mac / OSX, Android, and iOS. Therefore, in order to realize the cross-platform spin lock method, the atomic atomic operation template class in the C++11 standard is used to realize the cross-platform use of the spin lock method. Specifically, the spin lock includes a constructor, a lock function lock and an unlock function unlock. Wherein, the constructor defines the initial value of the lock count variable m_spin as 0, which indicates that the lock count variable is an idle spin lock not occupied by other threads.

[0042] The locking function lock is placed in a while loop body. In the loop body, the read and write operations on the lock count variable are realized through the compare_exchage_strong func...

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 relates to the field of internet technology, and particularly to a method and a device of accessing restriction on a resource and terminal equipment. According to the method, simultaneous accessing of a plurality of threads to the resource is restricted through a defined spin lock, and the spin lock includes a lock counting variable, locking functions and unlocking functions. A current thread calls a specified function in the lock functions to detect whether the lock counting variable is a preset initial value, and if the lock counting variable is the preset initial value, the lock counting variable is configured to a preset threshold value to enable the current thread to occupy the spin lock to access the resource. After resource accessing of the current thread is completed,the unlocking functions are called to configure the lock counting variable from the preset threshold value to the preset initial value to enable the other threads to call the spin lock. In the scheme, the thread reads and writes the lock counting variable through calling the system functions without using system resources, thus the system resources are saved, and running efficiency of a system isimproved.

Description

technical field [0001] The present invention relates to the technical field of the Internet, in particular, to a method, device and terminal equipment for restricting access to resources. Background technique [0002] In modern computer programming, multithreading is widely used. In order to protect related codes or variables, a lock mechanism is usually used in multithreading to solve it. For example, in the Windows system, methods such as spin locks, mutexes, and semaphores can be used to implement lock functions. Take the spin lock (generally provide the lock function for locking and the unlock function for unlocking) as an example, use the lock method of the spin lock to lock and protect the code and data that need to be protected, so that other threads run to the address of the calling function , it will be blocked; call the unlock function of the spin lock to unlock the code area. The code between lock and unlock is thread-safe. For a process with N threads running a...

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 Applications(China)
IPC IPC(8): G06F9/50G06F9/52
CPCG06F9/5027G06F9/52G06F2209/5018G06F2209/504
Inventor 杨亮张文明陈少杰
Owner WUHAN DOUYU NETWORK TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products