Application program control method and device

By creating a virtual socket and utilizing the kernel mode timing function of the operating system, the problem of low application timing accuracy in the existing technology is solved, and high-precision control of the application is achieved, which is suitable for applications that require high real-time performance and short-duration timing. scene.

CN112579210BActive Publication Date: 2024-10-25SHANGHAI ZHONG YUAN NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011604279.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-30
Publication Date
2024-10-25
Estimated Expiration
2040-12-30

Smart Images

  • Figure CN112579210B_ABST
    Figure CN112579210B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an application control method and device, which are applied to the field of software technology, wherein, when applied to an application, when there is a timing requirement for a target object, a virtual socket is accessed, and the target object is controlled to be in a blocked state, the target object is a process or thread used by the application to execute preset data processing, and the virtual socket is: a virtual socket pre-created by the application. The operating system installed in the electronic device where the application is located is triggered to time the duration of access to the virtual socket. After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, the blocking state of the target object is released, and the preset data processing is executed based on the target object. The solution provided by the embodiment of the present invention can improve the accuracy of controlling the application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software technology, and in particular to an application control method and device. Background Art

[0002] Electronic devices can run various applications. In some cases, the application needs to be timed during operation, so as to control the execution of specific data processing after a certain period of time. For example, when a user broadcasts live through a live broadcast program, the live broadcast program needs to be timed, and after each preset period of time, the live broadcast program needs to upload the collected sound or image data to the server.

[0003] In the prior art, applications are often timed by calling a user-mode timing function provided by the operating system installed in the electronic device running the application. However, the accuracy of the user-mode timing function is often low, and the accuracy of the application timing is low, which can easily lead to low accuracy in controlling the application. For example, the shortest timing duration of the timing function in the Windows operating system is approximately 15 milliseconds, and it is difficult to perform timing of less than 15 milliseconds. If the application has high real-time requirements, such as when it is necessary to time 10 milliseconds to control the application during the application running process, it is difficult to accurately control the application by calling the user-mode timing function. Summary of the invention

[0004] The purpose of the embodiment of the present invention is to provide an application control method and device to improve the accuracy of controlling the application. The specific technical solution is as follows:

[0005] In a first aspect of an embodiment of the present invention, a method for controlling an application program is provided, which is applied to an application program. The method includes:

[0006] When the target object has a timing requirement, access the virtual socket and control the target object to be in a blocked state, wherein the target object is a process or thread used by the application to perform preset data processing, and the virtual socket is: a virtual socket created in advance by the application;

[0007] Triggering the operating system installed in the electronic device where the application is located to time the access to the virtual socket;

[0008] After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, the blocking state of the target object is released, and the preset data processing is performed based on the target object.

[0009] In one embodiment of the present invention, accessing the virtual socket and controlling the target object to be in a blocked state includes:

[0010] By calling a socket access function, a virtual socket is accessed in an access mode indicated by the socket access function, and when a preset parameter of the socket access function indicates that the target object is blocked, the target object is triggered to be in a blocked state, wherein the access mode is: a mode of not obtaining data processing operations supported by the virtual socket.

[0011] In one embodiment of the present invention,

[0012] The socket access function is: a function provided by the operating system and used to access the virtual socket;

[0013] The socket access function is used to: trigger the operating system to time the duration of access to the virtual socket after triggering the target object to be in a blocked state.

[0014] In one embodiment of the present invention, after determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, releasing the blocking state of the target object includes:

[0015] After a timeout event is monitored, the blocking state of the target object is released, wherein the timeout event is an event triggered after the timing duration of the operating system reaches a preset timeout duration.

[0016] In a second aspect of an embodiment of the present invention, there is further provided an application control device, which is applied to an application, and the device includes:

[0017] A state trigger module, used for accessing a virtual socket and controlling the target object to be in a blocked state when a timing requirement exists for the target object, wherein the target object is a process or thread used by the application to perform preset data processing, and the virtual socket is a virtual socket pre-created by the application;

[0018] A timing trigger module, used to trigger the operating system installed in the electronic device where the application is located to time the duration of access to the virtual socket;

[0019] The data processing module is used to release the blocking state of the target object after determining that the timing duration of the operating system reaches the timeout duration of accessing the virtual socket, and perform the preset data processing based on the target object.

[0020] In one embodiment of the present invention, the state triggering module is specifically used to:

[0021] When a timing requirement exists for a target object, a socket access function is called to access a virtual socket in an access mode indicated by the socket access function, and when a preset parameter of the socket access function indicates that the target object is to be blocked, the target object is triggered to be in a blocked state, wherein the access mode is a mode of not obtaining data processing operations supported by the virtual socket.

[0022] In one embodiment of the present invention, the socket access function is: a function provided by the operating system and used to access a virtual socket;

[0023] The socket access function is used to: trigger the operating system to time the duration of access to the virtual socket after triggering the target object to be in a blocked state.

[0024] In one embodiment of the present invention, the data processing module is specifically used to:

[0025] After monitoring a timeout event, the blocking state of the target object is released, and the preset data processing is performed based on the target object, wherein the timeout event is an event triggered after the timing duration of the operating system reaches a preset timeout duration.

[0026] In a third aspect of an embodiment of the present invention, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0027] Memory, used to store computer programs;

[0028] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.

[0029] In another aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.

[0030] In yet another aspect of the present invention, there is provided a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any one of the method steps described in the first aspect.

[0031] In the application control scheme provided by the embodiment of the present invention, when there is a timing requirement for the target object, the target object is controlled to be in a blocked state by accessing the virtual socket, and the operating system is triggered to time the access to the virtual socket. If the timing duration reaches the timeout duration for accessing the virtual socket, the blocking state of the target object is released, and preset data processing is performed based on the target object.

[0032] As can be seen from the above, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is achieved with the help of the virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be achieved. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is achieved. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0034] Figure 1 A schematic diagram of a flow chart of a first application control method provided in an embodiment of the present invention;

[0035] Figure 2 A schematic flow chart of a second application control method provided in an embodiment of the present invention;

[0036] Figure 3 A schematic diagram of the structure of an application control device provided in an embodiment of the present invention;

[0037] Figure 4 The present invention is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0039] Since the timing accuracy of applications running in user mode based on the operating system is often low, which can easily lead to low accuracy in controlling the applications, in order to improve the accuracy of controlling the applications, an embodiment of the present invention provides an application control method and device.

[0040] In one embodiment of the present invention, an application control method is provided, which is applied to an application, and the method includes:

[0041] When there is a timing requirement for the target object, the virtual socket is accessed and the target object is controlled to be in a blocked state.

[0042] The target object is a process or thread used by the application to execute preset data processing, and the virtual socket is a virtual socket created in advance by the application.

[0043] The operating system installed on the electronic device where the application is located is triggered to time the duration of access to the virtual socket.

[0044] After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, the blocking state of the target object is released, and the preset data processing is performed based on the target object.

[0045] As can be seen from the above, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is achieved with the help of the virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be achieved. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is achieved. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0046] The application control method and device provided by the embodiments of the present invention are described below through specific embodiments.

[0047] In order to control the application in the embodiment of the present invention, a virtual socket needs to be created and started. The virtual socket can be started by the application when the application starts, or when the target object has a timing requirement for the first time.

[0048] See also Figure 1 , an embodiment of the present invention provides a flow chart of a first application control method, which is applied to an application. The method includes the following steps S101-S103.

[0049] S101: When a target object has a timing requirement, a virtual socket is accessed, and the target object is controlled to be in a blocked state.

[0050] The target object is a process or thread used by the application to execute preset data processing.

[0051] Specifically, the preset data processing may be: data calculation, data transmission, data reception, etc. When the target object has a timing requirement, the interface for accessing the virtual socket may be called. In one implementation, the application may access the virtual socket by executing another process or thread. The process or thread for accessing the virtual socket may be referred to as an execution object. The execution object may be a main process for controlling the operation of each process of the application, or a main thread for controlling the operation of each thread of the application. It may also be other processes outside the main process or other threads outside the main thread.

[0052] In one embodiment of the present invention, the execution object may send information for controlling the blocking of the target object to the target object, thereby triggering the target object to be in a blocking state. The target object being in a blocking state is equivalent to the target object pausing execution and entering a waiting state.

[0053] In addition, the virtual socket is a virtual socket created in advance by the application.

[0054] In one embodiment of the present invention, the virtual socket can be created by calling a socket function. The virtual socket can be a port for TCP / IP connection.

[0055] In one embodiment of the present invention, the above step S101 can be implemented through step S101A, which will not be described in detail here.

[0056] S102: Triggering the operating system installed in the electronic device where the application is located to time the duration of access to the virtual socket.

[0057] Specifically, the execution object can call the kernel of the operating system to start timing when the execution object starts accessing the virtual socket, and timing the duration of accessing the virtual socket. The timing accuracy of the kernel of the operating system is often high, so the timing accuracy of accessing the virtual socket is often high, and the shortest duration is approximately 0.5ms.

[0058] S103: After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, releasing the blocking state of the target object, and performing the preset data processing based on the target object.

[0059] Specifically, the timeout duration may be a preset fixed duration, or a duration set by the user according to timing requirements.

[0060] The timeout duration may be expressed in seconds, milliseconds, or both seconds and milliseconds. When the timeout duration is expressed in both seconds and milliseconds, the timeout duration may be expressed in the form of a structure, which includes a second value and a millisecond value. For example, when the second value is 1 and the millisecond value is 10, the timeout duration is 1 second and 10 milliseconds.

[0061] After the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, the execution object times out and the execution object stops running.

[0062] In one embodiment of the present invention, after the timing duration of the operating system reaches the timeout duration, the execution object may trigger a timeout event, thereby notifying the target object that the timing duration of the operating system reaches the timeout duration, and the target object may unblock the state and switch to the running state to continue running. Specifically, the timeout event may be an interrupt event, that is, the execution object triggers the interruption of the running process or thread.

[0063] When the execution object triggers a timeout event, the step S103 can be implemented by following the following step A.

[0064] Step A: After a timeout event is monitored, the blocking state of the target object is released, and the preset data processing is performed based on the target object.

[0065] The above-mentioned timeout event is: an event triggered after the timing duration of the above-mentioned operating system reaches a preset timeout duration.

[0066] Specifically, the above step A can be implemented by the main process or main thread of the above application, and the above main process or main thread can monitor whether the above timeout event is triggered by calling the event monitoring interface. If the above timeout event is monitored to be triggered, the above main process or main thread can send information of unblocking state to the target object, thereby controlling the above target object to unblock the state, and the above target object continues to perform the preset data processing.

[0067] In another embodiment of the present invention, after the timing duration of the above-mentioned operating system reaches the above-mentioned timeout duration, the above-mentioned execution object can send a timeout signal, thereby notifying the above-mentioned main thread or main process that the timing duration of the above-mentioned target object operating system has reached the above-mentioned timeout duration, then the above-mentioned main thread or main process can send information of unblocking the state to the target object, thereby controlling the above-mentioned target object to unblock the state, convert it to the running state and continue running.

[0068] As can be seen from the above, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is achieved with the help of the virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be achieved. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is achieved. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0069] In addition, the above Figure 1The illustrated embodiment can be applied to an application scenario in which a live broadcast program is controlled. The above-mentioned application is a live broadcast program, and the above-mentioned preset data processing is to send audio or image data to a server. The above-mentioned target object is a process or thread for sending audio or image data to a server. Specifically, the above-mentioned live broadcast program accesses the virtual socket and controls the target object to be in a blocked state, that is, the target object is suspended, and the live broadcast program suspends sending audio or image data to the server. And the live broadcast program triggers the operating system installed in the electronic device where the live broadcast program is located to time the access to the above-mentioned virtual socket. After the timing duration of the operating system reaches the timeout duration, the blocking state of the target object is released, that is, the target object continues to run, and the live broadcast program sends the audio or image data collected within the timeout duration to the server. After the audio or image data is sent, the live broadcast program can access the virtual socket again and control the target object to be in a blocked state. As can be seen from the above, through the above Figure 1 The embodiment shown can control the live broadcast program to send audio or image data to the server, and realize the function of sending audio or image data to the server after the live broadcast program has timed out. In addition, since most operating systems use a kernel-state timing function to time the access duration of the socket, the kernel-state timing function often has a high timing accuracy, and the shortest timing duration can often reach 0.5 milliseconds, it is possible to achieve millisecond-level control of the live broadcast program sending audio or image data to the server.

[0070] See also Figure 2 , is a flow chart of a second application control method provided by an embodiment of the present invention, which is similar to the above Figure 1 Compared with the embodiment shown, the above step S101 can be implemented by the following step S101A.

[0071] S101A: When the target object has a timing requirement, the virtual socket is accessed in the access mode indicated by the socket access function by calling the socket access function, and when the preset parameters of the socket access function indicate blocking the target object, the target object is triggered to be in a blocked state.

[0072] The access method mentioned above is a method of data processing operation that does not obtain support from the virtual socket.

[0073] When the target object has a timing requirement, the socket access function can be called, and the application accesses the virtual socket through the execution object. The socket access function can be used to access the socket and obtain the data processing operations supported by the socket, for example, operations that support writing data in the socket or operations that support reading data from the socket.

[0074] Specifically, when the preset parameters indicate that the target object is blocked, the above-mentioned socket access function is a blocking function, and when the preset parameters indicate that the target object is not blocked, the above-mentioned socket access function is a non-blocking function. In the case that the above-mentioned socket access function is a blocking function, during the execution of the socket access function, the target object will be set to a blocking state, waiting for the above-mentioned execution object to finish running, and the blocking state of the above-mentioned target object will be released and continue to run. In the case that the above-mentioned socket access function is a non-blocking function, the above-mentioned execution object will not affect the state of the above-mentioned target object. Therefore, in the embodiment of the present invention, in order to trigger the above-mentioned target object to be in a blocking state, the socket access function used is a blocking function.

[0075] Specifically, the preset parameter of the above-mentioned socket access function may include two different values, which respectively indicate that the above-mentioned socket access function is a blocking function or a non-blocking function. The above-mentioned preset parameter may be represented in the form of numbers, characters, etc. For example, if the value of the above-mentioned preset parameter is 1, it indicates that the above-mentioned socket access function is a blocking function, and if the value of the above-mentioned preset parameter is 0, it indicates that the above-mentioned socket access function is a non-blocking function.

[0076] Since the above-mentioned execution object can only trigger the above-mentioned target object to be in a blocked state when the above-mentioned socket access function is a blocking function, it is necessary to determine whether the above-mentioned preset parameters indicate blocking the above-mentioned target object before triggering the above-mentioned target object to be in a blocked state. If so, the above-mentioned target object is triggered to be in a blocked state.

[0077] In addition, during the execution of the socket access function, if the data processing operation supported by the virtual socket is not obtained, the blocking state of the target object will be released after the operating system times the access to the virtual socket to a timeout period, so that the target object can continue to perform the preset data processing.

[0078] Otherwise, if the execution object can obtain the data processing operation supported by the virtual socket, the work of the execution object is completed, the execution object will terminate directly, and the blocking state of the target object will be released, so that the target object continues to perform the preset data processing.

[0079] It can be seen that if the execution object can obtain the data processing operation supported by the virtual socket, the execution object may end its operation before the operating system reaches the timeout period, and release the blocking state of the target object. However, since the purpose of the embodiment of the present invention is to time the timeout period, so that the target object is in a blocked state and suspends its operation within the timer period, if the execution object can obtain the data processing operation supported by the virtual socket, the execution object may end its operation in advance, so that the target object's suspension period does not reach the timeout period.

[0080] To this end, the access mode indicated by the above-mentioned socket access function in the embodiment of the present invention is: a mode of not obtaining data processing operations supported by the virtual socket, that is, the above-mentioned socket access function will not actually obtain data processing operations supported by the virtual socket, and there is no situation where the above-mentioned execution object can obtain data processing operations supported by the virtual socket. In this way, the above-mentioned execution object will end its operation after the running timeout period, and then release the blocking state of the target object, thereby ensuring that the duration of the suspension of the above-mentioned target object is the above-mentioned timeout period.

[0081] In one embodiment of the present invention, the socket access function may be: a function provided by the operating system and used to access the virtual socket, or may be a user-defined function.

[0082] Furthermore, the socket access function is used to trigger the operating system to time the duration of accessing the virtual socket after triggering the target object to be in a blocked state.

[0083] Specifically, the socket access function may be a select function, and the select function may determine whether the virtual socket may perform operations of reading and writing data.

[0084] In one embodiment of the present invention, a file descriptor can be pre-created as a parameter of the above select, and the above file descriptor is a data set used to represent the path of the socket, and each bit of data in the file descriptor corresponds to a socket. The select function can determine the socket to be accessed through the file descriptor. If the value of a bit of data in the file descriptor is a first preset value, it means that the select function needs to access the socket corresponding to the bit of data. If the value of a bit of data is a second preset value, it means that the select function does not need to access the socket corresponding to the bit of data. For example, the above first preset value can be 1, and the second preset value can be 0.

[0085] Specifically, a file descriptor may be defined, the data type of the file descriptor is of fd_set type, the FD_ZERO function is called to set the values ​​of each bit of the file descriptor to the second preset value, and the FD_SET function is called to set the value of one bit of the file descriptor corresponding to the virtual socket to the first preset value. Therefore, the select function can access the virtual socket according to the file descriptor with the value set.

[0086] In addition, the value of the preset parameter in the above select function can be set to a value indicating that the above target object is blocked, and the above select function is a blocking function. The value of the timeout duration parameter of the select function can also be set to the above timeout duration, indicating that the select function ends its operation when the above timeout duration is executed but the data processing operation supported by the virtual socket is not obtained. Furthermore, the parameters in the above select function indicating whether the virtual socket can support the data reading operation and the parameters indicating whether the virtual socket can support the data writing operation can be set to 0, thereby indicating that the above select function will not determine whether the virtual socket can support the data reading operation and the data writing operation.

[0087] Therefore, the select function can access the virtual socket according to the file descriptor, and since the select function is a blocking function, the target object will be in a blocked state after the execution object accesses the virtual socket. Since the select function will not determine whether the virtual socket can support data reading and writing operations, the select function will not get a definite result, and will continue to execute until the duration of accessing the virtual socket reaches the timeout duration. Therefore, the execution object will end its operation after running for the timeout duration, and then release the blocking state of the target object, so that the target object will be in a blocked state and suspend its operation within the timeout duration, and continue to run after the timeout duration.

[0088] As can be seen from the above, since the above-mentioned socket access function is a blocking function, when the above-mentioned execution object starts to run, it will trigger the above-mentioned target object to be in a blocking state, causing the target object to suspend operation. In addition, the above-mentioned socket access function does not obtain the data processing operation supported by the virtual socket. Since the above-mentioned socket access function will not obtain any access results, it will continue to run until the running time reaches the timeout period, and then end the operation, and release the blocking state of the above-mentioned target object, so that the above-mentioned target object continues to perform the preset data processing. That is, the above-mentioned target object is in a blocked state and suspends operation within the above-mentioned timeout period, and will continue to run after the above-mentioned timeout period. Therefore, using the above-mentioned socket access function to access the above-mentioned virtual socket can control the operation of the target object, thereby controlling the application.

[0089] Corresponding to the aforementioned application control method, an application control device is also provided in an embodiment of the present invention.

[0090] See also Figure 3 The embodiment of the present invention provides a schematic diagram of the structure of an application control device, which is applied to an application. The device includes:

[0091] The state trigger module 301 is used to access the virtual socket and control the target object to be in a blocked state when there is a timing requirement for the target object, wherein the target object is a process or thread used by the application to perform preset data processing, and the virtual socket is a virtual socket pre-created by the application;

[0092] A timing trigger module 302, used to trigger the operating system installed in the electronic device where the application is located to time the access duration of the virtual socket;

[0093] The data processing module 303 is used to release the blocking state of the target object after determining that the timing duration of the operating system reaches the timeout duration of accessing the virtual socket, and perform the preset data processing based on the target object.

[0094] As can be seen from the above, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is achieved with the help of the virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be achieved. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is achieved. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0095] In one embodiment of the present invention, the state triggering module 301 is specifically used for:

[0096] When a timing requirement exists for a target object, a socket access function is called to access a virtual socket in an access mode indicated by the socket access function, and when a preset parameter of the socket access function indicates that the target object is to be blocked, the target object is triggered to be in a blocked state, wherein the access mode is a mode of not obtaining data processing operations supported by the virtual socket.

[0097] As can be seen from the above, since the above-mentioned socket access function is a blocking function, when the above-mentioned execution object starts to run, it will trigger the above-mentioned target object to be in a blocking state, causing the target object to suspend operation. In addition, the above-mentioned socket access function does not obtain the data processing operation supported by the virtual socket. Since the above-mentioned socket access function will not obtain any access results, it will continue to run until the running time reaches the timeout period, and then end the operation, and release the blocking state of the above-mentioned target object, so that the above-mentioned target object continues to perform the preset data processing. That is, the above-mentioned target object is in a blocked state and suspends operation within the above-mentioned timeout period, and will continue to run after the above-mentioned timeout period. Therefore, using the above-mentioned socket access function to access the above-mentioned virtual socket can control the operation of the target object, thereby controlling the application.

[0098] In one embodiment of the present invention, the socket access function is: a function provided by the operating system and used to access a virtual socket;

[0099] The socket access function is used to: trigger the operating system to time the duration of access to the virtual socket after triggering the target object to be in a blocked state.

[0100] In one embodiment of the present invention, the data processing module 303 is specifically used for:

[0101] After monitoring a timeout event, the blocking state of the target object is released, and the preset data processing is performed based on the target object, wherein the timeout event is an event triggered after the timing duration of the operating system reaches a preset timeout duration.

[0102] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.

[0103] Memory 403, used for storing computer programs;

[0104] The processor 401 is used to implement any method step described in the above-mentioned application control method when executing the program stored in the memory 403.

[0105] In the case of applying the electronic device control application provided by the embodiment of the present invention, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is realized by means of the above virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be realized. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is realized in this way. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0106] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0107] The communication interface is used for communication between the above terminal and other devices.

[0108] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0109] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0110] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the above-mentioned application control method is implemented.

[0111] In the case of executing the computer program stored in the computer-readable storage medium provided by the embodiment of the present invention to control the application, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is realized by means of the above virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be realized. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is realized in this way. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0112] In another embodiment of the present invention, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to execute any method step of the above-mentioned application control method.

[0113] In the case of executing the computer program control application provided by the embodiment of the present invention, a virtual socket is created and started in the solution provided by the embodiment of the present invention, and timing is realized by means of the above virtual socket. Specifically, by accessing the virtual socket, the target object is triggered to be in a blocked state, that is, the target object is suspended, and the operating system is triggered to perform timing. After the operating system timing reaches the timeout period, the blocking state of the target object is released, that is, the target object continues to run. That is to say, within the above timeout period, the target object is suspended, and after the timeout period, the target object continues to run, so that the control of the target object can be realized. Since the target object is a process or thread used by the application to perform preset data processing, the control of the application operation is realized. In addition, since most operating systems time the access duration of the socket through a timing function based on the kernel state, the accuracy of the timing function of the kernel state is often higher than the accuracy of the timing function of the user state provided by the operating system, the accuracy of the access duration of the timing socket in the solution provided by the embodiment of the present invention is higher, and then the accuracy of controlling the application according to the timing result is higher.

[0114] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0115] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0116] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for devices, electronic devices, computer-readable storage media, and computer program products, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0117] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. An application control method, It is characterized in that Applied to an application program, the method comprises: When there is a timing requirement for the target object, the virtual socket is accessed through the execution object, and the target object is controlled to be in a blocked state, wherein the target object is a process or thread used by the application to execute preset data processing, the virtual socket is: a virtual socket pre-created by the application, the execution object is another process or thread outside the target object, and in the process of accessing the virtual socket, the execution object does not obtain the data processing operation supported by the virtual socket; Triggering the operating system installed in the electronic device where the application is located to time the access to the virtual socket; After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, the blocking state of the target object is released, and the preset data processing is performed based on the target object.

2. The method according to claim 1, It is characterized in that The accessing the virtual socket and controlling the target object to be in a blocked state includes: By calling a socket access function, a virtual socket is accessed in an access mode indicated by the socket access function, and when a preset parameter of the socket access function indicates that the target object is blocked, the target object is triggered to be in a blocked state, wherein the access mode is: a mode of not obtaining data processing operations supported by the virtual socket.

3. The method according to claim 2, It is characterized in that The socket access function is: a function provided by the operating system for accessing a virtual socket; The socket access function is used to: trigger the operating system to time the duration of access to the virtual socket after triggering the target object to be in a blocked state.

4. The method according to any one of claims 1 to 3, It is characterized in that After determining that the timing duration of the operating system reaches the timeout duration for accessing the virtual socket, releasing the blocking state of the target object includes: After a timeout event is monitored, the blocking state of the target object is released, wherein the timeout event is an event triggered after the timing duration of the operating system reaches a preset timeout duration.

5. An application control device, It is characterized in that Applied to an application program, the device comprises: A state trigger module, used for accessing a virtual socket through an execution object when a timing requirement exists for a target object, and controlling the target object to be in a blocked state, wherein the target object is a process or thread used by the application to execute preset data processing, the virtual socket is: a virtual socket pre-created by the application, the execution object is another process or thread outside the target object, and in the process of accessing the virtual socket, the execution object does not obtain a data processing operation supported by the virtual socket; A timing trigger module, used to trigger the operating system installed in the electronic device where the application is located to time the access duration of the virtual socket; The data processing module is used to release the blocking state of the target object after determining that the timing duration of the operating system reaches the timeout duration of accessing the virtual socket, and perform the preset data processing based on the target object.

6. The device according to claim 5, It is characterized in that The state trigger module is specifically used for: When a timing requirement exists for a target object, a socket access function is called to access a virtual socket in an access mode indicated by the socket access function, and when a preset parameter of the socket access function indicates that the target object is to be blocked, the target object is triggered to be in a blocked state, wherein the access mode is a mode of not obtaining data processing operations supported by the virtual socket.

7. The device according to claim 6, It is characterized in that The socket access function is: a function provided by the operating system and used to access the virtual socket; The socket access function is used to: trigger the operating system to time the duration of access to the virtual socket after triggering the target object to be in a blocked state.

8. The device according to any one of claims 5 to 7, It is characterized in that The data processing module is specifically used for: After monitoring a timeout event, the blocking state of the target object is released, and the preset data processing is performed based on the target object, wherein the timeout event is an event triggered after the timing duration of the operating system reaches a preset timeout duration.

9. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 4 when executing a program stored in a memory.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 4 are implemented.