CN113220227B - Method and device for dynamically adjusting sleep duration of information access task - Google Patents
Method and device for dynamically adjusting sleep duration of information access task Download PDFInfo
- Publication number
- CN113220227B CN113220227B CN202110459269.6A CN202110459269A CN113220227B CN 113220227 B CN113220227 B CN 113220227B CN 202110459269 A CN202110459269 A CN 202110459269A CN 113220227 B CN113220227 B CN 113220227B
- Authority
- CN
- China
- Prior art keywords
- continuous
- storage unit
- sleep duration
- value
- sleep
- 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.)
- Active
Links
- 230000004617 sleep duration Effects 0.000 title claims abstract description 109
- 238000000034 method Methods 0.000 title claims abstract description 30
- 238000001514 detection method Methods 0.000 claims abstract description 55
- 230000004622 sleep time Effects 0.000 claims abstract description 50
- 238000004891 communication Methods 0.000 claims description 17
- 238000004590 computer program Methods 0.000 claims description 11
- 230000036578 sleeping time Effects 0.000 claims description 5
- 238000012544 monitoring process Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 12
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 101150039208 KCNK3 gene Proteins 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3206—Monitoring of events, devices or parameters that trigger a change in power modality
- G06F1/3215—Monitoring of peripheral devices
- G06F1/3225—Monitoring of peripheral devices of memory devices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/325—Power saving in peripheral device
- G06F1/3275—Power saving in memory, e.g. RAM, cache
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/067—Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a method and a device for dynamically adjusting sleep duration of an information access task, wherein the method comprises the following steps: detecting whether a first shared storage area for storing information has a free storage unit or not; adjusting a first continuous time when an idle storage unit is detected and a second continuous time when no idle storage unit is detected according to a detection result, and adjusting the sleep time length based on selected parameters in the first continuous time, the second continuous time, the set time, the minimum value and the maximum value; starting a timer based on the sleep duration; and if the timer is monitored to be expired, executing the step of detecting whether a first shared storage area for storing information has a free storage unit. The scheme can realize the dynamic adjustment of the sleep time of the information access task.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for dynamically adjusting a sleep duration of an information access task.
Background
In a network device, at least one shared storage area is usually set, and then information is stored in the shared storage area or is obtained from the shared storage area through at least one information access Task, as shown in fig. 1, which is a schematic diagram of the working principle of the information access Task, the information access Task (Task 1, 2, 3) obtains information from the outside or one shared storage area and then stores the information into another shared storage area, wherein, filled represents a part with information in the shared storage area, and Free represents a part without information in the shared storage area.
In the above information access manner, each shared storage area may include a plurality of shared storage units, each information access task may enter a sleep state after completing access to information that one shared storage unit can accommodate, and after the set sleep duration expires, access to information that another shared storage unit can accommodate is performed.
In this way, the sleep time of each information access task is fixed, and if the information acquisition speed of the next information access task is slower than the information storage speed of the previous information access task, the shared storage area will be consumed within a period of time, and newly acquired information is discarded because the newly acquired information cannot be stored in the shared storage unit, which may cause a system memory shortage and crash in severe cases. Therefore, a method for dynamically adjusting the sleep duration of an information access task is needed.
Disclosure of Invention
The embodiment of the invention provides a method and a device for dynamically adjusting sleep time of an information access task, which are used for dynamically adjusting the sleep time of the information access task.
According to the embodiment of the invention, a method for dynamically adjusting sleep duration of an information access task is provided, which is applied to each information access task included in network equipment and comprises the following steps:
detecting whether a first shared storage area for storing information has a free storage unit or not;
adjusting a first continuous frequency of detecting an idle storage unit and a second continuous frequency of detecting no idle storage unit according to a detection result, and adjusting the sleeping time length based on selected parameters in the first continuous frequency, the second continuous frequency, a set frequency, a minimum value and a maximum value;
starting a timer based on the sleep duration;
and if the timer is monitored to expire, executing the step of detecting whether the first shared storage area for storing the information has a free storage unit.
Specifically, detecting whether a first shared storage area for storing information has an idle storage unit specifically includes:
determining whether the number of first used storage units in a first shared storage area reaches the maximum number of storage units in the first shared storage area;
if the number of the first used storage units is determined to reach the maximum storage unit number, the detection result is no idle storage unit;
and if the number of the first used storage units is determined not to reach the maximum storage unit number, the detection result is that idle storage units exist.
Optionally, before starting the timer based on the sleep duration, the method further includes:
if the information to be stored is obtained from the outside, storing the information to be stored into the first shared storage area, and adding 1 to the number of the first used storage units; or,
and if the information to be stored is acquired from a second shared storage area, subtracting 1 from the number of second used storage units in the second shared storage area, and adding 1 to the number of first used storage units.
Specifically, adjusting a first continuous time for detecting an idle storage unit and a second continuous time for detecting no idle storage unit according to a detection result, and adjusting a sleep duration based on a selected parameter of the first continuous time, the second continuous time, a set time, a minimum value and a maximum value specifically includes:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleep time length according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, clearing the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
Specifically, adjusting the sleep duration according to the first continuous times, the set times and the minimum value specifically includes:
determining whether the first continuous times plus 1 exceed a set time;
if the first continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is smaller than the minimum value after being reduced by a set numerical value;
if the sleep duration is determined to be less than the minimum value after being reduced by the set numerical value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
Specifically, adjusting the sleep duration according to the second continuous times, the set times and the maximum value specifically includes:
determining whether the second continuous times plus 1 exceed the set times;
if the second continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set numerical value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep time length is not greater than the maximum value after the sleep time length is increased by the set value, increasing the sleep time length by the set value.
According to an embodiment of the present invention, there is further provided a device for dynamically adjusting sleep duration of an information access task, applied to each information access task included in a network device, including:
the detection module is used for detecting whether a first shared storage area for storing information has a free storage unit or not;
the adjusting module is used for adjusting the first continuous times of detecting the idle storage units and the second continuous times of detecting no idle storage units according to the detection result, and adjusting the sleep duration based on the selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value;
a starting module for starting a timer based on the sleep duration;
and the monitoring module is used for turning to the detection module if the timer is monitored to expire.
Specifically, the detecting module is configured to detect whether a first shared storage area storing information has an idle storage unit, and specifically configured to:
determining whether the number of first used storage units of a first shared storage area reaches the maximum number of storage units of the first shared storage area;
if the number of the first used storage units reaches the maximum storage unit number, the detection result is that no idle storage unit exists;
and if the number of the first used storage units is determined not to reach the maximum storage unit number, the detection result is that idle storage units exist.
Optionally, the adjusting module is further configured to:
before the starting module starts a timer based on the sleep duration, if information to be stored is obtained from the outside, the information to be stored is stored in the first shared storage area, and the number of the first used storage units is added by 1; or, if the information to be stored is acquired from a second shared storage area, subtracting 1 from the number of second used storage units in the second shared storage area, and adding 1 to the number of first used storage units.
Specifically, the adjusting module is configured to adjust a first continuous time when an idle storage unit is detected and a second continuous time when no idle storage unit is detected according to a detection result, and adjust the sleep duration based on a selected parameter among the first continuous time, the second continuous time, a set time, a minimum value, and a maximum value, and is specifically configured to:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleep time length according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, clearing the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
Specifically, the adjusting module is configured to adjust the sleep duration according to the first continuous times, the set times, and the minimum value, and is specifically configured to:
determining whether the first continuous times plus 1 exceed a set time;
if the first continuous times exceed the set times after being added with 1, determining whether the sleep duration is less than the minimum value after being reduced by a set value;
if the sleep duration is determined to be less than the minimum value after being reduced by the set numerical value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
Specifically, the adjusting module is configured to adjust the sleep duration according to the second consecutive times, the set times, and the maximum value, and specifically configured to:
determining whether the second continuous times plus 1 exceed the set times;
if the second continuous times exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set numerical value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep time length is not greater than the maximum value after the sleep time length is increased by the set value, increasing the sleep time length by the set value.
According to an embodiment of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the above method steps when executing the program stored in the memory.
According to an embodiment of the present invention, there is also provided a computer-readable storage medium having stored therein a computer program, which when executed by a processor, performs the above-mentioned method steps.
The invention has the following beneficial effects:
the embodiment of the invention provides a method and a device for dynamically adjusting sleep duration of an information access task, which are characterized in that whether a first shared storage area for storing information has a free storage unit or not is detected; adjusting a first continuous frequency of detecting an idle storage unit and a second continuous frequency of detecting no idle storage unit according to a detection result, and adjusting the sleeping time length based on selected parameters in the first continuous frequency, the second continuous frequency, a set frequency, a minimum value and a maximum value; starting a timer based on the sleep duration; and if the timer is monitored to expire, executing the step of detecting whether the first shared storage area for storing the information has a free storage unit. According to the scheme, whether a first shared storage area for storing information has a free storage unit or not can be detected, the first continuous times when the free storage unit is detected and the second continuous times when the free storage unit is not detected are adjusted according to the detection result, and the sleep time length is adjusted based on selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value, so that the sleep time length of an information access task is dynamically adjusted, the problems that the shared storage area is consumed light within a period of time, newly obtained information is discarded because the newly obtained information cannot be stored in the shared storage unit, and the newly obtained information is damaged due to insufficient system memory when the newly obtained information is serious are solved.
Drawings
FIG. 1 is a schematic diagram illustrating the operation of an information access task in the prior art;
FIG. 2 is a flowchart of a method for dynamically adjusting sleep duration of an information access task according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a device for dynamically adjusting sleep duration of an information access task according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device shown in the present application.
Detailed Description
In order to implement the dynamic adjustment of the sleep duration of the information access task, an embodiment of the present invention provides a method for dynamically adjusting the sleep duration of the information access task, which is applied to each information access task included in a network device, and a flow of the method is shown in fig. 2, and the method includes the following steps:
s21: whether a first shared storage area for storing information has a free storage unit is detected.
The network device may include a plurality of shared storage areas, the shared storage area for storing information corresponding to the current information access task may be defined as a first shared storage area, after the current information access task runs, it is first detected whether the first shared storage area has a free storage unit, the current information access task may be, but is not limited to, a thread, and the first shared storage area may be, but is not limited to, a shared memory, a message queue, a pipe, a socket, and the like.
S22: and adjusting the first continuous times of detecting the idle storage units and the second continuous times of detecting the non-idle storage units according to the detection result, and adjusting the sleep time length based on the selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value.
The number of times of continuously detecting the idle storage units can be defined as a first continuous number, and the number of times of continuously detecting the idle storage units can be defined as a second continuous number; the set times, the minimum value and the maximum value can be set according to actual needs.
S23: and starting a timer based on the sleep time length, and executing S21 if the expiration of the timer is monitored.
According to the scheme, whether a first shared storage area for storing information has a free storage unit or not can be detected, the first continuous times for detecting the free storage unit and the second continuous times for detecting no free storage unit are adjusted according to the detection result, and the sleep duration is adjusted based on selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value, so that the sleep duration of an information access task is dynamically adjusted, the problems that the shared storage area is consumed light within a period of time, newly acquired information is discarded due to the fact that the newly acquired information cannot be stored in the shared storage unit, and system memory is insufficient and crashed when the newly acquired information is serious are solved.
Specifically, the detecting step S21 includes detecting whether the first shared storage area for storing information has an idle storage unit, and the implementing process includes:
determining whether the number of first used storage units of the first shared storage area reaches the maximum number of storage units of the first shared storage area;
if the number of the first used storage units reaches the maximum number of the storage units, the detection result is no idle storage unit;
and if the number of the first used storage units is determined to not reach the maximum storage unit number, the detection result is an idle storage unit.
The used storage units in the first shared storage area can be defined as the number of first used storage units, when detecting whether the first shared storage area for storing the information has free storage units, whether the number of the first used storage units reaches the maximum number of the storage units in the first shared storage area can be determined, and if the number of the first used storage units reaches the maximum number of the storage units, which indicates that all the storage units included in the first shared storage unit store the information, the detection result is no free storage unit; and if the number of the first used storage units is determined to be less than the maximum number of the storage units, which indicates that part of the storage units included in the first shared storage unit stores information, the detection result is an idle storage unit.
Specifically, before the timer is started based on the sleep duration in S23, the method further includes:
if the information to be stored is acquired from the outside, storing the information to be stored into a first shared storage area, and adding 1 to the number of the first used storage units; or,
and if the information to be stored is acquired from the second shared storage area, subtracting 1 from the number of the second used storage units in the second shared storage area, and adding 1 to the number of the first used storage units.
As shown in fig. 1, if the current information access Task is Task1, directly obtaining information from the outside, where the information may be defined as information to be stored, and at this time, storing the information to be stored in a first shared storage area, and adding 1 to the number of first used storage units; if the current information access Task is Task2, the information to be stored is obtained from another shared storage area, the another shared storage area may be defined as a second shared storage area, and the number of used storage units in the second shared storage area may be defined as a second number of used storage units, at this time, the second number of used storage units in the second shared storage area may be subtracted by 1, and the first number of used storage units may be added by 1.
Specifically, the adjusting of the first continuous times of detecting that there is an idle storage unit and the second continuous times of detecting that there is no idle storage unit in S22 according to the detection result and the adjusting of the sleep duration based on the selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value specifically include:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleep time length according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, resetting the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
The selection of the selected parameters is different according to different detection results, if the detection result is that an idle storage unit exists, the selected parameters comprise a first continuous time, a set time and a minimum value, the first continuous time for which the idle storage unit is detected is added with 1, and after a second continuous time for which no idle storage unit is detected is cleared, the sleep time length is adjusted according to the first continuous time, the set time and the minimum value; and if the detection result is that no idle storage unit exists, selecting parameters including a second continuous time, a set time and a maximum value to adjust the sleep time length, adding 1 to the second continuous time, resetting the first continuous time, and adjusting the sleep time length according to the second continuous time, the set time and the maximum value.
Specifically, the adjusting the sleep duration according to the first continuous times, the set times and the minimum value specifically includes:
determining whether the first continuous times exceed the set times after adding 1;
if the first continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is smaller than the minimum value after being reduced by the set value;
if the sleep duration is determined to be reduced by the set value and then is smaller than the minimum value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
The detection result is an idle storage unit, so that whether the first continuous time plus 1 exceeds the set time or not needs to be determined, if the first continuous time plus 1 exceeds the set time, the first shared storage area has idle storage space for multiple times, the sleep time can be shortened to store information, the sleep time can be reduced, at the moment, whether the sleep time is reduced by the set value or not needs to be further determined, and specifically, if the sleep time is reduced by the set value and is smaller than the minimum value, the sleep time is updated to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
The setting value may be set according to actual needs, and may be, for example, but not limited to, set to 100ms.
Specifically, the adjusting the sleep duration according to the second continuous times, the set times and the maximum value specifically includes:
determining whether the second continuous times exceed the set times after adding 1;
if the second continuous times exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep time length is determined not to be larger than the maximum value after being increased by the set value, increasing the sleep time length by the set value.
The detection result is that no idle storage unit exists, so that whether the second continuous time plus 1 exceeds the set time or not needs to be determined, if the second continuous time plus 1 exceeds the set time, the first shared storage area does not have an idle storage space for multiple times, the sleep time needs to be increased to store information, the sleep time can be increased, at the moment, whether the sleep time is increased by the set value or not needs to be further determined, and is greater than the maximum value, specifically, if the sleep time is increased by the set value and is greater than the maximum value, the sleep time is updated to the maximum value; and if the sleep duration is determined to be not greater than the maximum value after being increased by the set value, increasing the sleep duration by the set value.
Based on the same inventive concept, an embodiment of the present invention provides a device for dynamically adjusting sleep duration of an information access task, which is applied to each information access task included in a network device, and the structure of the device is shown in fig. 3, and includes:
a detecting module 31, configured to detect whether a first shared storage area storing information has a free storage unit;
the adjusting module 32 is configured to adjust a first continuous number of times that an idle storage unit is detected and a second continuous number of times that no idle storage unit is detected according to the detection result, and adjust the sleep duration based on a selected parameter of the first continuous number, the second continuous number, the set number, the minimum value, and the maximum value;
a starting module 33, configured to start a timer based on the sleep duration;
and a monitoring module 34, configured to turn to the detection module if the timer is monitored to expire.
According to the scheme, whether a first shared storage area for storing information has a free storage unit or not can be detected, the first continuous times for detecting the free storage unit and the second continuous times for detecting no free storage unit are adjusted according to the detection result, and the sleep time length is adjusted based on the selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value, so that the problems that the shared storage area is consumed light within a period of time, newly acquired information is discarded because the information cannot be stored in the shared storage unit, and the system memory is insufficient and crashed when the newly acquired information is serious are effectively avoided.
Specifically, the detecting module 31 is configured to detect whether a first shared storage area storing information has an idle storage unit, and specifically configured to:
determining whether the number of first used storage units in the first shared storage area reaches the maximum number of storage units in the first shared storage area;
if the number of the first used storage units reaches the maximum number of the storage units, the detection result is no idle storage unit;
and if the number of the first used storage units is determined not to reach the maximum storage unit number, the detection result is that the storage unit is free.
Optionally, the adjusting module 32 is further configured to:
before a starting module starts a timer based on sleep time, if information to be stored is obtained from the outside, the information to be stored is stored in a first shared storage area, and the number of first used storage units is added by 1; or, if the information to be stored is acquired from the second shared storage area, subtracting 1 from the number of the second used storage units in the second shared storage area, and adding 1 to the number of the first used storage units.
Specifically, the adjusting module 32 is configured to adjust a first continuous time when an idle storage unit is detected and a second continuous time when no idle storage unit is detected according to the detection result, and adjust the sleep duration based on a selected parameter of the first continuous time, the second continuous time, the set time, the minimum value, and the maximum value, and specifically configured to:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleep time length according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, resetting the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
Specifically, the adjusting module 32 is configured to adjust the sleep duration according to the first continuous time, the set time, and the minimum value, and specifically configured to:
determining whether the first continuous times exceed the set times after adding 1;
if the first continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is smaller than the minimum value after being reduced by the set value;
if the sleep duration is determined to be reduced by the set value and then is smaller than the minimum value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
Specifically, the adjusting module 32 is configured to adjust the sleep duration according to the second consecutive times, the set times, and the maximum value, and specifically configured to:
determining whether the second continuous times exceed the set times after adding 1;
if the second continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set numerical value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep duration is determined to be not greater than the maximum value after being increased by the set value, increasing the sleep duration by the set value.
An electronic device is further provided in the embodiment of the present application, please refer to fig. 4, which includes a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 complete communication with each other through the communication bus 440.
A memory 430 for storing computer programs;
the processor 410 is configured to implement the method for dynamically adjusting the sleep duration of the information access task in any of the above embodiments when executing the program stored in the memory 430.
The communication interface 420 is used for communication between the above-described electronic device and other devices.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
According to the scheme, whether a first shared storage area for storing information has a free storage unit or not can be detected, the first continuous times for detecting the free storage unit and the second continuous times for detecting no free storage unit are adjusted according to the detection result, and the sleep duration is adjusted based on selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value, so that the sleep duration of an information access task is dynamically adjusted, the problems that the shared storage area is consumed light within a period of time, newly acquired information is discarded due to the fact that the newly acquired information cannot be stored in the shared storage unit, and system memory is insufficient and crashed when the newly acquired information is serious are solved.
Accordingly, an embodiment of the present application further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is caused to execute the method for dynamically adjusting the sleep duration of an information access task described in any of the foregoing embodiments.
According to the scheme, whether a first shared storage area for storing information has a free storage unit or not can be detected, the first continuous times for detecting the free storage unit and the second continuous times for detecting no free storage unit are adjusted according to the detection result, and the sleep duration is adjusted based on selected parameters of the first continuous times, the second continuous times, the set times, the minimum value and the maximum value, so that the sleep duration of an information access task is dynamically adjusted, the problems that the shared storage area is consumed light within a period of time, newly acquired information is discarded due to the fact that the newly acquired information cannot be stored in the shared storage unit, and system memory is insufficient and crashed when the newly acquired information is serious are solved.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While alternative embodiments of the present invention have been described, additional variations and modifications of those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following appended claims be interpreted as including alternative embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made in the embodiments of the present invention without departing from the spirit or scope of the embodiments of the invention. Thus, if such modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to encompass these modifications and variations.
Claims (12)
1. A method for dynamically adjusting sleep time of an information access task is applied to each information access task included in network equipment, and is characterized by comprising the following steps:
detecting whether a first shared storage area for storing information has a free storage unit or not;
adjusting a first continuous frequency of detecting an idle storage unit and a second continuous frequency of detecting no idle storage unit according to a detection result, and adjusting the sleeping time length based on selected parameters in the first continuous frequency, the second continuous frequency, a set frequency, a minimum value and a maximum value;
starting a timer based on the sleep duration;
if the timer is monitored to expire, executing the step of detecting whether a first shared storage area for storing information has a free storage unit;
the method specifically includes the steps of adjusting a first continuous time for detecting an idle storage unit and a second continuous time for detecting no idle storage unit according to a detection result, and adjusting the sleep duration based on selected parameters of the first continuous time, the second continuous time, a set time, a minimum value and a maximum value:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleeping time according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, clearing the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
2. The method of claim 1, wherein detecting whether a first shared storage area for storing information has free storage units comprises:
determining whether the number of first used storage units of a first shared storage area reaches the maximum number of storage units of the first shared storage area;
if the number of the first used storage units is determined to reach the maximum storage unit number, the detection result is no idle storage unit;
and if the number of the first used storage units is determined not to reach the maximum storage unit number, the detection result is that idle storage units exist.
3. The method of claim 2, wherein prior to starting the timer based on the sleep duration, further comprising:
if the information to be stored is obtained from the outside, storing the information to be stored into the first shared storage area, and adding 1 to the number of the first used storage units; or,
and if the information to be stored is acquired from a second shared storage area, subtracting 1 from the number of second used storage units in the second shared storage area, and adding 1 to the number of first used storage units.
4. The method of claim 1, wherein adjusting the sleep duration according to the first continuous number, the set number, and the minimum value specifically comprises:
determining whether the first continuous times plus 1 exceed a set time;
if the first continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is smaller than the minimum value after being reduced by a set numerical value;
if the sleep duration is determined to be less than the minimum value after being reduced by the set numerical value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
5. The method according to claim 1, wherein adjusting the sleep duration according to the second number of consecutive times, the set number of times, and the maximum value specifically comprises:
determining whether the second continuous times exceed a set time after adding 1;
if the second continuous times are determined to exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep time length is not greater than the maximum value after the sleep time length is increased by the set value, increasing the sleep time length by the set value.
6. A sleep duration dynamic adjustment device of an information access task is applied to each information access task included in network equipment, and is characterized by comprising the following steps:
the detection module is used for detecting whether a first shared storage area for storing information has a free storage unit or not;
the adjusting module is used for adjusting a first continuous frequency of detecting that an idle storage unit exists and a second continuous frequency of detecting that no idle storage unit exists according to a detection result, and adjusting the sleeping time length based on selected parameters in the first continuous frequency, the second continuous frequency, a set frequency, a minimum value and a maximum value;
a starting module for starting a timer based on the sleep duration;
the monitoring module is used for turning to the detection module if the timer is monitored to expire;
the adjusting module is configured to adjust a first continuous number of times that an idle storage unit is detected and a second continuous number of times that no idle storage unit is detected according to a detection result, and adjust a sleep duration based on a selected parameter of the first continuous number of times, the second continuous number of times, a set number of times, a minimum value, and a maximum value, and is specifically configured to:
if the detection result is that the idle storage unit exists, adding 1 to the first continuous times of detecting the idle storage unit, resetting the second continuous times of detecting no idle storage unit, and adjusting the sleep time length according to the first continuous times, the set times and the minimum value;
and if the detection result is that no idle storage unit exists, adding 1 to the second continuous times, clearing the first continuous times, and adjusting the sleep time length according to the second continuous times, the set times and the maximum value.
7. The apparatus of claim 6, wherein the detecting module is configured to detect whether a first shared storage area for storing information has free storage units, and is specifically configured to:
determining whether the number of first used storage units in a first shared storage area reaches the maximum number of storage units in the first shared storage area;
if the number of the first used storage units is determined to reach the maximum storage unit number, the detection result is no idle storage unit;
and if the number of the first used storage units is determined not to reach the maximum storage unit number, the detection result is that idle storage units exist.
8. The apparatus of claim 7, wherein the adjustment module is further configured to:
before the starting module starts a timer based on the sleep duration, if information to be stored is obtained from the outside, the information to be stored is stored in the first shared storage area, and the number of the first used storage units is added by 1; or, if the information to be stored is acquired from a second shared storage area, subtracting 1 from the number of second used storage units in the second shared storage area, and adding 1 to the number of first used storage units.
9. The apparatus according to claim 6, wherein the adjusting module is configured to adjust the sleep duration according to the first consecutive times, the set number of times, and the minimum value, and specifically is configured to:
determining whether the first continuous times exceed set times after adding 1;
if the first continuous times exceed the set times after being added with 1, determining whether the sleep duration is less than the minimum value after being reduced by a set value;
if the sleep duration is determined to be less than the minimum value after being reduced by the set numerical value, updating the sleep duration to the minimum value; and if the sleep duration is determined to be not less than the minimum value after being reduced by the set value, reducing the sleep duration by the set value.
10. The apparatus according to claim 6, wherein the adjusting module is configured to adjust the sleep duration according to the second consecutive number, the set number, and a maximum value, and specifically is configured to:
determining whether the second continuous times exceed a set time after adding 1;
if the second continuous times exceed the set times after being added with 1, determining whether the sleep duration is greater than the maximum value after being added with the set value;
if the sleep duration is determined to be greater than the maximum value after being increased by the set value, updating the sleep duration to the maximum value; and if the sleep time length is not greater than the maximum value after the sleep time length is increased by the set value, increasing the sleep time length by the set value.
11. An electronic device, characterized in that the electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-5 when executing a program stored on a memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110459269.6A CN113220227B (en) | 2021-04-27 | 2021-04-27 | Method and device for dynamically adjusting sleep duration of information access task |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110459269.6A CN113220227B (en) | 2021-04-27 | 2021-04-27 | Method and device for dynamically adjusting sleep duration of information access task |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113220227A CN113220227A (en) | 2021-08-06 |
CN113220227B true CN113220227B (en) | 2022-10-14 |
Family
ID=77089732
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110459269.6A Active CN113220227B (en) | 2021-04-27 | 2021-04-27 | Method and device for dynamically adjusting sleep duration of information access task |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113220227B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104754704A (en) * | 2013-12-26 | 2015-07-01 | 华为终端有限公司 | Method for controlling terminal to hibernate and terminal |
CN112437481A (en) * | 2019-08-26 | 2021-03-02 | 华为技术有限公司 | Monitoring period adjusting method and device |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9342443B2 (en) * | 2013-03-15 | 2016-05-17 | Micron Technology, Inc. | Systems and methods for memory system management based on thermal information of a memory system |
CN109271252B (en) * | 2018-08-29 | 2021-07-16 | 华为技术有限公司 | Method and device for adjusting thread number |
CN109525500B (en) * | 2018-12-27 | 2021-08-24 | 北京天融信网络安全技术有限公司 | Information processing method and information processing device capable of automatically adjusting threshold |
KR102671743B1 (en) * | 2019-05-31 | 2024-06-04 | 에스케이하이닉스 주식회사 | Memory system and operation method thereof |
-
2021
- 2021-04-27 CN CN202110459269.6A patent/CN113220227B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104754704A (en) * | 2013-12-26 | 2015-07-01 | 华为终端有限公司 | Method for controlling terminal to hibernate and terminal |
CN112437481A (en) * | 2019-08-26 | 2021-03-02 | 华为技术有限公司 | Monitoring period adjusting method and device |
Also Published As
Publication number | Publication date |
---|---|
CN113220227A (en) | 2021-08-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108829521B (en) | Task processing method and device, computer equipment and storage medium | |
CN104782082A (en) | New approach for controller area network bus off handling | |
CN104778074A (en) | Calculation task processing method and device | |
US9639465B2 (en) | Dynamic cachable memory interface frequency scaling | |
CN109428786B (en) | Network performance monitoring method and device and computer readable storage medium | |
CN106951321B (en) | Method and device for managing CPU (Central processing Unit) resources of virtual machine | |
JP2021515324A (en) | On-board monitoring of voltage levels and droop events | |
CN114174956B (en) | Preemptive wake-up circuit for waking up from low power mode | |
CN107436672B (en) | Application processing method and terminal | |
CN111988240A (en) | Data sending method and device, electronic equipment and storage medium | |
CN113220227B (en) | Method and device for dynamically adjusting sleep duration of information access task | |
RU96109831A (en) | METHOD FOR MANAGING OVERLOADING MESSAGES OF AN ELEMENTARY PROGRAM IN A MULTI-PROCESSOR CONTROL SYSTEM | |
CN107396428B (en) | Frequency switching method and device | |
CN102129475B (en) | A kind of conflict avoiding method and system of resolution system resource-constrained | |
CN109117295A (en) | A kind of overtime monitoring method of transaction and device | |
JPWO2014136182A1 (en) | Air conditioner management apparatus and method | |
CN115421859B (en) | Dynamic loading method and device for configuration file, computer equipment and storage medium | |
CN106294451B (en) | Method and device for displaying processing progress in data processing | |
CN111953561B (en) | Method and device for inhibiting VRRP oscillation | |
CN111917974B (en) | FPGA-based video processing system, method, device and medium | |
CN115904719A (en) | Data acquisition method and device, electronic equipment and storage medium | |
CN112506896B (en) | Data deleting method and device and electronic equipment | |
CN113821071B (en) | Dynamic adjustment method and device for output power of equipment | |
CN106569879B (en) | Method for awakening peripheral and mobile terminal | |
CN114222084B (en) | Control method and device and electronic equipment |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |