CN111984409A - Method and device for improving system resource utilization rate - Google Patents

Method and device for improving system resource utilization rate Download PDF

Info

Publication number
CN111984409A
CN111984409A CN202010820491.XA CN202010820491A CN111984409A CN 111984409 A CN111984409 A CN 111984409A CN 202010820491 A CN202010820491 A CN 202010820491A CN 111984409 A CN111984409 A CN 111984409A
Authority
CN
China
Prior art keywords
task
tokens
token
file
processes
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.)
Withdrawn
Application number
CN202010820491.XA
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202010820491.XA priority Critical patent/CN111984409A/en
Publication of CN111984409A publication Critical patent/CN111984409A/en
Withdrawn legal-status Critical Current

Links

Images

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)

Abstract

The invention discloses a method and a device for improving the utilization rate of system resources, which are used for creating M tokens for a task; the task comprises N processes which can be executed in parallel; the task intermittently acquires tokens, and executes one process each time a token is acquired. The method and the device establish the token for the task, the task executes a process when acquiring one token, namely, only the process of the acquired token is allowed to run, and the number of the processes running at the same time is limited by the token. Furthermore, the process can be bound to a specific CPU, the process is preferably operated on the CPU with the minimum resource utilization rate, the maximum utilization of resources is achieved under the condition that the normal operation of other tasks is not influenced, the probability of system breakdown caused by resource exhaustion is reduced, and the method has important significance in a production environment.

Description

Method and device for improving system resource utilization rate
Technical Field
The invention relates to the field of system resource utilization, in particular to a method and a device for improving the utilization rate of system resources.
Background
The LINUX system is a relatively open operating system, and is used for meeting all types of resource requests as far as possible within the allowable range of system resources according to the principle that the occupation of process resources (mainly referring to the occupation condition of a CPU and a memory) and the consumption of the process resources apply for first use, so that great convenience is brought to production, development and research; however, the resources are wasted greatly and occupied unreasonably, so that the best performance of the device cannot be brought into play effectively, or the normal operation of the key tasks and even the kernel itself is affected.
Although the LINUX system itself may impose a certain limitation on resource occupation, for example, when the memory is insufficient, a process with a higher memory occupation is forcibly killed, which may have a great adverse effect on the operation of the process, and especially when the CPU utilization is 100%, the performance of all the processes is greatly affected, and even a system crash or crash is caused.
Disclosure of Invention
In order to solve the above problems, the present invention provides a method and an apparatus for improving the utilization rate of system resources, by controlling the number of processes performed by a task at the same time, preferably binding a program related to the task to a specific CPU, and achieving the maximum utilization of resources without affecting the normal operation of other tasks.
The technical scheme of the invention is as follows: a method for improving the utilization rate of system resources comprises the following steps:
creating M tokens for the task; the task comprises N processes which can be executed in parallel; wherein M and N are integers greater than or equal to 1;
the task intermittently acquires tokens, and executes one process each time a token is acquired.
Further, creating M tokens for the task, specifically:
creating a pipeline file;
associating the conduit file to a file descriptor for the task;
writing M tokens into the file descriptor.
Further, after the process is executed, the corresponding token is released.
Further, if the number M of tokens is smaller than the number N of processes, when all the M tokens are issued, the task continues to execute the remaining processes while waiting for the release of the tokens.
Further, after all processes are executed, the pipeline file is deleted.
Further, the task acquires a token, acquires the resource utilization rate of each available CPU before executing the corresponding process, and runs the process on the CPU with the minimum resource utilization rate.
The technical scheme of the invention also comprises a device for improving the utilization rate of system resources, which comprises,
a token creation module: creating M tokens for the task; the task comprises N processes which can run in parallel; wherein M and N are integers greater than or equal to 1;
a process execution module: the task intermittently acquires tokens, and executes one process each time a token is acquired.
Further, the token creation module includes,
a pipe file creation unit: creating a pipeline file;
a pipeline file association unit: associating the conduit file to a file descriptor for the task;
a token write unit: writing M tokens into the file descriptor.
Further, after the process is executed, releasing the corresponding token;
if the number M of the tokens is smaller than the number N of the processes, when all the M tokens are issued, the process execution module continues to execute the rest processes when the tokens are released.
Further, the method also comprises the following steps of,
a CPU binding module: and acquiring the resource utilization rate of each available CPU, and running the process to be run on the CPU with the minimum resource utilization rate.
According to the method and the device for improving the utilization rate of the system resources, the token is created for the task, one process is executed when the task acquires one token, namely, only the process of the acquired token is allowed to run, and the number of processes running at the same time is limited through the token. Furthermore, the process can be bound to a specific CPU, the process is preferably operated on the CPU with the minimum resource utilization rate, the maximum utilization of system resources is achieved under the condition that the normal operation of other tasks is not influenced, the probability of system crash caused by resource exhaustion is reduced, and the method has important significance in a production environment.
Drawings
FIG. 1 is a schematic flow chart of a method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method according to an embodiment of the present invention;
fig. 3 is a schematic block diagram of a second structure according to an embodiment of the present invention.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings by way of specific examples, which are illustrative of the present invention and are not limited to the following embodiments.
Example one
The present embodiment provides a method for improving the utilization rate of system resources, which implements effective use of resources by controlling the number of processes that are performed simultaneously by tasks.
As shown in fig. 1, the method comprises the following steps:
s1, creating M tokens for the task; wherein the task comprises N processes which can be executed in parallel; wherein M and N are integers greater than or equal to 1;
s2, the task obtains tokens intermittently, and executes a process each time a token is obtained.
According to the method, the process of the token is controlled to run only by controlling the number of the processes which are carried out simultaneously through the token, the process of the token is obtained, at most, M processes are allowed to run simultaneously, the normal running of the processes can be ensured, and the maximum effective utilization of resources is realized by reasonably setting the number of the tokens.
To further understand the present solution, a specific implementation manner is provided in combination with the principle of the present invention on the basis of the above steps, as shown in fig. 2, including the following steps:
creating M tokens for a task
S101, creating a pipeline file;
a pipeline file, i.e. a First Input First Output (FIFO) file, a file type in the LINUX system, through which data can be transferred between different processes, and one end is written and the other end is read.
S102, associating the pipeline file to a file descriptor of the task;
the file descriptor is a nonnegative integer, when an existing file or a new file is opened, the kernel returns a file descriptor, and the file reading and writing operation is completed through the file descriptor.
Assuming that the file descriptor is 33, the pipe file is associated to the file descriptor of the task by the command exec 33< > PF, PF referring to the pipe file.
S103, writing M tokens into the file descriptor;
the last step associates the pipe file to the file descriptor, giving the file descriptor the properties of the pipe file, allowing the writing of tokens into the file descriptor. In addition, when the file descriptor controls the read-write operation, the file descriptor also has a first-in first-out characteristic, that is, in this embodiment, the task reads the token from the file descriptor, and the file descriptor issues the token to the task according to the first-in first-out characteristic. It should be noted that M is an integer greater than or equal to 1, that is, at least one token is written, and at least one process is allowed to execute during a certain period of time.
(II) the task intermittently acquires tokens, and executes a process each time a token is acquired
It should be noted that a task includes N processes that can be executed in parallel, that is, the N processes are allowed to be executed simultaneously. N is an integer of 1 or more.
S104, the task obtains tokens intermittently, and one process is executed when one token is obtained;
that is, the task sends a token obtaining instruction to the file descriptor once every preset time interval, and the file descriptor sends a token to the task after receiving the instruction.
It should be noted that, after the process is executed, the corresponding token is released.
And if the token number M is larger than the process number N, executing all the parallel processes at most by taking M times.
If the number M of tokens is smaller than the number N of the processes, after M times of operation, M processes may be simultaneously operated, no process which is finished to operate releases the tokens, and no token remains in the file descriptor, at this time, the task continues to wait until a process which is finished to operate releases the tokens, and the rest of the N-M processes are operated.
S105, before the process runs, acquiring the resource utilization rate of each available CPU, and running the process on the CPU with the minimum resource utilization rate;
in order to ensure the preferential use of resources, the present embodiment performs resource usage ranking on the CPUs before the process runs, so that the process can run on the CPU with the minimum resource usage.
The cpu with the minimum resource utilization rate can be specified to run the corresponding process through the taskset command.
And S106, after the process is executed, releasing the corresponding token.
And S107, deleting the pipeline file after all the processes are executed.
The method combines the binding function of the pipeline file and the CPU, realizes the dual purposes of process number control and resource occupation, and realizes the maximum and effective utilization of resources.
Example two
On the basis of the first embodiment, the present embodiment provides an apparatus for improving system resource utilization, which includes the following functional modules.
The token creation module 101: creating M tokens for the task; wherein the task comprises N processes which can run in parallel;
the process execution module 102: the task intermittently acquires tokens, and executes one process each time a token is acquired.
Wherein the token creation module comprises the following functional units.
Pipe file creating unit 101-1: creating a pipeline file;
pipe file association unit 101-2: associating the conduit file to a file descriptor for the task;
token write unit 101-3: writing M tokens into the file descriptor.
It should be noted that, after the process is executed, the corresponding token is released.
If the number M of tokens is smaller than the number N of processes, when all the M tokens are issued, the process execution module 102 waits for the release of the tokens and then continues to execute the remaining processes.
The embodiment further includes a CPU binding module 103: and acquiring the resource utilization rate of each available CPU, and running the process to be run on the CPU with the minimum resource utilization rate.
The process execution module 102 obtains the token, and before the process is run, the CPU binding module 103 selects the CPU with the minimum resource utilization rate, binds the CPU with the minimum resource utilization rate to the to-be-run process, and runs the to-be-run process on the CPU with the minimum resource utilization rate.
The above disclosure is only for the preferred embodiments of the present invention, but the present invention is not limited thereto, and any non-inventive changes that can be made by those skilled in the art and several modifications and amendments made without departing from the principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A method for improving the utilization rate of system resources is characterized by comprising the following steps:
creating M tokens for the task; the task comprises N processes which can be executed in parallel; wherein M and N are integers greater than or equal to 1;
the task intermittently acquires tokens, and executes one process each time a token is acquired.
2. The method of claim 1,
creating M tokens for the task, specifically:
creating a pipeline file;
associating the conduit file to a file descriptor for the task;
writing M tokens into the file descriptor.
3. The method of claim 2, wherein the corresponding token is released after the process is executed.
4. The method according to claim 3, wherein if the number of tokens M is smaller than the number of processes N, when all M tokens are issued, the task continues to execute the remaining processes after waiting for the token to be released.
5. The method of claim 4, wherein the pipeline file is deleted after all processes have been executed.
6. The method for improving system resource utilization according to any one of claims 1 to 5, wherein a task acquires a token, acquires resource utilization rates of available CPUs before executing a corresponding process, and runs the process on the CPU with the lowest resource utilization rate.
7. An apparatus for improving utilization rate of system resources, comprising,
a token creation module: creating M tokens for the task; the task comprises N processes which can run in parallel; wherein M and N are integers greater than or equal to 1;
a process execution module: the task intermittently acquires tokens, and executes one process each time a token is acquired.
8. The apparatus for improving utilization of system resources of claim 7, wherein the token creation module comprises,
a pipe file creation unit: creating a pipeline file;
a pipeline file association unit: associating the conduit file to a file descriptor for the task;
a token write unit: writing M tokens into the file descriptor.
9. The apparatus for improving utilization rate of system resources according to claim 7 or 8, wherein the corresponding token is released after the process is executed;
if the number M of the tokens is smaller than the number N of the processes, when all the M tokens are issued, the process execution module continues to execute the rest processes when the tokens are released.
10. The apparatus for improving utilization of system resources according to claim 9, further comprising,
a CPU binding module: and acquiring the resource utilization rate of each available CPU, and running the process to be run on the CPU with the minimum resource utilization rate.
CN202010820491.XA 2020-08-14 2020-08-14 Method and device for improving system resource utilization rate Withdrawn CN111984409A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010820491.XA CN111984409A (en) 2020-08-14 2020-08-14 Method and device for improving system resource utilization rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010820491.XA CN111984409A (en) 2020-08-14 2020-08-14 Method and device for improving system resource utilization rate

Publications (1)

Publication Number Publication Date
CN111984409A true CN111984409A (en) 2020-11-24

Family

ID=73435309

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010820491.XA Withdrawn CN111984409A (en) 2020-08-14 2020-08-14 Method and device for improving system resource utilization rate

Country Status (1)

Country Link
CN (1) CN111984409A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138471A (en) * 2021-11-18 2022-03-04 苏州浪潮智能科技有限公司 Method for binding software service to CPU core and related device
CN114896040A (en) * 2022-05-10 2022-08-12 浙江太美医疗科技股份有限公司 Task scheduling method and device, electronic equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138471A (en) * 2021-11-18 2022-03-04 苏州浪潮智能科技有限公司 Method for binding software service to CPU core and related device
CN114138471B (en) * 2021-11-18 2024-04-19 苏州浪潮智能科技有限公司 Method for binding software business with CPU core and related device
CN114896040A (en) * 2022-05-10 2022-08-12 浙江太美医疗科技股份有限公司 Task scheduling method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
KR101721466B1 (en) Fault tolerant batch processing
CN106569891B (en) Method and device for scheduling and executing tasks in storage system
CN109558344B (en) DMA transmission method and DMA controller suitable for network transmission
JP2007079789A (en) Computer system and event processing method
JPH10283210A (en) Virtual machine movement control system between virtual machine systems
CN111984409A (en) Method and device for improving system resource utilization rate
CN104104705B (en) The cut-in method and equipment of distributed memory system
CN115756767A (en) Device and method for multi-core CPU atomic operation memory
CN108958903B (en) Embedded multi-core central processor task scheduling method and device
US7689991B2 (en) Bus management techniques
CN112506818A (en) USB hardware virtualization method based on software simulation
JPH0798663A (en) Asynchronous i/o control system
CN113778690B (en) Task allocation method, device, equipment and storage medium
CN114281529B (en) Method, system and terminal for dispatching optimization of distributed virtualized client operating system
US6675238B1 (en) Each of a plurality of descriptors having a completion indicator and being stored in a cache memory of an input/output processor
CN115981893A (en) Message queue task processing method and device, server and storage medium
CN112748883B (en) IO request pipeline processing device, method, system and storage medium
CN108958904B (en) Driver framework of lightweight operating system of embedded multi-core central processing unit
CN108958905B (en) Lightweight operating system of embedded multi-core central processing unit
US6665752B1 (en) Interrupt driven interface coupling a programmable media access controller and a process controller
CN109656708B (en) Animation playing limiting method for Android, storage medium, electronic equipment and system
JP2004157644A (en) Disk subsystem, computer system, storage management method for managing thereof, and management program
CN110618794A (en) Method and system for accessing NandFlash by SSD firmware
JP2019179412A (en) Deadlock avoidance method and deadlock avoidance device
CN110908952B (en) Data processing method and device, CPU and computer

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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20201124