CN105893120A - Acquisition method and device for thread synchronization resources - Google Patents

Acquisition method and device for thread synchronization resources Download PDF

Info

Publication number
CN105893120A
CN105893120A CN201610249861.2A CN201610249861A CN105893120A CN 105893120 A CN105893120 A CN 105893120A CN 201610249861 A CN201610249861 A CN 201610249861A CN 105893120 A CN105893120 A CN 105893120A
Authority
CN
China
Prior art keywords
resource
thread
weighted value
record
timestamp
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201610249861.2A
Other languages
Chinese (zh)
Other versions
CN105893120B (en
Inventor
魏亚文
孙政
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201610249861.2A priority Critical patent/CN105893120B/en
Publication of CN105893120A publication Critical patent/CN105893120A/en
Application granted granted Critical
Publication of CN105893120B publication Critical patent/CN105893120B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/468Specific access rights for resources, e.g. using capability register
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3442Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for planning or managing the needed capacity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/483Multiproc
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/484Precedence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5013Request control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/508Monitor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention provides an acquisition method and device for thread synchronization resources, aiming at meeting the similar requirements of resource calling of threads with priority levels, avoiding the problems that the threads cannot be executed in time as the resources cannot be acquired in time, and reducing the operation risks of a whole system to a certain extent. Meanwhile, distribution conditions of all resources at present are recorded and monitored, and data evidences are provided for analyzing whether a program thread resource design is reasonable or not in the future. The acquisition method for the thread synchronization resources comprises the following steps: receiving acquired resource parameters sent by the threads; determining weight values of the threads according to weight parameters; according to the resource parameters, determining whether the resources are in a locked state or not; under the precondition that the resources are determined to be in the locked state, modifying the state of the threads into a blocked state; putting the threads into a waiting queue of the resources; under the condition that the resources are unlocked, providing the resources to the thread with the greatest weight value in the waiting queue.

Description

The acquisition methods of a kind of thread synchronization resource and device
Technical field
The present invention relates to computer and software technology field thereof, particularly to a kind of thread synchronization money The acquisition methods in source and device.
Background technology
In java program, based on multithreading is concurrently the most common.In order to prevent because of multithreading pair Same resource (data object) accesses and causes data corruption, so there being synchronization (lock) Application, thus ensure each resource some moment can only by a thread accesses, simultaneously its He can only block by thread;After waiting that other threads complete, wake up obstruction thread up.
Due to the obstruction of thread with to wake up up be all random, and for the thread that priority is high, Obtain resource if delayed, will result in thread cannot perform in time, even can be to whole System produces bigger risk.Money same for multiple thread dispatchings in existing jvm virtual machine The processing mode in source typically uses the mode of fair lock, i.e. waits that the time of resource is long based on thread Short come wake-up waiting thread;Other processing modes are substantially random wake-up waiting thread.
In sum, the processing mode of prior art resource same for multiple thread dispatchings uses Length random or based on the waiting time wakes up the thread of obstruction up, excellent for being similar to have The requirement of the resource transfer of the thread of first level cannot meet, the most not only can be because of obtaining in time The problem getting resource and cause thread to perform in time, the most also can run whole system Produce bigger risk;Meanwhile, the distribution condition of current all of resource is not had by prior art Record and monitoring, also make later analysis program threads Resource Design the most rationally lack foundation.
Summary of the invention
In view of this, the present invention provides acquisition methods and device, the energy of a kind of thread synchronization resource Enough meet the requirement being similar to there is the resource transfer of the thread of priority, it is to avoid because of cannot and Time get resource and the problem that causes thread to perform in time, reduce to a certain extent The operation risk of whole system;Meanwhile, the distribution condition of current all of resource is remembered Record and monitoring, the most rationally provide data foundation for later analysis program threads Resource Design.
For achieving the above object, according to an aspect of the invention, it is provided a kind of thread synchronization The acquisition methods of resource.
The acquisition methods of the thread synchronization resource of the present invention, including: the acquisition that receiving thread sends The parameter of resource;The parameter of described acquisition resource includes: resource parameters and weight parameter;According to Described weight parameter determines the weighted value of described thread;This resource is determined according to described resource parameters Whether it is lock-out state, on the premise of determining that this resource is lock-out state, by described thread Status modifier is blocked state, is then put into by this thread in the waiting list of this resource, at this In the case of resource is unlocked, this resource is supplied to the line that in this waiting list, weighted value is maximum Journey.
Alternatively, according to described resource parameters determine this resource be whether lock-out state step it After also include: on the premise of determining that this resource is unlocked state, this resource is supplied to institute State thread.
Alternatively, described weight parameter includes weighted value, weighting function or sky;When described weight When parameter is weighted value, the step of the described weighted value determining described thread according to described weight parameter Suddenly include the weighted value that receives as the weighted value of this thread;When described weight parameter is power During weight function, the step of the described weighted value determining described thread according to described weight parameter includes: The weighted value of this thread it is calculated according to this weighting function;When described weight parameter is empty, The step of the described weighted value determining described thread according to described weight parameter includes: confirm described Weight parameter is empty, then using the weighted value of acquiescence as the weighted value of this thread.
Alternatively, described determine that whether this resource is the step of lock-out state according to described resource parameters Before Zhou, also include: determine whether there is the recalls information of this resource according to described resource parameters, If it is present the resource extinction duration in the recalls information of this resource is reverted to initial duration; Otherwise, set up the recalls information of this resource, and the resource extinction duration of this resource is set.
Alternatively, described determine that whether this resource is the step of lock-out state according to described resource parameters Suddenly include: search the resource information of this resource according to described resource parameters;According to this resource information In resource lock flag determine whether this resource is lock-out state.
Alternatively, after the step of the parameter of the acquisition resource that receiving thread sends, also include: The initial time stamp of this thread application resource is recorded, then by the time of record in journal file Stamp is stored in data base, further according to the timestamp statistics thread of record average etc. in data base That treats duration and thread averagely performs duration.
Alternatively, after the step in the described waiting list that this thread is put into this resource, also Including: in journal file, record this thread enter the timestamp of waiting list, then by record Timestamp be stored in data base, further according to the timestamp statistics thread of record in data base Average waiting duration and thread averagely perform duration.
Alternatively, described weighted value in this waiting list maximum thread that this resource is supplied to Before step, also include: record thread waits for timestamp in journal file, then will The timestamp of record is stored in data base, further according to the timestamp statistics line of record in data base The average waiting duration of journey and thread averagely perform duration.
Alternatively, described weighted value in this waiting list maximum thread that this resource is supplied to After step, also include: record thread timestamp after getting resource in journal file, Then the timestamp of record is stored in data base, further according to the timestamp of record in data base The statistics average waiting duration of thread and thread averagely perform duration;Described get resource after Timestamp include: resource is locked timestamp and resource is abandoned the timestamp of locking.
Alternatively, described weighted value in this waiting list maximum thread that this resource is supplied to Step includes: according to weight, the thread in waiting list is carried out descending;This resource is carried Supply comes the thread of first;And described thread in waiting list is dropped according to weight After the step of sequence arrangement, also include: according to the thread scheduling instruction received, record thread The change of the position in affiliated waiting list, and the weighted value of the thread after position change is repaiied Change the weighted value corresponding to this position after change in location into.
According to another aspect of the present invention, it is provided that the acquisition device of a kind of thread synchronization resource.
The acquisition device of the thread synchronization resource of the present invention includes: receiver module, is used for receiving line The parameter of the acquisition resource that journey sends;The parameter of described acquisition resource includes: resource parameters and power Weight parameter;Determine module, for determining the weighted value of described thread according to described weight parameter; First provides module, for determining whether this resource is lock-out state according to described resource parameters, On the premise of determining that this resource is lock-out state, by the status modifier of described thread for blocking shape State, then puts in the waiting list of this resource by this thread, in the situation that this resource is unlocked Under, this resource is supplied to the thread that in this waiting list, weighted value is maximum.
Alternatively, also include the second offer module, for determining that this resource is unlocked state On the premise of, this resource is supplied to described thread.
Alternatively, described weight parameter includes weighted value, weighting function or sky;When described weight When parameter is weighted value, described determine module for the weighted value that will receive as this thread Weighted value;When described weight parameter is weighting function, described determine that module is for according to this power Weight function is calculated the weighted value of this thread;When described weight parameter is empty, described determine Module is used for confirming that described weight parameter is sky, then using the weighted value of acquiescence as this thread Weighted value.
Alternatively, also include information check module, for determining whether according to described resource parameters There is the recalls information of this resource, if it is present by the resource in the recalls information of this resource Extinction duration reverts to initial duration;Otherwise, set up the recalls information of this resource, and setting should The resource extinction duration of resource.
Alternatively, described first module is provided to be additionally operable to search this resource according to described resource parameters Resource information, whether determine this resource further according to the resource lock flag in this resource information For lock-out state.
Alternatively, also include the first logging modle, for recording this thread Shen in journal file Please the initial time stamp of resource, then the timestamp of record is stored in data base, further according to In data base, the timestamp of record adds up average waiting duration and when averagely the performing of thread of thread Long.
Alternatively, also include the second logging modle, enter for recording this thread in journal file Enter the timestamp of waiting list, then the timestamp of record is stored in data base, further according to In data base, the timestamp of record adds up average waiting duration and when averagely the performing of thread of thread Long.
Alternatively, also include the 3rd logging modle, wait for record thread in journal file Deadline stabs, and is then stored in data base by the timestamp of record, further according in data base The timestamp statistics average waiting duration of thread of record and thread averagely perform duration.
Alternatively, also include the 4th logging modle, obtaining for record thread in journal file Get the timestamp after resource, then the timestamp of record is stored in data base, further according to In data base, the timestamp of record adds up average waiting duration and when averagely the performing of thread of thread Long;Described get resource after timestamp include: resource is locked timestamp and resource and is put Abandon the timestamp of locking.
Alternatively, described first module is provided to be additionally operable to the thread in waiting list according to weight Carry out descending, then this resource is supplied to come the thread of first;And described device is also Including thread scheduling module, for according to the thread scheduling instruction received, record thread is in institute The change of the position in genus waiting list, and the weighted value of the thread after position change is revised as Weighted value corresponding to this position after change in location.
According to a further aspect of the invention, it is provided that the acquisition device of a kind of thread synchronization resource.
The acquisition device of the thread synchronization resource of the present invention, including: memorizer and processor;Its In, described memory store instruction;Described processor performs described instruction, is used for: receive line The parameter of the acquisition resource that journey sends;The parameter of described acquisition resource includes: resource parameters and power Weight parameter;The weighted value of described thread is determined according to described weight parameter;Join according to described resource Number determines whether this resource is lock-out state, on the premise of determining that this resource is lock-out state, It is blocked state by the status modifier of described thread, then this thread is put into the wait of this resource In queue, in the case of this resource is unlocked, this resource is supplied in this waiting list power The thread that weight values is maximum.
According to technical scheme, come the line waited the weighted value being then based on thread Cheng Jinhang wakes up up, therefore, it is possible to meet the wanting of resource transfer being similar to have the thread of priority Ask, it is to avoid the problem that causes thread to perform in time because resource cannot be got in time, Reduce the operation risk of whole system to a certain extent;Meanwhile, wait at thread and call During, the distribution condition of current all of resource is recorded and monitored, thus for Later analysis program threads Resource Design the most rationally provides data foundation;And this technical side Thread wait order in waiting list can also be changed by case, thus, also in certain journey The motility of scheduling of resource is improve on degree.
Accompanying drawing explanation
Accompanying drawing is used for being more fully understood that the present invention, does not constitute inappropriate limitation of the present invention.Wherein:
Fig. 1 is the signal of the acquisition device of a kind of thread synchronization resource according to embodiments of the present invention Figure;
Fig. 2 is the signal of the acquisition methods of a kind of thread synchronization resource according to embodiments of the present invention Figure;
Fig. 3 is showing of the acquisition methods of another kind of thread synchronization resource according to embodiments of the present invention It is intended to.
Detailed description of the invention
Below in conjunction with accompanying drawing, the one exemplary embodiment of the present invention is explained, including this The various details of bright embodiment are to help understanding, it should they are thought the most exemplary. Therefore, those of ordinary skill in the art are it should be appreciated that can do the embodiments described herein Go out various changes and modifications, without departing from scope and spirit of the present invention.Equally, in order to clearly Chu, with simple and clear, eliminates the description to known function and structure in description below.
Fig. 1 is the signal of the acquisition device of a kind of thread synchronization resource according to embodiments of the present invention Figure.The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention specifically includes that receiver module 11, determine that module 12 and first provides module 13;Receiver module 11 is for receiving thread The parameter of the acquisition resource sent;The parameter of described acquisition resource includes: resource parameters and weight Parameter;Determine that module 12 for determining the weighted value of described thread according to described weight parameter;The One provides module 13 to be used for determining whether this resource is lock-out state according to described resource parameters, On the premise of determining that this resource is lock-out state, it is blocked state by the status modifier of described thread, Then this thread is put in the waiting list of this resource, in the case of this resource is unlocked, This resource is supplied to the thread that in this waiting list, weighted value is maximum.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include the second offer Module, on the premise of determining that this resource is unlocked state, is supplied to institute by this resource State thread.
The weight parameter being previously mentioned in the embodiment of the present invention can be weighted value, weighting function or sky;
When described weight parameter is weighted value, determine that module 12 is for the weighted value that will receive Weighted value as this thread;
When described weight parameter is weighting function, determine that module 12 is for according to this weighting function It is calculated the weighted value of this thread;
When described weight parameter is empty, determine that module 12 is for confirming that described weight parameter is Sky, then using the weighted value of acquiescence as the weighted value of this thread.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include information check Module (not shown), for determining whether there is this resource according to described resource parameters Recalls information, if it is present recover the resource extinction duration in the recalls information of this resource For initial duration;Otherwise, set up the recalls information of this resource, and the resource arranging this resource disappears Die duration.
First offer module 13 of the acquisition device 10 of the thread synchronization resource of the embodiment of the present invention Can be additionally used in the resource information searching this resource according to described resource parameters, believe further according to this resource Resource lock flag in breath determines whether this resource is lock-out state.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include the first record Module (not shown), for recording the initial of this thread application resource in journal file Timestamp, is then stored in the timestamp of record in data base, further according to record in data base The timestamp statistics average waiting duration of thread and thread averagely perform duration.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include the second record Module (not shown), enters waiting list for recording this thread in journal file Timestamp, is then stored in the timestamp of record in data base, further according to record in data base The timestamp statistics average waiting duration of thread and thread averagely perform duration.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include the 3rd record Module (not shown), waits for timestamp for record thread in journal file, Then the timestamp of record is stored in data base, further according to the timestamp of record in data base The statistics average waiting duration of thread and thread averagely perform duration.
The acquisition device 10 of the thread synchronization resource of the embodiment of the present invention may also include the 4th record Module (not shown), for record thread in journal file after getting resource Timestamp, is then stored in the timestamp of record in data base, further according to record in data base The timestamp statistics average waiting duration of thread and thread averagely perform duration;Described acquisition Timestamp after resource includes: resource is locked timestamp and resource is abandoned time of locking Stamp.
First offer module 13 of the acquisition device 10 of the thread synchronization resource of the embodiment of the present invention Can be additionally used in and the thread in waiting list is carried out descending according to weight, then this resource is carried Supply comes the thread of first;
And described device may also include thread scheduling module (not shown), for basis The thread scheduling instruction received, the change of record thread position in affiliated waiting list, And the weighted value of the thread after position change is revised as after change in location the power corresponding to this position Weight values.
Fig. 2 is the signal of the acquisition methods of a kind of thread synchronization resource according to embodiments of the present invention Figure.As in figure 2 it is shown, the execution master of the acquisition methods of the thread synchronization resource of the embodiment of the present invention Body is the acquisition device 10 of the thread synchronization resource being previously mentioned in Fig. 1, the method mainly include as Lower step S20 to S24.
Step S20: the parameter of the acquisition resource that receiving thread sends.This step is previously mentioned The parameter obtaining resource includes: resource parameters and weight parameter;When thread needs to call resource, Need the resource parameters of resource to be called and the weight parameter of this thread are sent to thread synchronization The acquisition device 10 of resource;Meanwhile, the acquisition device 10 of thread synchronization resource is in journal file Record the initial time stamp of this thread application resource.
Step S21: determine the weighted value of described thread according to described weight parameter.In this step In, the acquisition device 10 of thread synchronization resource is receiving resource parameters and the weight that thread sends After parameter, determine the weighted value of this thread according to weight parameter therein;Weight parameter can be Weighted value, weighting function or sky;(the power such as, received when weight parameter is weighted value Weight values is 8, it is assumed that the span of weighted value is [1,10]), then, thread synchronization resource Acquisition device 10 using the weighted value 8 that receives as the weighted value of this thread;When weight parameter is During weighting function, the acquisition device 10 of thread synchronization resource calculates according to the weighting function received Go out corresponding weighted value, and using calculated weighted value as the weighted value of this thread;Hold power When weight parameter is empty, the acquisition device 10 of thread synchronization resource first confirms that received weight Parameter is empty, then using the weighted value of acquiescence as the weighted value of this thread.
Step S22: determine whether this resource is lock-out state according to described resource parameters, if This resource is lock-out state, then perform step S23;Otherwise, step S24 is performed.Due to online Journey is called often occurs in the middle of the process of resource that same resource needs by multiple thread dispatchings Situation, therefore to ensure that each resource can only be needed by a thread accesses in some moment When resource is by thread dispatching, resource is locked;In step S22, thread synchronization provides The acquisition device 10 in source searches the resource information of this resource according to received resource parameters, and Determine whether this resource is lock-out state according to the resource lock flag in this resource information.
Step S23: be blocked state by the status modifier of described thread, then puts this thread Enter in the waiting list of this resource, in the case of this resource is unlocked, this resource is supplied to The thread that in this waiting list, weighted value is maximum.In this step, the acquisition of thread synchronization resource Thread in this resource waiting list is carried out descending according to the size of weighted value by device 10, And in journal file, record this thread enter the timestamp of waiting list;Solved in this resource In the case of lock, journal file records weighted value and comes when the waiting for of thread of first Between stab;Finally this resource is supplied to weighted value in this waiting list and comes the thread of first, and Record thread timestamp after getting resource in journal file, wherein, thread is obtaining Timestamp after resource includes: resource is locked timestamp and resource is abandoned time of locking Stamp;The acquisition device 10 of thread synchronization resource can be regularly by the timestamp recorded in journal file It is stored in data base, further according to the average waiting of the timestamp statistics thread of record in data base Duration and thread averagely perform duration, for monitoring and record the distribution of resource and calling situation, And data foundation is provided when later analysis program threads Resource Design is the most reasonable.
Step S24: this resource is supplied directly to described thread.
In the technical scheme of the embodiment of the present invention, in order to the resource data in internal memory is entered Row cleaning, therefore, the resource extinction duration corresponding to the resource settings in internal memory, permissible On the premise of resource is not the most called, timing cleaning internal memory, save memory headroom;Line The acquisition device 10 of journey isochronous resources determines whether there is this money according to received resource parameters The recalls information in source, if it is present by the resource extinction duration in the recalls information of this resource Revert to initial duration;Otherwise, set up the recalls information of this resource, and the money of this resource is set Source extinction duration.The acquisition device 10 of thread synchronization resource is not called and resource in resource Extinction time a length of 0 time, this resource is purged.
In the technical scheme of the embodiment of the present invention, the acquisition device 10 of thread synchronization resource can basis The thread scheduling instruction received, the change of record thread position in affiliated waiting list, And the weighted value of the thread after position change is revised as after change in location the power corresponding to this position Weight values.The acquisition device 10 of thread synchronization resource can carry a terminal interface, works as display Before wait thread in waiting list corresponding to invoked resource, resource and according to data When timestamp recorded in storehouse is added up that the average waiting duration of the thread obtained is peaceful to be performed both by The information such as length, user can be by operation terminal interface by waiting team by resource by the way of pulling The wait order of the thread in row is changed, thus generates the thread scheduling instruction of correspondence, and According to the change of this thread scheduling instruction record thread position in affiliated waiting list, and will The weighted value of the thread after position change is revised as the weight after change in location corresponding to this position Value.Such as: the waiting list of a resource has three threads waited, i.e. thread 1 (weight Value is 9), thread 2 (weighted value is 8) and thread 3 (weighted value is 7);If this Time thread 2 need first carry out, then, in the way of pulling, thread 2 can be placed into thread 1 Position, the change of acquisition device 10 record thread 2 position of thread synchronization resource, and will The weighted value of thread 2 should be the weighted value of original thread 1 the most in this position, and by thread 1 Weighted value should the weighted value of thread 2 for being originally in second.
Fig. 3 is showing of the acquisition methods of another kind of thread synchronization resource according to embodiments of the present invention It is intended to.As it is shown on figure 3, the acquisition device 30 of the thread synchronization resource of the present invention mainly includes depositing Reservoir 31 and processor 32;Wherein, described memorizer 31 storage instruction;Described processor 32 Perform described instruction, for the parameter of the acquisition resource that receiving thread sends;Described acquisition resource Parameter include: resource parameters and weight parameter;Described thread is determined according to described weight parameter Weighted value;Determine whether this resource is lock-out state according to described resource parameters, determining this On the premise of resource is lock-out state, it is blocked state by the status modifier of described thread, then This thread is put in the waiting list of this resource, in the case of this resource is unlocked, should Resource is supplied to the thread that in this waiting list, weighted value is maximum.
Technical scheme according to embodiments of the present invention, is come reciprocity by the weighted value being then based on thread The thread treated wakes up up, therefore, it is possible to meet the resource tune being similar to have the thread of priority Requirement, it is to avoid cause thread to perform in time because resource cannot be got in time Problem, reduces the operation risk of whole system to a certain extent;Meanwhile, wait at thread With in invoked procedure, the distribution condition of current all of resource is recorded and monitored, because of And data foundation is the most rationally provided for later analysis program threads Resource Design;And should Thread wait order in waiting list can also be changed by technical scheme, thus, also exist Improve the motility of scheduling of resource to a certain extent.
Above-mentioned detailed description of the invention, is not intended that limiting the scope of the invention.This area Technical staff, it is to be understood that depend on that design requires and other factors, can occur various The amendment of various kinds, combination, sub-portfolio and replacement.Any within the spirit and principles in the present invention Amendment, equivalent and the improvement etc. made, within should be included in scope.

Claims (21)

1. the acquisition methods of a thread synchronization resource, it is characterised in that including:
The parameter of the acquisition resource that receiving thread sends;The parameter of described acquisition resource includes: money Source dates and weight parameter;
The weighted value of described thread is determined according to described weight parameter;
Determine whether this resource is lock-out state according to described resource parameters, determining that this resource is On the premise of lock-out state, it is blocked state by the status modifier of described thread, then by this line Journey is put in the waiting list of this resource, in the case of this resource is unlocked, this resource is carried Supply the thread that in this waiting list, weighted value is maximum.
Method the most according to claim 1, it is characterised in that according to described resource parameters Determine this resource be whether lock-out state step after also include: determining that this resource is unlocked On the premise of determining state, this resource is supplied to described thread.
Method the most according to claim 1, it is characterised in that described weight parameter includes Weighted value, weighting function or sky;
When described weight parameter is weighted value, described determine described line according to described weight parameter The step of the weighted value of journey includes the weighted value that receives as the weighted value of this thread;
When described weight parameter is weighting function, described determine according to described weight parameter described The step of the weighted value of thread includes: be calculated the weighted value of this thread according to this weighting function;
When described weight parameter is empty, described determine described thread according to described weight parameter The step of weighted value includes: confirm that the weighted value of acquiescence, for sky, is then made by described weight parameter Weighted value for this thread.
Method the most according to claim 1, it is characterised in that described according to described resource Before whether this resource of parameter determination is the step of lock-out state, also include: according to described resource Whether parameter determination exists the recalls information of this resource, if it is present calling this resource Resource extinction duration in information reverts to initial duration;Otherwise, that sets up this resource calls letter Breath, and the resource extinction duration of this resource is set.
Method the most according to claim 1, it is characterised in that described according to described resource Whether this resource of parameter determination is that the step of lock-out state includes:
The resource information of this resource is searched according to described resource parameters;
Determine whether this resource is locking shape according to the resource lock flag in this resource information State.
Method the most according to claim 1, it is characterised in that what receiving thread sent obtains After the step of the parameter taking resource, also include: in journal file, record this thread application money The initial time stamp in source, is then stored in the timestamp of record in data base, further according to data In storehouse, the timestamp statistics average waiting duration of thread of record and thread averagely performs duration.
Method the most according to claim 1, it is characterised in that described this thread is put into After step in the waiting list of this resource, also include: in journal file, record this thread Enter the timestamp of waiting list, then the timestamp of record is stored in data base, then root Perform according to average waiting duration and the average of thread of the timestamp statistics thread of record in data base Duration.
Method the most according to claim 1, it is characterised in that described this resource is provided Before the step of the thread of weighted value maximum in this waiting list, also include: at journal file Middle record thread waits for timestamp, is then stored in data base by the timestamp of record, The average waiting duration of thread and the average of thread is added up further according to the timestamp of record in data base Perform duration.
Method the most according to claim 1, it is characterised in that described this resource is provided After the step of the thread of weighted value maximum in this waiting list, also include: at journal file Middle record thread timestamp after getting resource, is then stored in number by the timestamp of record According in storehouse, add up average waiting duration and the line of thread further according to the timestamp of record in data base Journey averagely perform duration;Described get resource after timestamp include: when resource is locked Between stamp and resource be abandoned the timestamp of locking.
Method the most according to claim 1, it is characterised in that described this resource is carried Supply the step of the thread that weighted value is maximum in this waiting list to include:
Thread in waiting list is carried out descending according to weight;
This resource is supplied to come the thread of first;
And described by the thread in waiting list according to weight carry out descending step it After, also include: according to the thread scheduling instruction received, record thread is at affiliated waiting list In the change of position, and after the weighted value of the thread after position change is revised as change in location Weighted value corresponding to this position.
The acquisition device of 11. 1 kinds of thread synchronization resources, it is characterised in that including:
Receiver module, for the parameter of the acquisition resource that receiving thread sends;Described acquisition resource Parameter include: resource parameters and weight parameter;
Determine module, for determining the weighted value of described thread according to described weight parameter;
First provides module, for determining whether this resource is locking shape according to described resource parameters State, on the premise of determining that this resource is lock-out state, is resistance by the status modifier of described thread Plug-like state, then puts into this thread in the waiting list of this resource, is unlocked in this resource In the case of, this resource is supplied to the thread that in this waiting list, weighted value is maximum.
12. devices according to claim 11, it is characterised in that the second offer is also provided Module, on the premise of determining that this resource is unlocked state, is supplied to institute by this resource State thread.
13. devices according to claim 11, it is characterised in that described weight parameter bag Include weighted value, weighting function or sky;
When described weight parameter is weighted value, described determine that module is for the weight that will receive It is worth the weighted value as this thread;
When described weight parameter is weighting function, described determine that module is for according to this weight letter Number is calculated the weighted value of this thread;
When described weight parameter is empty, described determine that module is for confirming that described weight parameter is Sky, then using the weighted value of acquiescence as the weighted value of this thread.
14. devices according to claim 11, it is characterised in that also include information check Module, for determining whether there is the recalls information of this resource according to described resource parameters, if Exist, then the resource extinction duration in the recalls information of this resource is reverted to initial duration;No Then, set up the recalls information of this resource, and the resource extinction duration of this resource is set.
15. devices according to claim 11, it is characterised in that described first provides mould Block is additionally operable to search the resource information of this resource according to described resource parameters, believes further according to this resource Resource lock flag in breath determines whether this resource is lock-out state.
16. devices according to claim 11, it is characterised in that also include the first record Module, for recording the initial time stamp of this thread application resource in journal file, then will The timestamp of record is stored in data base, further according to the timestamp statistics line of record in data base The average waiting duration of journey and thread averagely perform duration.
17. devices according to claim 11, it is characterised in that also include the second record Module, enters the timestamp of waiting list, then will for recording this thread in journal file The timestamp of record is stored in data base, further according to the timestamp statistics line of record in data base The average waiting duration of journey and thread averagely perform duration.
18. devices according to claim 11, it is characterised in that also include the 3rd record Module, in journal file record thread wait for timestamp, then by record time Between stab and be stored in data base, further according to the timestamp statistics thread of record average in data base Waiting time and thread averagely perform duration.
19. devices according to claim 11, it is characterised in that also include the 4th record Module, for record thread timestamp after getting resource in journal file, then will The timestamp of record is stored in data base, further according to the timestamp statistics line of record in data base The average waiting duration of journey and thread averagely perform duration;Described get the time after resource Stamp includes: resource is locked timestamp and resource is abandoned the timestamp of locking.
20. devices according to claim 11, it is characterised in that described first provides mould Block is additionally operable to according to weight, the thread in waiting list is carried out descending, then this resource is carried Supply comes the thread of first;
And described device also includes thread scheduling module, for according to the thread scheduling received Instruction, the change of record thread position in affiliated waiting list, and by after position change The weighted value of thread is revised as the weighted value after change in location corresponding to this position.
The acquisition device of 21. 1 kinds of thread synchronization resources, it is characterised in that including: memorizer And processor;Wherein, described memory store instruction;
Described processor performs described instruction, is used for:
The parameter of the acquisition resource that receiving thread sends;The parameter of described acquisition resource includes: money Source dates and weight parameter;
The weighted value of described thread is determined according to described weight parameter;
Determine whether this resource is lock-out state according to described resource parameters, determining that this resource is On the premise of lock-out state, it is blocked state by the status modifier of described thread, then by this line Journey is put in the waiting list of this resource, in the case of this resource is unlocked, this resource is carried Supply the thread that in this waiting list, weighted value is maximum.
CN201610249861.2A 2016-04-21 2016-04-21 A kind of acquisition methods and device of thread synchronization resource Active CN105893120B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610249861.2A CN105893120B (en) 2016-04-21 2016-04-21 A kind of acquisition methods and device of thread synchronization resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610249861.2A CN105893120B (en) 2016-04-21 2016-04-21 A kind of acquisition methods and device of thread synchronization resource

Publications (2)

Publication Number Publication Date
CN105893120A true CN105893120A (en) 2016-08-24
CN105893120B CN105893120B (en) 2019-07-30

Family

ID=56704183

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610249861.2A Active CN105893120B (en) 2016-04-21 2016-04-21 A kind of acquisition methods and device of thread synchronization resource

Country Status (1)

Country Link
CN (1) CN105893120B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106372179A (en) * 2016-08-31 2017-02-01 上海爱数信息技术股份有限公司 Method and system for detecting document change and synchronization
CN106775974A (en) * 2016-12-07 2017-05-31 国云科技股份有限公司 A kind of implementation method of distributed priority queuing lock
CN107133092A (en) * 2017-05-24 2017-09-05 努比亚技术有限公司 Multi-thread synchronization processing method, terminal and computer-readable recording medium
CN107147922A (en) * 2017-06-20 2017-09-08 深圳市茁壮网络股份有限公司 Frequency resource allocation methods and frequency resource management server
CN107967150A (en) * 2017-12-19 2018-04-27 郑州云海信息技术有限公司 A kind of thread execution order determines method, apparatus, equipment and storage medium
CN109308220A (en) * 2017-07-26 2019-02-05 华为技术有限公司 Shared resource distribution method and device
CN110381124A (en) * 2019-06-28 2019-10-25 苏州浪潮智能科技有限公司 A kind of application method and device for locking resource
CN110688102A (en) * 2019-09-29 2020-01-14 北京浪潮数据技术有限公司 Method, system, device and storage medium for capturing execution result of asynchronous interface
CN110865977A (en) * 2019-11-05 2020-03-06 中盈优创资讯科技有限公司 Method and device for operating HDFS directory by multiple programs
WO2021042825A1 (en) * 2019-09-03 2021-03-11 苏宁云计算有限公司 Multi-camera synchronization method and distributed system
CN118093348A (en) * 2024-04-07 2024-05-28 荣耀终端有限公司 Critical thread identification method and thread optimization method during application starting

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005096149A1 (en) * 2004-04-02 2005-10-13 Symbian Software Limited Improvements in or relating to an operating system for a computing device
CN1983193A (en) * 2005-12-12 2007-06-20 国际商业机器公司 System and method for processing information
US7886300B1 (en) * 2006-09-26 2011-02-08 Oracle America, Inc. Formerly Known As Sun Microsystems, Inc. Mechanism for implementing thread synchronization in a priority-correct, low-memory safe manner
CN103902732A (en) * 2014-04-18 2014-07-02 北京大学 Construction and network resource collection method of self-adaption network resource collection system
CN103984598A (en) * 2013-02-07 2014-08-13 宏达国际电子股份有限公司 Method and electronic device for thread scheduling
CN104303149A (en) * 2012-02-23 2015-01-21 高通股份有限公司 Method and system for scheduling requests in a portable computing device
US9003413B1 (en) * 2009-09-28 2015-04-07 Xilinx, Inc. Thread synchronization by transitioning threads to spin lock and sleep state
CN105408873A (en) * 2013-05-02 2016-03-16 微软技术许可有限责任公司 Activity based sampling of diagnostics data
EP3005110A1 (en) * 2013-05-31 2016-04-13 Microsoft Technology Licensing, LLC Efficient priority-aware thread scheduling

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005096149A1 (en) * 2004-04-02 2005-10-13 Symbian Software Limited Improvements in or relating to an operating system for a computing device
CN1973266A (en) * 2004-04-02 2007-05-30 西姆毕恩软件有限公司 Improvements in or relating to an operating system for a computing device
CN1983193A (en) * 2005-12-12 2007-06-20 国际商业机器公司 System and method for processing information
US7886300B1 (en) * 2006-09-26 2011-02-08 Oracle America, Inc. Formerly Known As Sun Microsystems, Inc. Mechanism for implementing thread synchronization in a priority-correct, low-memory safe manner
US9003413B1 (en) * 2009-09-28 2015-04-07 Xilinx, Inc. Thread synchronization by transitioning threads to spin lock and sleep state
CN104303149A (en) * 2012-02-23 2015-01-21 高通股份有限公司 Method and system for scheduling requests in a portable computing device
CN103984598A (en) * 2013-02-07 2014-08-13 宏达国际电子股份有限公司 Method and electronic device for thread scheduling
CN105408873A (en) * 2013-05-02 2016-03-16 微软技术许可有限责任公司 Activity based sampling of diagnostics data
EP3005110A1 (en) * 2013-05-31 2016-04-13 Microsoft Technology Licensing, LLC Efficient priority-aware thread scheduling
CN103902732A (en) * 2014-04-18 2014-07-02 北京大学 Construction and network resource collection method of self-adaption network resource collection system

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106372179A (en) * 2016-08-31 2017-02-01 上海爱数信息技术股份有限公司 Method and system for detecting document change and synchronization
CN106372179B (en) * 2016-08-31 2020-04-03 上海爱数信息技术股份有限公司 Method and system for detecting document change and synchronization
CN106775974B (en) * 2016-12-07 2019-12-10 国云科技股份有限公司 Method for realizing distributed priority queuing lock
CN106775974A (en) * 2016-12-07 2017-05-31 国云科技股份有限公司 A kind of implementation method of distributed priority queuing lock
CN107133092A (en) * 2017-05-24 2017-09-05 努比亚技术有限公司 Multi-thread synchronization processing method, terminal and computer-readable recording medium
CN107147922A (en) * 2017-06-20 2017-09-08 深圳市茁壮网络股份有限公司 Frequency resource allocation methods and frequency resource management server
CN107147922B (en) * 2017-06-20 2019-06-18 深圳市茁壮网络股份有限公司 Frequency point resource allocation methods and frequency point resource management server
CN109308220A (en) * 2017-07-26 2019-02-05 华为技术有限公司 Shared resource distribution method and device
CN107967150A (en) * 2017-12-19 2018-04-27 郑州云海信息技术有限公司 A kind of thread execution order determines method, apparatus, equipment and storage medium
CN107967150B (en) * 2017-12-19 2021-10-15 郑州云海信息技术有限公司 Method, device, equipment and storage medium for determining thread execution sequence
CN110381124A (en) * 2019-06-28 2019-10-25 苏州浪潮智能科技有限公司 A kind of application method and device for locking resource
WO2021042825A1 (en) * 2019-09-03 2021-03-11 苏宁云计算有限公司 Multi-camera synchronization method and distributed system
CN110688102A (en) * 2019-09-29 2020-01-14 北京浪潮数据技术有限公司 Method, system, device and storage medium for capturing execution result of asynchronous interface
CN110688102B (en) * 2019-09-29 2022-03-22 北京浪潮数据技术有限公司 Method, system, device and storage medium for capturing execution result of asynchronous interface
CN110865977A (en) * 2019-11-05 2020-03-06 中盈优创资讯科技有限公司 Method and device for operating HDFS directory by multiple programs
CN118093348A (en) * 2024-04-07 2024-05-28 荣耀终端有限公司 Critical thread identification method and thread optimization method during application starting

Also Published As

Publication number Publication date
CN105893120B (en) 2019-07-30

Similar Documents

Publication Publication Date Title
CN105893120A (en) Acquisition method and device for thread synchronization resources
US9027027B2 (en) Thread management based on device power state
CN103426072B (en) The order processing system of a kind of high concurrent competition stock and disposal route thereof
CN106293950B (en) A kind of resource optimization management method towards group system
US9135085B2 (en) Exclusive control method of resource and exclusive controller of resource
US12056540B2 (en) Generic concurrency restriction
CN110213371A (en) Information consumption method, apparatus, equipment and computer storage medium
US8375228B2 (en) Multiple-node system power utilization management
CN106021468B (en) The update method and system of distributed caching and local cache
CN108073684A (en) A kind of data processing method, server and computer readable storage medium
CN106681811A (en) Multi-thread scheduling method and device based on thread pool
CN101566977A (en) Method, device and system of processor accessing shared data
CN106294198B (en) A kind of memory allocation method and method for releasing of (SuSE) Linux OS
CN102006297B (en) Two-level policy decision-based access control method and system
CN112241400A (en) Method for realizing distributed lock based on database
CN105718474A (en) Method and device for controlling concurrent operation of MySQL database
CN109871273A (en) A kind of adaptive task moving method and device
CN104063283B (en) A kind of resource regulating method of explorer
CN105141589B (en) A kind of token of more examples shares the method and system with safeguarding
CN106354801A (en) Distributed database connection method and device
CN107491350B (en) Interface task call method and device
CN113448701A (en) Multi-process outbound control method, system, electronic equipment and storage medium
CN102779058A (en) Interface data loading device and interface data loading method
CN106095577B (en) The optimized treatment method and device of shared drive based on multichannel process device
CN102662632A (en) Serial number generation method based on semaphore and generator.

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant