Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Alternative embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
A first embodiment provided by the present disclosure is an embodiment of a method for scheduling a functional object.
The following describes an embodiment of the present disclosure in detail with reference to fig. 1, where fig. 1 is a flowchart of a method for scheduling a functional object according to an embodiment of the present disclosure.
Step S101, acquiring interface information of the functional object in the process.
A process is a running activity of a program with independent functions with respect to a certain data set. It can apply for and own system resources, and is a dynamic concept and an active entity. It is not just the code of the program but also the current activity, represented by the value of the program counter and the contents of the processing registers.
The method is applied to a process.
A thread is the smallest unit that an operating system can perform arithmetic scheduling. It is included in the process and is the actual unit of operation in the process. A thread refers to a single sequential control flow in a process, multiple threads can be concurrently executed in a process, and each thread executes different tasks in parallel.
The functional object is a section of program capable of completing independent functions in one thread. For example, a functional object is a function or method. The multiple functional objects may be in a parallel relationship or a nested relationship. For example, A, B, C and D are four function objects, B and C are function objects in which two of A have a parallel relationship, that is, B, C has a nested relationship with A; and D is a functional object in B, namely D and B have a nested relation.
The embodiment of the disclosure provides interface information of a functional object. The process establishes the logic relation of calling between the function objects and the corresponding calling thread through the interface information, thereby realizing the ordered calling of the function objects. The newly added functional object does not need to concern about the asynchronous problem, and can be added to the process according to the rule of the interface information, thereby simplifying the programming complexity.
The interface information includes: the method comprises the following steps of calling information of the function objects, dependency relationship among the function objects, process characteristic information, calling thread pool types and calling thread characteristic information corresponding to the calling thread pool types.
For example, the function object call information is description information of a function or a method.
For example, continuing with A, B, C and D above is an example of four functional objects, the dependencies between the functional objects are: b and C are dependent on A; d is dependent on B.
The type of the call thread pool is used for conveniently managing the number, functions and purposes of the call threads. The method comprises the following steps: a CPU intensive type and/or an IO intensive type.
The number of CPU-intensive types of call threads depends on the core architecture of the CPU. Meanwhile, the executed excessive function objects can be executed in turn only by preempting the CPU time slice, and the additional cost of system resources and time brought by frequently switching the function objects is increased. Therefore, optionally, the number of calling threads of the CPU intensive type is less than or equal to the number of cores of the CPU. For example, if the number of the cores of the CPU is 8, the number of the call threads of the CPU-intensive type is less than or equal to 8, and it is ensured that the 8 CPU cores can process 8 call threads in parallel under extreme conditions, so as to avoid the extra overhead caused by preempting the CPU time slice.
The number of IO-intensive call threads is less dependent on the kernel architecture of the CPU, and the call threads can be in a waiting state when the CPU cannot process redundant call threads. No further restrictions are placed on the number of call threads of the IO-intensive type.
In addition, the user can customize the type of the calling thread pool according to the functional requirement. The disclosed embodiments are not limiting.
And step S102, establishing a directed logic relationship between the functional objects according to the interface information and the directed sorting rule.
The purpose of this step is to establish a sort relation of calling between the function objects, so that the process can call the function objects in turn according to the sort relation, and avoid the mutual interference between the function objects and the additional overhead of the system.
Optionally, the establishing a directed logical relationship between the functional objects according to the interface information and the directed sorting rule includes the following steps:
and step S102-1, establishing a directed logic relationship between the functional objects according to the dependency relationship and the directed sorting rule between the functional objects.
For example, continuing with A, B, C and D above is an example of four functional objects, the dependencies between the functional objects are: b and C are dependent on A; d is dependent on B; the directed logical relationship is represented as:
A——>B、C——>D。
optionally, the dependency relationship between the functional objects includes: a directed graph data structure of functional objects.
The biggest difference between directed and undirected graphs is that each path has unidirectional directivity.
A directed graph data structure is an ordered triplet (V (D), A (D), ψ (D)) of a directed graph D, where ψ (D) is the correlation function that makes each element in A (D) (called a directed edge or arc) correspond to an ordered pair of elements in V (D) (called vertices or points).
The establishing of the directed logic relationship among the functional objects according to the dependency relationship and the directed sorting rule among the functional objects comprises the following steps:
and S102-1-1, establishing a directed logic relationship between the functional objects according to the directed graph data structure and the directed sorting rule.
Optionally, the directed logical relationship includes: directed acyclic logic relationships.
Optionally, the directed ordering rule includes: topological ordering rules of directed graphs.
A directed acyclic logic relationship graph G is subjected to topological ordering, all vertexes in the graph G are arranged into a linear sequence, so that any pair of vertexes u and v in the graph has the condition that if an edge < u, v > belongs to E (G), u appears before v in the linear sequence. Generally, such a linear sequence is referred to as a sequence satisfying a topological order, abbreviated as a topological sequence. Briefly, a partial order on a set results in a full order on the set, which is called topological ordering.
And step S103, calling functional objects according to the interface information in sequence based on the direction of the directed logic relationship.
The calling of the function object according to the interface information comprises the following steps:
step S103-1, acquiring function object calling information, process characteristic information, calling thread pool type and calling thread characteristic information of the interface information.
And step S103-2, acquiring the calling thread according to the process characteristic information, the calling thread pool type and the calling thread characteristic information.
Each thread has an exclusive dynamic feature information, but the dynamic feature information is dynamically allocated when the process is established and cannot be pre-specified, so that the embodiment of the disclosure classifies the calling threads with different functions and purposes by using the calling thread pool type, creates a corresponding number of threads according to the calling thread feature information under each calling thread pool type in the interface information when the process is established, and establishes a corresponding index relationship between the dynamic feature information of the thread and the calling thread feature information. And acquiring the corresponding calling thread through the index relation.
For example, the number of cores of the CPU is 8, and the number of pieces of calling thread feature information in the CPU-intensive type is 4, which are a01, a02, a03, and a04, respectively; when a process is established, 4 threads with the same quantity as the calling thread feature information are established, the dynamic feature information acquired by each thread is F201901, F201902, F201903 and F201904, and corresponding index relations are established by a simple corresponding method; namely, A01 for F201901, A02 for F201902, A03 for F201903, and A04 for F201904.
And step S103-3, calling the function object by using the calling thread and the function object calling information.
For example, the function object call information is description information of a function or a method, and the call thread acquires the call method through the description information of the function or the method, so that the function object can be called, that is, the call thread calls the function or the method.
According to the method and the device, the calling sequencing relation is established among the functional objects among the threads, so that the process can call the functional objects in sequence according to the sequencing relation, and the additional overhead of a system caused by mutual interference among the functional objects is avoided. The newly added functional object does not need to concern about the asynchronous problem, and can be added to the process according to the rule of the interface information, thereby simplifying the programming complexity. And the CPU kernel can process the calling thread in parallel under extreme conditions, so that the extra overhead caused by the occupation of the CPU time slice is avoided. Meanwhile, each functional object is conveniently monitored.
Corresponding to the first embodiment provided by the present disclosure, the present disclosure also provides a second embodiment, that is, an apparatus for scheduling functional objects. Since the second embodiment is basically similar to the first embodiment, the description is simple, and the relevant portions should be referred to the corresponding description of the first embodiment. The device embodiments described below are merely illustrative.
Fig. 2 illustrates an embodiment of an apparatus for scheduling a functional object according to the present disclosure. Fig. 2 is a block diagram of a unit of an apparatus for scheduling a functional object according to an embodiment of the present disclosure.
Referring to fig. 2, the present disclosure provides an apparatus for scheduling a functional object, including: the device comprises an acquisition unit 201, a building unit 202 and a calling unit 203.
An obtaining unit 201, configured to obtain interface information of a function object in the process;
an establishing unit 202, configured to establish a directed logical relationship between the functional objects according to the interface information and a directed ordering rule;
and the calling unit 203 is used for calling the functional objects in sequence according to the interface information based on the direction of the directed logical relationship.
Optionally, the interface information includes: the method comprises the following steps of calling information of the function objects, dependency relationship among the function objects, process characteristic information, calling thread pool types and calling thread characteristic information corresponding to the calling thread pool types.
Optionally, the establishing unit 202 includes:
and the dependency relationship-based subunit is used for establishing a directed logic relationship between the functional objects according to the dependency relationship between the functional objects and a directed sorting rule.
Optionally, the dependency relationship between the functional objects includes: a directed graph data structure of the functional object;
in the dependency relationship-based subunit, including:
and the directed graph data structure-based subunit is used for establishing a directed logic relationship between the functional objects according to the directed graph data structure and a directed sorting rule.
Optionally, the invoking unit 203 includes:
the thread information acquiring subunit is used for acquiring function object calling information, process characteristic information, calling thread pool type and calling thread characteristic information of the interface information;
the obtaining calling thread subunit is used for obtaining a calling thread according to the process characteristic information, the calling thread pool type and the calling thread characteristic information;
and the calling subunit is used for calling the functional object by using the calling thread and the functional object calling information.
Optionally, the calling thread pool type includes: a CPU intensive type and/or an IO intensive type;
the number of the calling threads of the CPU intensive type is less than or equal to the number of the cores of the CPU.
Optionally, the directed logical relationship includes: directed acyclic logical relationships;
the directed ordering rule comprises: topological ordering rules of directed graphs.
According to the method and the device, the calling sequencing relation is established among the functional objects among the threads, so that the process can call the functional objects in sequence according to the sequencing relation, and the additional overhead of a system caused by mutual interference among the functional objects is avoided. The newly added functional object does not need to concern about the asynchronous problem, and can be added to the process according to the rule of the interface information, thereby simplifying the programming complexity. And the CPU kernel can process the calling thread in parallel under extreme conditions, so that the extra overhead caused by the occupation of the CPU time slice is avoided. Meanwhile, each functional object is conveniently monitored.
The third embodiment of the present disclosure provides an electronic device, where the electronic device is used in a method for scheduling a functional object, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to perform the method of scheduling functional objects according to the first embodiment.
The present disclosure provides a fourth embodiment, which is a computer storage medium storing computer-executable instructions that can execute the method for scheduling functional objects as described in the first embodiment.
Referring now to FIG. 3, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 3, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring at least two internet protocol addresses; sending a node evaluation request comprising the at least two internet protocol addresses to node evaluation equipment, wherein the node evaluation equipment selects the internet protocol addresses from the at least two internet protocol addresses and returns the internet protocol addresses; receiving an internet protocol address returned by the node evaluation equipment; wherein the obtained internet protocol address indicates an edge node in the content distribution network.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a node evaluation request comprising at least two internet protocol addresses; selecting an internet protocol address from the at least two internet protocol addresses; returning the selected internet protocol address; wherein the received internet protocol address indicates an edge node in the content distribution network.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.