CN110032434A - A kind of method of adjustment and device of semaphore license - Google Patents

A kind of method of adjustment and device of semaphore license Download PDF

Info

Publication number
CN110032434A
CN110032434A CN201910187874.5A CN201910187874A CN110032434A CN 110032434 A CN110032434 A CN 110032434A CN 201910187874 A CN201910187874 A CN 201910187874A CN 110032434 A CN110032434 A CN 110032434A
Authority
CN
China
Prior art keywords
license
thread
parameter
semaphore
thread pool
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.)
Pending
Application number
CN201910187874.5A
Other languages
Chinese (zh)
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201910187874.5A priority Critical patent/CN110032434A/en
Publication of CN110032434A publication Critical patent/CN110032434A/en
Pending legal-status Critical Current

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/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/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)

Abstract

The embodiment of the present application discloses the method for adjustment and device of a kind of semaphore license, this method is suitable for Business Process Optimizing, this method comprises: obtaining the task quantity in the license waiting list in subject thread pond, and it obtains and the matched first semaphore parameter in the subject thread pond, when the task quantity is greater than preset targets threshold and the corresponding first borrow parameter of institute's the first semaphore parameter is to be, obtain the licensed number to be borrowed in the subject thread pond, obtain semaphore parameter group belonging to the first semaphore parameter, and M third semaphore parameter is determined from N number of second signal amount parameter of the semaphore parameter group, licensed number to be borrowed is somebody's turn to do to borrowing with the matched M thread pool request of the M third semaphore parameter, and call borrow to license indicated by idle thread handle the license etc. in the subject thread pond To the task in queue.Using the embodiment of the present application, the license of thread pool can be adjusted by semaphore parameter.

Description

A kind of method of adjustment and device of semaphore license
Technical field
The method of adjustment and device permitted this application involves field of computer technology more particularly to a kind of semaphore.
Background technique
Current most task is all to be handled by the thread in thread pool, and generally configuring thread pool After parameters, dynamically the parameters of thread pool cannot be adjusted.If thinking the parameter of adjustment thread pool, it is necessary to weight Newly configure this thread pool.When some task needs to call the thread process in thread pool, if do not had in thread pool at this time Idle thread, then the task will be sequentially stored in the license waiting list of the thread pool, to wait in thread pool When there is idle thread, the idle thread occurred in the thread pool is called to handle this task.If in some time thread pool It is all slow without the speed of the idle thread processing task in idle thread or thread pool, then the license waiting list of the thread pool In there may be a large amount of waiting tasks, it is low that this will lead to the waiting for a long time of task, treatment effeciency.
Summary of the invention
The embodiment of the present application provides the method for adjustment and device of a kind of semaphore license, can be adjusted by semaphore parameter The license of thread pool reduces the waiting time of task, improves the treatment effeciency of task.
In a first aspect, the embodiment of the present application provides a kind of method of adjustment of semaphore license, this method comprises:
The task quantity in the license waiting list in subject thread pond is obtained, and is obtained and the subject thread pond matched the One semaphore parameter, the license waiting list for storing task to be processed, the first semaphore parameter be used to indicate this The quantity of the license of one thread pool, the license are used to indicate the idle thread in thread pool;
When the task quantity is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter is When being, the licensed number to be borrowed in the subject thread pond is obtained, which is used to indicate whether thread pool allows to borrow With the license of other thread pools;
Semaphore parameter group belonging to the first semaphore parameter is obtained, and is believed from N number of the second of the semaphore parameter group Number amount parameter in determine M third semaphore parameter, wherein third semaphore parameter it is corresponding second borrow parameter be it is yes, this Whether the license that the second borrow parameter is used to indicate thread pool allows to be borrowed by other thread pools, and M is less than or equal to N;
It is somebody's turn to do licensed number to be borrowed to borrowing with the matched M thread pool request of the M third semaphore parameter, and is called Idle thread indicated by the license borrowed in the M thread pool handles appointing in the license waiting list in the subject thread pond Business.
With reference to first aspect, in a kind of possible embodiment, to this M third semaphore parameter matched M Thread pool request borrows the license of the licensed number to be borrowed, comprising:
It obtains and the M matched M thread pool of third semaphore parameter, one of semaphore parameter and a thread Pond matching;For any thread pool i in the M thread pool, when with indicated by the matched third semaphore parameter of thread pool i License quantity be greater than zero when, to thread pool i request borrow the matched third semaphore parameter of thread pool i indicated by One or more license;It should stop borrowing license, and trigger when borrowing licensed number when the quantity of the license borrowed is equal to It executes the license for calling idle thread indicated by the license borrowed in the M thread pool to handle the subject thread pond and waits team Task in column.
With reference to first aspect, in a kind of possible embodiment, to this M third semaphore parameter matched M Thread pool request borrows the license of the licensed number to be borrowed, comprising:
Count in the M third semaphore parameter the of third semaphore parameter of the quantity greater than zero of indicated license One quantity;This is borrowed wait borrowing licensed number and be determined as first into the value obtained after one divided by the resulting quotient of the first quantity Use quantity;It obtains and the M matched M thread pool of third semaphore parameter, one of semaphore parameter and a thread Pond matching;Each thread pool request into the M thread pool borrows the license of the first borrow quantity;When the license borrowed Quantity be greater than or equal to should when borrowing licensed number, stop borrow license, and trigger execution call the M thread pool in borrow Idle thread indicated by the license used handles the task in the license waiting list in the subject thread pond.
With reference to first aspect, in a kind of possible embodiment, the license institute that borrows in calling the M thread pool After the idle thread of instruction handles the task in the license waiting list in the subject thread pond, this method further include: obtaining should The time is given back in each license borrowed;Discharge the borrow to each license in reach and give back indicated by the license of time Idle thread, and give back the license that the time is given back in the arrival.
With reference to first aspect, in a kind of possible embodiment, the licensed number to be borrowed in the subject thread pond is obtained, It include: to obtain preset percent value;The product for calculating the task quantity and the percent value, the value after which is rounded are true It is set to the licensed number to be borrowed in the subject thread pond.
Second aspect, the embodiment of the present application provide a kind of adjustment device of semaphore license, which includes:
First obtains module, the task quantity in license waiting list for obtaining subject thread pond, and obtains and be somebody's turn to do The matched first semaphore parameter in subject thread pond, the license waiting list is for storing task to be processed, first signal Amount parameter is used to indicate the quantity of the license in the first thread pond, which is used to indicate the idle thread in thread pool;
Second obtains module, for when the task quantity is greater than preset targets threshold and the first semaphore parameter corresponds to The first borrow parameter be when being, to obtain the licensed number to be borrowed in the subject thread pond, which is used to indicate Whether thread pool allows to borrow the license of other thread pools;
Third obtains module, for obtaining semaphore parameter group belonging to the first semaphore parameter, and from the semaphore M third semaphore parameter is determined in N number of second signal amount parameter of parameter group, wherein third semaphore parameter corresponding Two borrow parameters be it is yes, whether this second borrows parameter and is used to indicate the license of thread pool and allow to be borrowed by other thread pools, and M is small In or equal to N;
Module is borrowed, for being somebody's turn to do to the matched M thread pool request borrow of the M third semaphore parameter wait borrow perhaps Can quantity, and idle thread indicated by the license borrowed in the M thread pool is called to handle the license in the subject thread pond Task in waiting list.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned borrow module is specifically used for: obtaining and the M The matched M thread pool of third semaphore parameter, one of semaphore parameter are matched with a thread pool;For the M line Any thread pool i of Cheng Chizhong, when with the quantity of license indicated by the matched third semaphore parameter of thread pool i be greater than zero When, it requests to borrow the license of one or more indicated by the matched third semaphore parameter of thread pool i to thread pool i;When The quantity of the license borrowed, which was equal to, to be stopped borrowing license, and call and borrow in the M thread pool when borrowing licensed number To license indicated by idle thread handle the subject thread pond license waiting list in task.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned borrow module is specifically used for: counting the M the First quantity of third semaphore parameter of the quantity of indicated license greater than zero in three semaphore parameters;This is waited borrowing and is permitted Can quantity divided by the resulting quotient of the first quantity be determined as the first borrow quantity into the value obtained after one;It obtains and the M The matched M thread pool of third semaphore parameter, one of semaphore parameter are matched with a thread pool;To the M thread Each thread pool request in pond borrows the license of the first borrow quantity;It is somebody's turn to do when the quantity of the license borrowed is greater than or equal to When borrowing licensed number, stop borrowing license, and call idle thread indicated by the license borrowed in the M thread pool Handle the task in the license waiting list in the subject thread pond.
In conjunction with second aspect, in a kind of possible embodiment, the device further include: the 4th obtains module, is used for Idle thread indicated by the license borrowed in the M thread pool is called to handle in the license waiting list in the subject thread pond Task after, obtain the borrow to each license give back the time;Module is given back, each is permitted for discharge that the borrow arrives It middle can reach and give back idle thread indicated by the license of time, and give back the license that the time is given back in the arrival.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned second acquisition module is specifically used for: when the task It is when being, to obtain preset hundred that quantity, which is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter, Divide ratio;The product for calculating the task quantity and the percent value, the value after which is rounded are determined as the subject thread pond Licensed number to be borrowed.
The third aspect, the embodiment of the present application provide a kind of terminal, including processor and memory, the processor and storage Device is connected with each other, wherein the memory is used to store the computer program for supporting terminal to execute the above method, the computer program Including program instruction, which is configured for calling the program instruction, executes the semaphore license of above-mentioned first aspect Method of adjustment.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, which deposits Computer program is contained, which includes program instruction, which makes the processor when being executed by a processor Execute the method for adjustment of the semaphore license of above-mentioned first aspect.
Task quantity in license waiting list of the embodiment of the present application by obtaining subject thread pond, and obtain and the mesh The matched first semaphore parameter of thread pool is marked, when the task quantity is greater than preset targets threshold and institute's first semaphore ginseng The corresponding first borrow parameter of number is when being, to obtain the licensed number to be borrowed in the subject thread pond, obtain first semaphore Semaphore parameter group belonging to parameter, and M third letter is determined from N number of second signal amount parameter of the semaphore parameter group Number amount parameter, to the M third semaphore parameter matched M thread pool request borrow licensed number to be borrowed, and adjust The idle thread indicated by the license borrowed in the M thread pool is handled in the license waiting list in the subject thread pond Task can adjust the license of thread pool by semaphore parameter, reduce the waiting time of task, improve the processing effect of task Rate.
Detailed description of the invention
Technical solution in ord to more clearly illustrate embodiments of the present application, below will be to needed in embodiment description Attached drawing is briefly described, it should be apparent that, the accompanying drawings in the following description is some embodiments of the present application, general for this field For logical technical staff, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a schematic flow diagram of the method for adjustment of semaphore license provided by the embodiments of the present application;
Fig. 2 is the schematic diagram of semaphore database provided by the embodiments of the present application;
Fig. 3 is another schematic flow diagram of the method for adjustment of semaphore license provided by the embodiments of the present application;
Fig. 4 is the schematic diagram provided by the embodiments of the present application for borrowing record;
Fig. 5 is a schematic block diagram of the adjustment device of semaphore license provided by the embodiments of the present application;
Fig. 6 is a schematic block diagram of terminal provided by the embodiments of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete Site preparation description, it is clear that described embodiment is some embodiments of the present application, instead of all the embodiments.Based on this Shen Please in embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall in the protection scope of this application.
It should be appreciated that the description and claims of this application and term " first " in the attached drawing, " second ", " third " etc. is not use to describe a particular order for distinguishing different objects.In addition, term " includes " and " having " and Their any deformations, it is intended that cover and non-exclusive include.Such as contain a series of steps or units process, method, System, product or equipment are not limited to listed step or unit, but optionally further comprising the step of not listing or Unit, or optionally further comprising other step or units intrinsic for these process, methods, product or equipment.
It is also understood that referenced herein " embodiment " it is meant that describe in conjunction with the embodiments special characteristic, structure or Characteristic may be embodied at least one embodiment of the application.Each position in the description shows that the phrase might not Identical embodiment is each meant, nor the independent or alternative embodiment with other embodiments mutual exclusion.Those skilled in the art Member explicitly and implicitly understands that embodiment described herein can be combined with other embodiments.
It will be further appreciated that the term "and/or" used in present specification and the appended claims is Refer to any combination and all possible combinations of one or more of associated item listed, and including these combinations.
Below in conjunction with Fig. 1 to Fig. 6, the method for adjustment and device of semaphore provided by the embodiments of the present application license are carried out Explanation.
It is a schematic flow diagram of the method for adjustment of semaphore license provided by the embodiments of the present application referring to Fig. 1.Such as Fig. 1 Shown, the method for adjustment of semaphore license may include step:
S101 obtains the task quantity in the license waiting list in subject thread pond, and obtains and match with subject thread pond The first semaphore parameter.
In some possible embodiments, above-mentioned subject thread pond can be any thread pool in terminal.Terminal is every It receives with the presence or absence of idle thread in the corresponding thread pool of task type that a task can detect the task, if at this time Idle thread is not present in the thread pool, then the task order is stored in the license waiting list of the thread pool.Terminal can Periodically to count the task quantity permitted in waiting list in (such as every 10 minutes statistics primary) subject thread pond, and can be from pre- If semaphore database in obtain with the matched first semaphore parameter in the subject thread pond.Wherein, license waiting list can Task to be processed for storage, the first semaphore parameter can serve to indicate that the quantity of the license in first thread pond, license It can serve to indicate that the idle thread in thread pool.May include in preset semaphore database thread pool, semaphore parameter, Borrow the information such as parameter, semaphore parameter group.One thread pool can be matched with a semaphore parameter.Semaphore parameter is signified The quantity for the license shown is greater than or equal to 0, and the quantity of license indicated by semaphore parameter is matched equal to the semaphore parameter Thread pool in idle thread quantity.
For example, as shown in Fig. 2, being the schematic diagram of semaphore database provided by the embodiments of the present application.Wherein, it first borrows Parameter can serve to indicate that whether this thread pool allows to borrow the license of other thread pools;Second borrow parameter is used to indicate this line Whether the license of Cheng Chizhong allows to be borrowed by other thread pools.It include multiple semaphore parameters, such as signal in semaphore parameter group Measure includes semaphore parameter SA1, SA2 and SA3 in parameter group SPS_A.Assuming that subject thread pond is A3, then terminal is from semaphore It is obtained and the matched first semaphore parameter SA3 of thread pool A3 in database.
S102, when task quantity is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter is When being, the licensed number to be borrowed in subject thread pond is obtained.
In some possible embodiments, terminal can periodically detect (detection in such as every 10 minutes is primary) above-mentioned number of tasks Whether amount is greater than preset targets threshold.When detecting that the task quantity is greater than the targets threshold, then terminal can be from default Semaphore database in obtain above-mentioned first semaphore parameter corresponding first and borrow parameter, and can detecte first signal Measuring parameter corresponding first and borrowing parameter is yes/no.When the corresponding first borrow parameter of the first semaphore parameter is to be, Illustrate that above-mentioned subject thread pond allows to borrow the license of other thread pools, then the available above-mentioned subject thread pond of terminal wait borrow Use licensed number.When detecting that the task quantity is less than or equal to the targets threshold, then terminal can be without any processing, etc. Whether the task quantity in license waiting list to detect above-mentioned subject thread pond next time is greater than the preset targets threshold. When it is no that the first semaphore parameter corresponding first, which borrows parameter, illustrate that above-mentioned subject thread pond does not allow to borrow other lines The license of Cheng Chi calls the target when then terminal can wait the quantity of license indicated by the first semaphore parameter to be greater than 0 Idle thread indicated by license in thread pool handles the task in above-mentioned license waiting list.One idle thread can be located Manage a task.Wherein, targets threshold can be the maximum waiting task quantity of the preset thread pool of terminal, such as targets threshold It is 20.Licensed number to be borrowed can be preset for terminal, if the licensed number to be borrowed in subject thread pond is 10.Terminal In the licensed number to be borrowed of each thread pool can be identical, can not also be identical, if terminal is that thread pool A1 is preset wait borrow It is 10 with licensed number, be the preset licensed number to be borrowed of thread pool A3 is 15 etc..
In some possible embodiments, terminal detect above-mentioned task quantity be greater than preset targets threshold and on Stating the corresponding first borrow parameter of the first semaphore parameter is when being, when can count the processing of each task in a period of time It is long, and the average treatment duration of task in this time can be calculated.Terminal available preset task maximum waiting time, And can be according to the average treatment duration, counting waiting time in above-mentioned license waiting list is more than the task maximum waiting time Task quantity, which can be determined as the licensed number to be borrowed in above-mentioned subject thread pond by terminal.For example, it is assumed that one The section time is in 1 hour before current time.In 1 hour before terminal statistics current time when the processing of each task It is long and 2 minutes a length of when the average treatment of task in 1 hour before calculating current time.Assuming that preset task maximum etc. When it is 30 minutes a length of, permit waiting list in task quantity be 20.Terminal calculating task quantity 20 and average treatment Product between duration 2 minutes 20*2=40 minutes, by the product 40 minutes between 30 minutes task maximum waiting times Difference (40-30=10 minutes) divided by average treatment duration 2 minutes resulting quotient (10/2=5) into the value (5 after one It is a) it is determined as the licensed number to be borrowed in subject thread pond, i.e., 5.
S103 obtains semaphore parameter group belonging to the first semaphore parameter, and believes from N number of the second of semaphore parameter group Number amount parameter in determine M third semaphore parameter.
In some possible embodiments, terminal can obtain above-mentioned first signal from preset semaphore database Semaphore parameter group belonging to parameter is measured, may include the first semaphore parameter and N number of second in the semaphore parameter group Semaphore parameter.Terminal can detecte each second signal amount parameter pair in N number of second signal parameter of the semaphore parameter group It is yes/no that second answered, which borrows parameter, and it is yes for can borrowing parameter in N number of second signal amount parameter corresponding second Second signal amount parameter be determined as third semaphore parameter, obtain M third semaphore parameter.Second borrow parameter can be used Whether the license in this thread pool of instruction allows to be borrowed by other thread pools.M can be less than or equal to N, M and N all can be Integer more than or equal to 1.
For example, it is assumed that the first semaphore parameter is SA1, semaphore parameter group belonging to the first semaphore parameter is SPS_A, It include this 2 second signal amount parameters of SA2, SA3 in semaphore parameter group SPS_A.Terminal detects second signal amount parameter respectively The corresponding second borrow parameter of SA2 is yes/no, the corresponding second borrow parameter of SA3 is yes/no.Since second signal amount is joined Number SA2 it is corresponding second borrow parameter be it is yes, then SA2 is determined as a third semaphore parameter;Second signal amount parameter SA3 Corresponding second borrow parameter be also it is yes, SA3 is determined as another third semaphore parameter, obtains 2 third semaphores ginseng Number.
S104 borrows licensed number to be borrowed to the matched M thread pool request of M third semaphore parameter, and adjusts Appointing in the license waiting list of the idle thread processing target thread pool indicated by the license borrowed in M thread pool Business.
In some possible embodiments, terminal is after determining M third semaphore parameter, can be from preset Each matched thread of third semaphore parameter with above-mentioned M third semaphore parameter is obtained in semaphore database respectively Pond obtains M thread pool.One of semaphore parameter can be matched with a thread pool.For appointing in the M thread pool One thread pool i, when being greater than zero with the quantity of license indicated by the matched third semaphore parameter of thread pool i, terminal can To borrow one or more licenses to thread pool i.When with license indicated by the matched third semaphore parameter of thread pool i Quantity when being equal to zero, terminal can the thread pool in addition to thread pool i into the M thread pool borrow one or more License.Terminal can detecte the quantity of the license borrowed after any one thread pool into the M thread pool borrows license Whether above-mentioned licensed number to be borrowed is equal to.When detect borrow to license quantity be equal to should when borrowing licensed number, Then terminal can stop other thread pools into the M thread pool and (herein refer to the thread not being borrowed in M thread pool Pond) license is borrowed, and idle thread indicated by the license borrowed from the M thread pool can be called to handle above-mentioned target Task in the license waiting list of thread pool.One idle thread can handle a task.When detecting that borrow arrived permitted Can quantity be less than should when borrowing licensed number, then terminal can be removed into the M thread pool thread pool that was borrowed it Outer any thread pool borrows one or more licenses, until the quantity of the license borrowed be equal to be somebody's turn to do licensed number to be borrowed or When the M thread pool, which all borrows, to be finished, stop borrowing license.Task of the embodiment of the present application in license waiting list When quantity is excessive, to the license for allowing other thread pools borrowed to borrow the license of licensed number to be borrowed, and borrow is called to arrive Task in indicated idle thread processing license waiting list, can be effectively relieved the caching pressure of license waiting list, And the waiting time of task can be reduced, improve the treatment effeciency of task.
For example, it is assumed that third semaphore parameter includes SA2, SA3, M=2 at this time.Assuming that licensed number to be borrowed is 5.Eventually End obtains and the matched thread pool A2 of third semaphore parameter SA2 and third semaphore parameter respectively from semaphore database The matched thread pool A3 of SA3.Terminal obtains the quantity (i.e. the value of SA2) of license indicated by third semaphore parameter SA2, it is assumed that The quantity of license indicated by third semaphore parameter SA2 is 3.The number of the license as indicated by third semaphore parameter SA2 Amount 3 is greater than 0, and the difference 5 between the quantity 0 of total licensed number to be borrowed 5 and the license currently borrowed is signified greater than SA2 The quantity 3 for the license shown, terminal borrow the quantity license of license indicated by SA2 to thread pool A2, that is, borrow 3 licenses. Terminal detect borrow to licensed number 3 be less than licensed number 5 to be borrowed, obtain third semaphore parameter SA3 indicated by The quantity (i.e. the value of SA3) of license, it is assumed that the quantity of license indicated by third semaphore parameter SA3 is 4.Due to third signal The quantity 4 for measuring license indicated by parameter SA3 is greater than 0, obtains total licensed number to be borrowed 5 and the current license borrowed Difference 5-3=2 between quantity 3.Since this difference 2 is less than 4, then the difference license is borrowed to thread pool A3, that is, borrow 2 A license.Terminal detect at this time borrow to licensed number 3+2=5 be equal to licensed number 5 to be borrowed, then stop borrow permitted Can, and borrow from thread pool A2 3 licenses are dispatched to any 3 tasks in license waiting list, in order to call Idle thread in thread pool A2 handles this 3 tasks;Borrow from thread pool A3 2 licenses are dispatched to license and wait team Any 2 tasks in column, in order to call the idle thread in thread pool A3 to handle this 2 tasks.Wherein, a task point Send a license.
In the embodiment of the present application, the task quantity in license waiting list of the terminal by obtaining subject thread pond, and Obtain with the matched first semaphore parameter in the subject thread pond, when the task quantity be greater than preset targets threshold and institute this The corresponding first borrow parameter of one semaphore parameter is when being, to obtain the licensed number to be borrowed in the subject thread pond, and obtaining should Semaphore parameter group belonging to first semaphore parameter, and determined from N number of second signal amount parameter of the semaphore parameter group M third semaphore parameter out, should be wait borrow perhaps to borrowing with the matched M thread pool request of the M third semaphore parameter Can quantity, and idle thread indicated by the license borrowed in the M thread pool is called to handle the license in the subject thread pond Task in waiting list can adjust the license of thread pool by semaphore parameter, reduce the waiting time of task, improve and appoint The treatment effeciency of business.
It is another schematic flow diagram of the method for adjustment of semaphore license provided by the embodiments of the present application referring to Fig. 3.Such as figure Shown in 3, the method for adjustment of semaphore license may include step:
S301 obtains the task quantity in the license waiting list in subject thread pond, and obtains and match with subject thread pond The first semaphore parameter.
In some possible embodiments, the step S301 of the embodiment of the present application can refer to the step of embodiment illustrated in fig. 1 The implementation of rapid S101, details are not described herein.
S302, when task quantity is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter is When being, preset percent value is obtained.
S303, the product of calculating task quantity and percent value, the value after product is rounded are determined as subject thread pond Licensed number to be borrowed.
In some possible embodiments, terminal can periodically detect whether above-mentioned task quantity is greater than preset target Threshold value.When detecting that the task quantity is greater than the targets threshold, then terminal can be obtained from preset semaphore database Above-mentioned first semaphore parameter corresponding first borrows parameter, and can detecte the first semaphore parameter corresponding first and borrow Parameter is yes/no.When the corresponding first borrow parameter of the first semaphore parameter is to be, illustrate that above-mentioned subject thread pond permits Perhaps borrow the license of other thread pools, then the available preset percent value of terminal, and can calculate above-mentioned task quantity with Product between the percent value, the value after which is rounded are determined as the licensed number to be borrowed in above-mentioned subject thread pond.
For example, it is assumed that preset percent value is 90%, the task quantity in the license waiting list in subject thread pond is 15, then terminal calculates the value [13.5] after the product 15*90%=13.5 between percent value 90% and task quantity 15 is rounded =13, this value 13 is determined as to the licensed number to be borrowed in subject thread pond.[x] indicates to take the integer part of x.
S304 obtains semaphore parameter group belonging to the first semaphore parameter, and believes from N number of the second of semaphore parameter group Number amount parameter in determine M third semaphore parameter.
In some possible embodiments, the step S304 of the embodiment of the present application can refer to the step of embodiment illustrated in fig. 1 The implementation of rapid S103, details are not described herein.
S305 counts the third semaphore parameter that the quantity of license indicated in M third semaphore parameter is not zero The first quantity.
S306 will be determined as first into the value obtained after one divided by the resulting quotient of the first quantity wait borrow licensed number Borrow quantity.
S307 is obtained and the M matched M thread pool of third semaphore parameter.
S308, each thread pool request into M thread pool borrow the first license for borrowing quantity.
S309, when the quantity of the license borrowed is greater than or equal to when borrowing licensed number, stopping borrows license, and adjusts Appointing in the license waiting list of the idle thread processing target thread pool indicated by the license borrowed in M thread pool Business.
In some possible embodiments, terminal can detecte the M after determining M third semaphore parameter Whether the quantity of license indicated by each third semaphore is greater than 0 in a third semaphore parameter, and can count the M the First quantity of third semaphore parameter of the quantity of indicated license greater than 0 in three semaphore parameters.Terminal can calculate The quotient can be determined as into obtaining value after one by above-mentioned licensed number to be borrowed divided by the resulting quotient of the first quantity First borrows quantity.Terminal can obtain and above-mentioned M third semaphore parameter respectively from preset semaphore database Each matched thread pool of third semaphore parameter, obtains M thread pool.One of semaphore parameter can be with a thread Pond matching.Terminal can each thread pool respectively into the M thread pool borrow this first borrow quantity license.Terminal is every After borrowing license to a thread pool, so that it may which whether the quantity for the license that detection borrows is greater than or equal to this wait borrow license Quantity.It is somebody's turn to do when borrowing licensed number when the quantity of the license borrowed is greater than or equal to, then terminal can stop to the M line Other thread pools (herein referring to the thread pool not being borrowed in M thread pool) of Cheng Chizhong borrow license, and can call from Idle thread indicated by the license borrowed in the M thread pool is handled in the license waiting list in above-mentioned subject thread pond Task.One idle thread can handle a task.When detect borrow to license quantity be less than should wait borrow license When quantity, then terminal can the thread pool successively into the M thread pool in addition to the thread pool being borrowed borrow this first The license for borrowing quantity is somebody's turn to do licensed number to be borrowed until the quantity of the license borrowed is greater than or equal to, or until the M When thread pool whole borrow finishes, stop borrowing license.
For example, it is assumed that the first quantity is 5, licensed number to be borrowed is 13.Terminal calculates quantity to be borrowed 13 divided by first This quotient 2.6 is determined as the first borrow quantity into the value 3 obtained after one by the resulting quotient 13/5=2.6 of quantity 5.It is false If in M third semaphore parameter 5 third semaphore parameters of the quantity of indicated license greater than 0 be respectively SD1, SD2, SD3, SD4 and SD5.Terminal obtains and the M matched M thread pool of third semaphore parameter from semaphore data volume.Eventually End successively into M thread pool with the quantity of indicated license be greater than 0 each third semaphore parameter (SD1, SD2, SD3, SD4 and SD5) quantity 3 licenses of matched the first borrow of thread pool borrow.With the matched thread of third semaphore parameter SD1 Pond is D1, is D2 with the matched thread pool of SD2, is D3 with the matched thread pool of SD3, is D4 with the matched thread pool of SD4, with The matched thread pool of SD5 is D5.Terminal obtains the quantity 4 of license indicated by third semaphore parameter SD1, then terminal is to thread Pond D1 borrows first and borrows quantity 3 licenses.The quantity of the license borrowed at this time be 3, due to 3 be less than quantity 13 to be borrowed, Then terminal borrows first to thread pool D2 and borrows quantity 3 licenses.Assuming that the quantity of license indicated by SD2 be 2, then at this time from Thread pool D2, which is only borrowed to 2, to be permitted, the quantity of the license borrowed at this time is 3+2=5.Due to 5 be less than quantity 13 to be borrowed, Then terminal borrows first to thread pool D3 and borrows quantity 3 licenses.Assuming that the quantity of license indicated by SD3 be 3, then at this time from Thread pool D3, which is borrowed to 3, to be permitted, the quantity of the license borrowed at this time is 3+2+3=8.Due to 8 be less than quantity 13 to be borrowed, Then terminal borrows first to thread pool D4 and borrows quantity 3 licenses.Assuming that the quantity of license indicated by SD4 be 5, then at this time from Thread pool D4, which is borrowed to 3, to be permitted, the quantity of the license borrowed at this time is 3+2+3+3=11.Since 11 less than number to be borrowed Amount 13, then terminal borrows first to thread pool D5 and borrows quantity 3 licenses.Assuming that the quantity of license indicated by SD5 is 6, then It borrows from thread pool D5 to 3 and permits at this time, the quantity of the license borrowed at this time is 3+2+3+3+3=14.It is greater than due to 14 Quantity 13 to be borrowed, the then license etc. of 14 indicated idle thread processing target thread pools of 14 licenses for calling borrow to arrive To the task in queue.
S310, obtain each license borrowed gives back the time.
S311 discharges to reach in each license borrowed and gives back idle thread indicated by the license of time, and gives back Reach the license for giving back the time.
In some possible embodiments, each thread pool in above-mentioned M thread pool is provided with when lending license The time is given back in license, and if current time is 17:05, the time that some thread pool allows to lend license is 5 minutes, then this The time of giving back of the license of thread pool lending is 17:10.Terminal can be generated after borrowing to any one thread pool to license Borrow records and stores.It may include borrow side (referring to subject thread pond) in borrow record, the side of being borrowed, borrow quantity, borrow With information such as time, the times of giving back.As shown in figure 4, being the schematic diagram provided by the embodiments of the present application for borrowing record.Wherein, it borrows With the quantity for the license that quantity is used to indicate to borrow, borrowing time is used to indicate the time when side's of being borrowed lending license, returns The also time is for indicating that the time of license is given back by borrow side.Terminal can obtain each license borrowed from borrow record Give back the time, and that detects whether current time reach each license borrowed gives back the time.It is somebody's turn to do when current time reaches When the giving back the time of some license borrowed then discharges arrival and gives back idle thread indicated by the license of time, and give back Reach the license for giving back the time.The embodiment of the present application is when permitting the task quantity in waiting list excessive, to allow to borrow Other thread pools borrow license, and call appointing in the processing license waiting list of idle thread indicated by the license borrowed Business, when the license borrowed give back the time reach when, give back the license of borrow, may be implemented timing borrow license, reduce times The waiting time of business improves treatment effeciency.
In the embodiment of the present application, the task quantity in license waiting list of the terminal by obtaining subject thread pond, and Acquisition and the matched first semaphore parameter in subject thread pond, when task quantity is greater than preset targets threshold and the first semaphore The corresponding first borrow parameter of parameter is to obtain preset percent value when being, the product of calculating task quantity and percent value, Value after product is rounded is determined as the licensed number to be borrowed in subject thread pond, obtains signal belonging to the first semaphore parameter Parameter group is measured, and determines M third semaphore parameter from N number of second signal amount parameter of semaphore parameter group.To with M Each thread pool request in the matched M thread pool of third semaphore parameter borrows a certain number of licenses, when what is borrowed The quantity of license is greater than or equal to when borrowing licensed number, stops borrowing license, and calls what is borrowed in M thread pool to be permitted Task in the license waiting list of idle thread processing target thread pool that can be indicated.Obtain each license borrowed It gives back the time, discharges to reach in each license borrowed and give back idle thread indicated by the license of time, and give back arrival Give back the license of time.Timing may be implemented and borrow license, reduce the waiting time of task, improve treatment effeciency.
It is a schematic block diagram of the adjustment device of semaphore license provided by the embodiments of the present application referring to Fig. 5.Such as Fig. 5 Shown, the adjustment device of the semaphore license of the embodiment of the present application includes:
First obtain module 10, for obtain subject thread pond license waiting list in task quantity, and obtain with The matched first semaphore parameter in the subject thread pond, the license waiting list is for storing task to be processed, first letter Number amount parameter is used to indicate the quantity of the license in the first thread pond, which is used to indicate the idle thread in thread pool;
Second obtains module 20, for being greater than preset targets threshold and the first semaphore parameter pair when the task quantity The the first borrow parameter answered is when being, to obtain the licensed number to be borrowed in the subject thread pond, and the first borrow parameter is for referring to Show whether thread pool allows to borrow the license of other thread pools;
Third obtains module 30, for obtaining semaphore parameter group belonging to the first semaphore parameter, and from the signal It measures in N number of second signal amount parameter of parameter group and determines M third semaphore parameter, wherein third semaphore parameter is corresponding Second borrow parameter be it is yes, whether this second borrows parameter and is used to indicate the license of thread pool and allow to be borrowed by other thread pools, M Less than or equal to N;
Module 40 is borrowed, for being somebody's turn to do to the matched M thread pool request borrow of the M third semaphore parameter wait borrow Licensed number, and idle thread indicated by the license borrowed in the M thread pool is called to handle being permitted for the subject thread pond It may wait for the task in queue.
In some possible embodiments, above-mentioned borrow module 40 is specifically used for: obtaining and joins with the M third semaphore The matched M thread pool of number, one of semaphore parameter are matched with a thread pool;For any in the M thread pool Thread pool i, when being greater than zero with the quantity of license indicated by the matched third semaphore parameter of thread pool i, to the thread I request in pond borrows the license of one or more indicated by the matched third semaphore parameter of thread pool i;When the license borrowed Quantity be equal to should when borrowing licensed number, stop borrow license, and call borrowed in the M thread pool license meaning The idle thread shown handles the task in the license waiting list in the subject thread pond.
In some possible embodiments, above-mentioned borrow module 40 is specifically used for: counting the M third semaphore parameter In indicated license third semaphore parameter of the quantity greater than zero the first quantity;By the licensed number to be borrowed divided by this The resulting quotient of first quantity is determined as the first borrow quantity into the value obtained after one;It obtains and joins with the M third semaphore The matched M thread pool of number, one of semaphore parameter are matched with a thread pool;Each line into the M thread pool Cheng Chi request borrows the license of the first borrow quantity;License count to be borrowed is somebody's turn to do when the quantity of the license borrowed is greater than or equal to When amount, stop borrowing license, and idle thread indicated by the license borrowed in the M thread pool is called to handle the score Task in the license waiting list of Cheng Chi.
In some possible embodiments, which further includes the 4th acquisition module 50 and gives back module 60.This Four obtain module 50, and idle thread indicated by the license for borrowing in calling the M thread pool handles the score After task in the license waiting list of Cheng Chi, obtain the borrow to each license give back the time;This gives back module 60, For discharge the borrow to each license in reach and give back idle thread indicated by the license of time, and give back the arrival and return The also license of time.
In some possible embodiments, above-mentioned second acquisition module 20 is specifically used for: when the task quantity is greater than in advance If the corresponding first borrow parameter of targets threshold and the first semaphore parameter be when being, to obtain preset percent value;Meter The product for calculating the task quantity and the percent value, by the product be rounded after value be determined as the subject thread pond wait borrow perhaps It can quantity.
In the specific implementation, the adjustment device of above-mentioned semaphore license can execute above-mentioned Fig. 1 or Fig. 3 by above-mentioned modules Implementation provided by each step in provided implementation realizes the function of being realized in the various embodiments described above, tool Body can be found in the corresponding description that each step provides in above-mentioned Fig. 1 or embodiment of the method shown in Fig. 3, and details are not described herein.
In the embodiment of the present application, in license waiting list of the adjustment device of semaphore license by obtaining subject thread pond Task quantity, and obtain with the matched first semaphore parameter in the subject thread pond, when the task quantity be greater than preset mesh Mark threshold value and the corresponding first borrow parameter of institute's the first semaphore parameter be when being obtain the subject thread pond wait borrow perhaps Can quantity, obtain semaphore parameter group belonging to the first semaphore parameter, and from N number of second signal of the semaphore parameter group M third semaphore parameter is determined in amount parameter, is borrowed to the matched M thread pool request of the M third semaphore parameter With the licensed number to be borrowed, and idle thread indicated by the license borrowed in the M thread pool is called to handle the target Thread pool license waiting list in task, can by semaphore parameter adjust thread pool license, reduce task etc. To duration, the treatment effeciency of task is improved.
It is a schematic block diagram of terminal provided by the embodiments of the present application referring to Fig. 6.As shown in fig. 6, the embodiment of the present application In terminal may include: one or more processors 601 and memory 602.Above-mentioned processor 601 and memory 602 pass through Bus 603 connects.For memory 602 for storing computer program, the computer program includes program instruction, processor 601 For executing the program instruction of the storage of memory 602.Above-mentioned processor 601 is configured for calling described program instruction execution:
The task quantity in the license waiting list in subject thread pond is obtained, and is obtained and the subject thread pond matched the One semaphore parameter, the license waiting list for storing task to be processed, the first semaphore parameter be used to indicate this The quantity of the license of one thread pool, the license are used to indicate the idle thread in thread pool;
When the task quantity is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter is When being, the licensed number to be borrowed in the subject thread pond is obtained, which is used to indicate whether thread pool allows to borrow With the license of other thread pools;
Semaphore parameter group belonging to the first semaphore parameter is obtained, and is believed from N number of the second of the semaphore parameter group Number amount parameter in determine M third semaphore parameter, wherein third semaphore parameter it is corresponding second borrow parameter be it is yes, this Whether the license that the second borrow parameter is used to indicate thread pool allows to be borrowed by other thread pools, and M is less than or equal to N;
It is somebody's turn to do licensed number to be borrowed to borrowing with the matched M thread pool request of the M third semaphore parameter, and is called Idle thread indicated by the license borrowed in the M thread pool handles appointing in the license waiting list in the subject thread pond Business.
It should be appreciated that in the embodiment of the present application, alleged processor 601 can be central processing unit (Central Processing Unit, CPU), which can also be other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic Device, discrete gate or transistor logic, discrete hardware components etc..General processor can be microprocessor or this at Reason device is also possible to any conventional processor etc..
The memory 602 may include read-only memory and random access memory, and to processor 601 provide instruction and Data.The a part of of memory 602 can also include nonvolatile RAM.For example, memory 602 can also be deposited Store up the information of device type.
In the specific implementation, letter provided by the embodiments of the present application can be performed in processor 601 described in the embodiment of the present application Number amount license method of adjustment described in implementation, also can be performed the embodiment of the present application described in semaphore license The implementation of device is adjusted, details are not described herein.
The embodiment of the present application also provides a kind of computer readable storage medium, which has meter Calculation machine program, the computer program include program instruction, which realizes Fig. 1 or shown in Fig. 3 when being executed by processor The method of adjustment of semaphore license, detail please refer to the description of Fig. 1 or embodiment illustrated in fig. 3, and details are not described herein.
Above-mentioned computer readable storage medium can be the adjustment device of the license of semaphore described in aforementioned any embodiment Or the internal storage unit of electronic equipment, such as the hard disk or memory of electronic equipment.The computer readable storage medium can also be with It is the plug-in type hard disk being equipped on the External memory equipment of the electronic equipment, such as the electronic equipment, intelligent memory card (smart Media card, SMC), secure digital (secure digital, SD) card, flash card (flash card) etc..Further, The computer readable storage medium can also both including the electronic equipment internal storage unit and also including External memory equipment.It should Computer readable storage medium is for other programs and data needed for storing the computer program and the electronic equipment.The meter Calculation machine readable storage medium storing program for executing can be also used for temporarily storing the data that has exported or will export.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware With the interchangeability of software, each exemplary composition and step are generally described according to function in the above description.This A little functions are implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Specially Industry technical staff can use different methods to achieve the described function each specific application, but this realization is not It is considered as beyond scope of the present application.
The application is referring to the method, apparatus of the embodiment of the present application and the flow chart and/or box of computer program product Figure describes.It should be understood that each process and/or the side in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in frame and flowchart and/or the block diagram.These computer program instructions be can provide to logical With the processor of the processing equipments of computer, special purpose computer, Embedded Processor or other programmable diagnosis and treatment data to generate One machine, so that generating use by the instruction that the processor of computer or the processing equipment of other programmable diagnosis and treatment data executes In the dress for realizing the function of specifying in one or more flows of the flowchart and/or one or more blocks of the block diagram It sets.
These computer program instructions, which may also be stored in, to be able to guide processing of computer or other programmable diagnosis and treatment data and sets In standby computer-readable memory operate in a specific manner, so that instruction stored in the computer readable memory generates Manufacture including command device, the command device are realized in one or more flows of the flowchart and/or one, block diagram The function of being specified in box or multiple boxes.
These computer program instructions can also be loaded into the processing equipment of computer or other programmable diagnosis and treatment data, be made It obtains and executes series of operation steps on a computer or other programmable device to generate computer implemented processing, thus counting The instruction executed on calculation machine or other programmable devices is provided for realizing in one or more flows of the flowchart and/or side The step of function of being specified in block diagram one box or multiple boxes.
Although the application is described in conjunction with specific features and embodiment, it is clear that, do not departing from this Shen In the case where spirit and scope please, it can be carry out various modifications and is combined.Correspondingly, the specification and drawings are only institute The exemplary illustration for the application that attached claim is defined, and be considered as covered within the scope of the application any and all and repair Change, change, combining or equivalent.Obviously, those skilled in the art the application can be carried out various modification and variations without It is detached from spirit and scope.If in this way, these modifications and variations of the application belong to the claim of this application and its Within the scope of equivalent technologies, then the application is also intended to include these modifications and variations.

Claims (10)

1. a kind of method of adjustment of semaphore license characterized by comprising
The task quantity in the license waiting list in subject thread pond is obtained, and is obtained and the subject thread pond matched first Semaphore parameter, for the license waiting list for storing task to be processed, the first semaphore parameter is used to indicate institute State the quantity of the license in first thread pond, the idle thread for permitting to be used to indicate in thread pool;
When the task quantity is greater than preset targets threshold and the corresponding first borrow parameter of the first semaphore parameter is When being, the licensed number to be borrowed in the subject thread pond is obtained, the first borrow parameter is used to indicate whether thread pool is permitted Perhaps the license of other thread pools is borrowed;
Semaphore parameter group belonging to the first semaphore parameter is obtained, and is believed from N number of the second of the semaphore parameter group Number amount parameter in determine M third semaphore parameter, wherein third semaphore parameter it is corresponding second borrow parameter is yes, institute Whether allow by other thread pools borrowed, M is less than or equal to N if stating the second borrow parameter and be used to indicate the license of thread pool;
The licensed number to be borrowed is borrowed to the matched M thread pool request of the M third semaphore parameter, and is called Idle thread indicated by the license borrowed in the M thread pool is handled in the license waiting list in the subject thread pond Task.
2. the method according to claim 1, wherein it is described to the matched M of the M third semaphore parameter A thread pool request borrows the license of the licensed number to be borrowed, comprising:
It obtains and the matched M thread pool of M third semaphore parameter, one of semaphore parameter and a thread pool Matching;
For any thread pool i in the M thread pool, when signified with the matched third semaphore parameter of the thread pool i When the quantity for the license shown is greater than zero, Xiang Suoshu thread pool i request borrows one or more licenses;
When the quantity of the license borrowed is equal to described when borrowing licensed number, stop borrowing license, and trigger and execute calling Idle thread indicated by the license borrowed in the M thread pool is handled in the license waiting list in the subject thread pond Task.
3. the method according to claim 1, wherein it is described to the matched M of the M third semaphore parameter A thread pool request borrows the license of the licensed number to be borrowed, comprising:
Count the first of third semaphore parameter of the quantity greater than zero of license indicated in the M third semaphore parameter Quantity;
It is determined as first into the value obtained after one divided by the resulting quotient of the first quantity wait borrow licensed number for described Borrow quantity;
It obtains and the matched M thread pool of M third semaphore parameter, one of semaphore parameter and a thread pool Matching;
Each thread pool request into the M thread pool borrows the described first license for borrowing quantity;
When the quantity of the license borrowed is greater than or equal to described when borrowing licensed number, stop borrowing license, and trigger and hold The license that row calls idle thread indicated by the license borrowed in the M thread pool to handle the subject thread pond waits Task in queue.
4. method according to claim 1-3, which is characterized in that described to be borrowed in calling the M thread pool After idle thread indicated by the license used handles the task in the license waiting list in the subject thread pond, the side Method further include:
Obtain each license borrowed gives back the time;
It discharges to reach in each license borrowed and gives back idle thread indicated by the license of time, and give back described arrive Up to the license for giving back the time.
5. method according to claim 1-4, which is characterized in that it is described obtain the subject thread pond wait borrow With licensed number, comprising:
Obtain preset percent value;
The product for calculating the task quantity and the percent value, the value after the product is rounded are determined as the score The licensed number to be borrowed of Cheng Chi.
6. a kind of adjustment device of semaphore license characterized by comprising
First obtains module, the task quantity in license waiting list for obtaining subject thread pond, and obtains and the mesh The matched first semaphore parameter of thread pool is marked, the license waiting list is for storing task to be processed, first letter Number amount parameter is used to indicate the quantity of the license in the first thread pond, described to permit the idle line that is used to indicate in thread pool Journey;
Second obtains module, for when the task quantity is greater than preset targets threshold and the first semaphore parameter corresponds to The first borrow parameter be to obtain the licensed number to be borrowed in the subject thread pond when being, the first borrow parameter is used for Indicate whether thread pool allows to borrow the license of other thread pools;
Third obtains module, for obtaining semaphore parameter group belonging to the first semaphore parameter, and from the semaphore M third semaphore parameter is determined in N number of second signal amount parameter of parameter group, wherein third semaphore parameter corresponding Two borrow parameters be it is yes, whether described second, which borrows parameter, is used to indicate the license of thread pool allows to be borrowed by other thread pools, M Less than or equal to N;
Module is borrowed, for described wait borrow perhaps to borrowing with the matched M thread pool request of the M third semaphore parameter Can quantity, and idle thread indicated by the license borrowed in the M thread pool is called to handle the subject thread pond Permit the task in waiting list.
7. device according to claim 6, which is characterized in that the borrow module is specifically used for:
It obtains and the matched M thread pool of M third semaphore parameter, one of semaphore parameter and a thread pool Matching;
For any thread pool i in the M thread pool, when signified with the matched third semaphore parameter of the thread pool i When the quantity for the license shown is greater than zero, Xiang Suoshu thread pool i request borrows the matched third semaphore parameter institute of thread pool i One or more licenses of instruction;
When the quantity of the license borrowed is equal to described when borrowing licensed number, stop borrowing license, and call the M line Idle thread indicated by the license that Cheng Chizhong is borrowed handles the task in the license waiting list in the subject thread pond.
8. device according to claim 6, which is characterized in that the borrow module is specifically used for:
Count the first of third semaphore parameter of the quantity greater than zero of license indicated in the M third semaphore parameter Quantity;
It is determined as first into the value obtained after one divided by the resulting quotient of the first quantity wait borrow licensed number for described Borrow quantity;
It obtains and the matched M thread pool of M third semaphore parameter, one of semaphore parameter and a thread pool Matching;
Each thread pool request into the M thread pool borrows the described first license for borrowing quantity;
When the quantity of the license borrowed is greater than or equal to described when borrowing licensed number, stop borrowing license, and call institute Idle thread indicated by the license borrowed in M thread pool is stated to handle in the license waiting list in the subject thread pond Task.
9. a kind of terminal, which is characterized in that including processor and memory, the processor and memory are connected with each other, wherein The memory is for storing computer program, and the computer program includes program instruction, and the processor is configured for Described program instruction is called, the method according to claim 1 to 5 is executed.
10. a kind of computer readable storage medium, which is characterized in that the computer storage medium is stored with computer program, The computer program includes program instruction, and described program instruction makes the processor execute such as right when being executed by a processor It is required that the described in any item methods of 1-5.
CN201910187874.5A 2019-03-12 2019-03-12 A kind of method of adjustment and device of semaphore license Pending CN110032434A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910187874.5A CN110032434A (en) 2019-03-12 2019-03-12 A kind of method of adjustment and device of semaphore license

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910187874.5A CN110032434A (en) 2019-03-12 2019-03-12 A kind of method of adjustment and device of semaphore license

Publications (1)

Publication Number Publication Date
CN110032434A true CN110032434A (en) 2019-07-19

Family

ID=67235907

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910187874.5A Pending CN110032434A (en) 2019-03-12 2019-03-12 A kind of method of adjustment and device of semaphore license

Country Status (1)

Country Link
CN (1) CN110032434A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457126A (en) * 2019-08-13 2019-11-15 杭州有赞科技有限公司 A kind of asynchronous invoking method and system
CN118051346A (en) * 2024-04-11 2024-05-17 恒生电子股份有限公司 Method, device, electronic equipment and readable storage medium for requesting dynamic current limiting

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106155803A (en) * 2015-04-07 2016-11-23 北大方正集团有限公司 A kind of thread pool sharing method based on semaphore and system
CN107220033A (en) * 2017-07-05 2017-09-29 百度在线网络技术(北京)有限公司 Method and apparatus for controlling thread pool thread quantity
CN107463439A (en) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 A kind of thread pool implementation method and device
CN108846632A (en) * 2018-05-28 2018-11-20 浙江口碑网络技术有限公司 Thread processing method and device
CN109271252A (en) * 2018-08-29 2019-01-25 华为技术有限公司 A kind of method and device adjusting Thread Count

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106155803A (en) * 2015-04-07 2016-11-23 北大方正集团有限公司 A kind of thread pool sharing method based on semaphore and system
CN107220033A (en) * 2017-07-05 2017-09-29 百度在线网络技术(北京)有限公司 Method and apparatus for controlling thread pool thread quantity
CN107463439A (en) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 A kind of thread pool implementation method and device
CN108846632A (en) * 2018-05-28 2018-11-20 浙江口碑网络技术有限公司 Thread processing method and device
CN109271252A (en) * 2018-08-29 2019-01-25 华为技术有限公司 A kind of method and device adjusting Thread Count

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457126A (en) * 2019-08-13 2019-11-15 杭州有赞科技有限公司 A kind of asynchronous invoking method and system
CN118051346A (en) * 2024-04-11 2024-05-17 恒生电子股份有限公司 Method, device, electronic equipment and readable storage medium for requesting dynamic current limiting

Similar Documents

Publication Publication Date Title
CN109992414A (en) A kind of task processing method and device based on thread pool
CN110046038A (en) A kind of task processing method and device based on thread pool
CN109034244A (en) Line loss abnormality diagnostic method and device based on electric quantity curve characteristic model
CN109766393A (en) Abnormal deviation data examination method and device
CN109726198A (en) Method for processing abnormal data and device
CN109146855A (en) A kind of image mole marks detection method, terminal device and storage medium
CN110222871A (en) The selection method and device of similar day for load forecast
CN109684311A (en) Abnormal deviation data examination method and device
CN112084096B (en) Cold channel sealing management method and device and terminal equipment
CN105378668A (en) Operating system-managed interrupt steering in multiprocessor systems
CN110032434A (en) A kind of method of adjustment and device of semaphore license
CN115370973B (en) Water supply leakage monitoring method and device, storage medium and electronic equipment
CN109684091B (en) Task processing method and device
CN104603713A (en) Processor having per core and package level p0 determination functionality
CN109597745A (en) Method for processing abnormal data and device
CN110008012A (en) A kind of method of adjustment and device of semaphore license
WO2020224218A1 (en) Hbase-based data writing method, system, device, and readable storage medium
CN110324411A (en) A kind of service shunting method and device
CN107730774A (en) Method, financial machine and tool and the computer-readable recording medium of wholesale deposit
KR101635816B1 (en) Apparatus and method for thread progress tracking using deterministic progress index
KR101892273B1 (en) Apparatus and method for thread progress tracking
CN109447534A (en) A kind of working hour distribution method, device, equipment and storage medium
CN109739838A (en) Method for processing abnormal data and device
CN109741047A (en) Charging system on a kind of line
CN109063926A (en) Plan generated energy determines method, system and terminal device in period

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination