Control method and device for operating application program based on browser, equipment and medium

By creating the kernel and system call interface of the operating system in the browser, and using the communication channel to process application requests, the problem of how the browser operating system handles application requests is solved, the service call between the application and the kernel is realized, and the technology is filled. blank.

CN118819879APending Publication Date: 2024-10-22DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310409295.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-17
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

The existing technology has not yet proposed a mature solution on how to use the operating system created in the browser to handle the request of the JS program in Node.js run by the browser to provide the services required by the application that exist in the operating system.

Method used

By creating the kernel of the operating system in the browser, a system call interface is provided, and through a pre-established communication channel, the application's data processing request is sent to the system call interface in the kernel, the system service is called to process the request, and the processing result is Return to application.

Benefits of technology

It enables applications in user space to call services provided by the kernel, solves the problem of how the browser operating system handles application requests, fills the technical gap, and ensures the isolation between applications and the kernel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819879A_ABST
    Figure CN118819879A_ABST
Patent Text Reader

Abstract

The invention discloses a control method and device for operating an application program based on a browser, equipment and a medium, which are used for providing a scheme for processing a request of the application program by utilizing an operating system created in the browser and filling the technical blank in the prior art. The method comprises the steps that a data processing request sent by an application program based on a first interface is received, the first interface is an interface which corresponds to a system calling interface in a kernel of an operating system created in a browser and is called by the application program, and a communication channel is established between the system calling interface and the first interface; transmitting the data processing request to a system calling interface in the kernel through the communication channel, and calling a system service in the kernel to process the data processing request; receiving processing result data of the system service for the data processing request returned from the system calling interface; and transmitting the processing result data to the first interface through the communication channel, and sending the processing result data to the application program by the first interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a control method, device, electronic device and computer-readable storage medium for running an application based on a browser. Background Art

[0002] An operating system is a system that provides software and hardware management and an interactive interface for resource calls. The emergence of WebAssembly (a binary instruction set based on a stack-based virtual machine, referred to as Wasm) and the new application programming interface (Application Program Interface, API) makes it possible to write and create an operating system based on Wasm.

[0003] Currently, for example, you can use emscripten technology to compile a Wasm-based Linux operating system, and use a browser to run the compiled Linux operating system to achieve the purpose of creating a Linux operating system in the browser.

[0004] However, using an operating system created in a browser, how to process requests from JS programs (generally referred to as applications) in Node.js (Node.js is a JavaScript runtime environment, referred to as JS runtime environment) running in the browser to provide services that exist in the operating system and are required by the application, the prior art has not yet proposed a mature solution. Summary of the invention

[0005] The disclosed embodiment provides a control method for running an application based on a browser, so as to provide a solution for processing application requests by using an operating system created in a browser, thereby filling this technical gap in the prior art.

[0006] The embodiments of the present disclosure also provide a control device, an electronic device, and a computer storage medium for running an application based on a browser.

[0007] The embodiments of the present disclosure adopt the following technical solutions:

[0008] A control method for running an application based on a browser, comprising: receiving a data processing request sent by the application based on a first interface, wherein the first interface is an interface corresponding to a system call interface in a kernel of an operating system created in the browser and is used for the application to call, and a communication channel is established between the system call interface and the first interface; transmitting the data processing request to the system call interface in the kernel through the communication channel to call a system service in the kernel to process the data processing request; receiving processing result data of the system service for the data processing request returned from the system call interface; transmitting the processing result data to the first interface through the communication channel, and the first interface sends the processing result data to the application.

[0009] A control device for running an application based on a browser, comprising: a request receiving unit, used to receive a data processing request sent by the application based on a first interface, wherein the first interface is an interface corresponding to a system call interface in the kernel of an operating system created in the browser and for the application to call, and a communication channel is established between the system call interface and the first interface; a calling unit, used to transmit the data processing request to the system call interface in the kernel through the communication channel, so as to call a system service in the kernel to process the data processing request; a data receiving unit, used to receive processing result data of the system service for the data processing request returned from the system call interface; and a transmission unit, used to transmit the processing result data to the first interface through the communication channel, and the first interface sends the processing result data to the application.

[0010] An electronic device, comprising: a memory and a processor, wherein:

[0011] The memory is used to store programs;

[0012] The processor is coupled to the memory and is used to execute the program stored in the memory, so as to execute the control method of running an application based on a browser as described above.

[0013] A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer, can implement the above-mentioned control method for running an application based on a browser.

[0014] At least one of the above technical solutions adopted in the embodiments of the present disclosure can achieve the following beneficial effects:

[0015] Due to the isolation relationship between the kernel space and the user space, the application running in the user space cannot directly call the system call interface. However, by adopting the scheme provided by the embodiment of the present disclosure, the application can call the first interface corresponding to the system call interface and available for the application to call. Specifically, the application can send a data processing request to the first interface, so that the first interface sends the request to the system call interface in the kernel for processing through a pre-established communication channel between the first interface and the system call interface in the kernel. Subsequently, based on the communication channel, the system call interface transmits the processing result data of the request to the first interface, and the first interface sends the processing result data to the application, thereby meeting the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:

[0017] Figure 1 A schematic diagram of a specific structure of a control system for running an application based on a browser provided in an embodiment of the present disclosure;

[0018] Figure 2a A diagram showing the corresponding relationship between the root process, the child process created by the root process, and the application running in the user space;

[0019] Figure 2b A schematic diagram of the overall process from sending a request to "create a new process" to receiving the processing result data for the application;

[0020] Figure 3a A schematic diagram of a specific implementation flow of a control method for running an application based on a browser provided in an embodiment of the present disclosure;

[0021] Figure 3b A schematic diagram of a specific implementation flow of another control method for running an application based on a browser provided in an embodiment of the present disclosure;

[0022] Figure 3c A schematic diagram of a specific implementation flow of another control method for running an application based on a browser provided in an embodiment of the present disclosure;

[0023] Figure 4a A schematic diagram of a specific implementation process of the solution provided in the embodiment of the present disclosure in practice;

[0024] Figure 4b A schematic diagram of the interaction between kernel space and user space in a specific application scenario;

[0025] Figure 5a A schematic diagram of a specific structure of a control device for running an application based on a browser provided in an embodiment of the present disclosure;

[0026] Figure 5b A schematic diagram of the specific structure of another control device for running an application based on a browser provided in an embodiment of the present disclosure;

[0027] Figure 5c A schematic diagram of the specific structure of another control device for running an application based on a browser provided in an embodiment of the present disclosure;

[0028] Figure 6 A schematic diagram of the structure of an electronic device provided in Example 6 of the present disclosure. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure will be clearly and completely described below in combination with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.

[0030] Those skilled in the art may appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0031] The terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable when appropriate, which is merely a way of distinguishing objects of the same attributes when describing the embodiments of the present disclosure. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, so that a process, method, system, product, or device that includes a series of units is not necessarily limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0032] Example 1

[0033] In order to solve the problem in the prior art of how to use an operating system created in a browser to process a request of an application program, an embodiment of the present disclosure provides a control solution for running an application program based on a browser.

[0034] First, the embodiment of the present disclosure provides a control system based on running an application program in a browser. The specific structural diagram of the system is shown in FIG. Figure 1 As shown, it includes a kernel 11 and a system call interface information exposure module 12. Among them:

[0035] Kernel 11 is the kernel of the operating system created in the browser;

[0036] The kernel is used to provide a system call interface (ie, System Call, also referred to as Syscall) running in the kernel space.

[0037] The system call interface information exposure module 12 is used to perform the following operations:

[0038] Exposing an interface (the interface may be referred to as a first interface) corresponding to the System Call and available for invocation by the application program running in the user space;

[0039] Receiving a data processing request sent by the application to the first interface exposed by the system call interface exposure module 12;

[0040] Sending the data processing request sent by the application to the System Call in the kernel 11 for processing through a pre-established communication channel between the first interface and the system call interface in the kernel;

[0041] The processing result data of the data processing request returned by the System Call is transmitted to the first interface through the communication channel, so that the first interface can return the processing result data to the application program later.

[0042] The data processing request is sent to the System Call in the kernel 11 for processing, which specifically includes: the data processing request is sent to the System Call in the kernel 11, and the System Call calls the system service matching the data processing request in the kernel for processing.

[0043] In the disclosed embodiment, the user space includes an instance created by a Webworker (ie, a worker instance). The worker instance is created by calling a Webworker interface of a browser.

[0044] Webworker, also known as worker thread, is part of the HTML5 standard (the next generation standard of the Internet, a language for building and presenting Internet content, and considered one of the core technologies of the Internet). This standard defines a set of APIs, including the above-mentioned Webworker interface. By creating a worker instance based on the Webworker interface, a JS program can be allowed to run in another thread outside the main thread (such as a child thread of the main thread).

[0045] One of the main functions of Webworker is to create a multi-threaded environment for JS programs, allowing the main thread to create child threads (called worker child threads, which can be used to create worker instances so that JS programs can run in worker instances), and the worker child threads can run independently of the main thread. Based on the created worker child threads, some tasks that may block the main thread can be assigned to the worker child threads for processing, so that the tasks run by the main thread (such as a JS program) and the tasks run by the worker child threads (such as another JS program) do not interfere with each other. After the worker child thread completes the task processing, it can return the processing results to the main thread through the message mechanism, thus making full use of the advantages of multi-threading.

[0046] To create a worker sub-thread based on Webworker, the browser can call the worker() constructor and pass in a Uniform Resource Identifier (URI) of a JS program to be run in the worker sub-thread, and then create a worker sub-thread for executing the JS program.

[0047] In order to make the readers clearly understand the control system based on the browser running the application provided by the embodiment of the present disclosure, some technical terms mentioned in the above solution are further explained below:

[0048] 1. Kernel

[0049] The kernel is the core of the operating system. It is the first layer of software expansion based on hardware, providing the most basic functions of the operating system and the basis of the operating system. It is responsible for managing the operating system's processes, memory, device drivers, files, and network systems, and determines the performance and stability of the operating system. The kernel sets up a group of subroutines for implementing system functions, called the system call interface (System Call). System Call is very similar to ordinary library function calls, except that System Call is provided by the kernel and runs in kernel mode, while ordinary function calls are provided by function libraries or users themselves and run in user mode.

[0050] The above-mentioned "process" is the smallest unit of resource allocation of the central processing unit (CPU) of a computing device, and is the smallest unit that can have resources and run independently. The literal meaning of a process is an ongoing program. It is understood as a task program that can run independently and has its own resource space. A process includes the running program and the memory and system resources used by the program.

[0051] Processes are independent of each other. At any given moment, the CPU always runs one process, while other processes are not running. The CPU can have many processes. Each time a computing device opens a software, one or more processes will be generated. When the CPU runs a process, other processes are not running. The CPU uses the "time slice round-robin algorithm" to run multiple processes at the same time.

[0052] Generally, a process cannot access the kernel. It cannot access the memory space occupied by the kernel and cannot call kernel functions. In order to interact with processes running in user space, the kernel provides a set of interfaces, which are the above-mentioned System Call. Through System Call, applications can access hardware devices and other operating system resources. SystemCall sends a request to the kernel through an interrupt to call the system service in the kernel, thereby realizing the function of the system service provided by the kernel. This set of interfaces plays the role of a messenger between the application and the kernel. The application sends various requests, and the kernel is responsible for satisfying these requests (or temporarily putting the application on hold). In fact, this set of interfaces is mainly provided to ensure the stability and reliability of the system and to avoid problems caused by the reckless behavior of the application.

[0053] Generally, an application programming interface (API) may require one or more system calls to complete specific functions. Of course, if the application needs to interact with the kernel, then a system call is required, otherwise it is not necessary.

[0054] When an application needs a system service provided by the kernel, the application (such as a JS program running in user space) can directly call the API, and then complete the function through the API and the System Call. Therefore, the API is an interface provided to the application. It is a set of functions that directly interact with the application written by the programmer. The System Call does not interact with the application. It responds to the call of the API function and submits a request to the kernel through a soft interrupt mechanism to obtain the interface of the kernel service.

[0055] It should be noted that in the embodiments of the present disclosure, as described in the background technology section, the operating system can be created in the browser according to the current technology. The kernel described in the embodiments of the present disclosure refers to the kernel of the operating system created in the browser.

[0056] 2. Kernel space and user space: Kernel space is the operating space of the kernel, and user space is the operating space of the application. For security reasons, these two spaces are isolated, so that even if the application crashes, the kernel space will not be affected. The kernel space can execute any command and call all system resources; while the user space can only perform simple operations and cannot directly call system resources. It must go through System call before the user space can issue instructions to the kernel space.

[0057] In the control system for running applications based on a browser provided by the embodiment of the present disclosure, the kernel space is the operating space of the kernel of the operating system created in the browser. The kernel of the operating system created in the browser can provide System calls. The provided System calls can at least include: process control, file read and write operations, and socket control.

[0058] The process control described in the embodiments of the present disclosure refers to the general term for System calls related to the process, as shown in Table 1 below. The process control may include but is not limited to these System calls. The specific description of these System calls is detailed in Table 1.

[0059] Table 1:

[0060] The name of the system call included in the process control Description of System call fork Create a new process clone Create a new process based on specified conditions exit Terminating a process wait Wait for the child process to terminate ... ...

[0061] The file read and write operations described in the embodiments of the present disclosure refer to the general term for System calls related to file read or write operations, as shown in Table 2 below. The file read and write operations may include but are not limited to these System calls. The specific description of these System calls is detailed in Table 2.

[0062] Table 2:

[0063]

[0064]

[0065] Socket, or socket, is an abstraction of an endpoint for bidirectional communication. The socket control described in the embodiments of the present disclosure refers to the general term for System calls related to bidirectional communication, as shown in Table 3 below. Socket control may include but is not limited to these System calls. The specific description of these System calls is detailed in Table 3.

[0066] Table 3:

[0067] The name of the System call contained in the Socket control Description of System call socket Create a socket listen Listening socket port accept Respond to socket connection request send Sending information via socket ... ...

[0068] In addition to the above system calls, the kernel can also provide system calls including but not limited to: file system operations; system control; memory management; network management; user management; inter-process communication; signals; messages; pipes; semaphores; shared memory.

[0069] Which system calls the kernel provides can be compiled by programmers when compiling the operating system that can be run by the browser, depending on specific needs. The operating system described in the embodiments of the present disclosure can be compiled based on Wasm. By running the compiled operating system, the browser can provide a kernel space for the system call to run.

[0070] In the disclosed embodiment, the user space includes a worker instance. The worker instance is created by calling the Webworker interface of the browser. The application running in the user space (i.e., running in the worker instance) may include but is not limited to a JS program.

[0071] The application described in the embodiment of the present disclosure runs in the "user space" created by calling the Webworker interface of the browser; the System Call described in the embodiment of the present disclosure runs in the "kernel space" where the kernel of the operating system created in the browser runs.

[0072] Since user space and kernel space are isolated from each other, if an application wants to use services provided by the kernel, such as process control services, file read and write operation services, or socket control services, a solution is needed to support the application to cross the user space and submit its needs to the kernel space.

[0073] The embodiment of the present disclosure provides such a solution, specifically: the system call interface information exposure module 12 exposes the first interface (the interface that can be called by the application, i.e., API) corresponding to the System Call to the application running in the user space. As mentioned above, although the application cannot directly call the System Call, it can call the API. Therefore, the application can call the exposed first interface by sending a data processing request to the first interface exposed by the system call interface information exposure module 12.

[0074] Subsequently, the system call interface information exposure module 12 can send the data processing request to the target System Call in the kernel through the communication channel between the pre-established first interface and the system call interface in the kernel, and the target System Call calls the system service processing in the kernel to process the data processing request. Subsequently, based on the communication channel, the "processing result data of the system service for the data processing request" returned by the target System Call is transmitted to the first interface, and the first interface sends the processing result data to the application, thereby satisfying the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art.

[0075] In an optional implementation, the system provided by the embodiment of the present disclosure may further include an initialization module, and the initialization module may use the following steps a to c to enable the application to run in the worker instance:

[0076] Step a: Initialize the root process of the browser;

[0077] The root process of the browser can also be called the init process of the browser. Only one root process is created in the browser. The functions of the root process mainly include but are not limited to: 1) Responsible for the browser interface display, interaction with users, URL bar input, forward and backward, etc.; 2) Responsible for managing various windows / pages (Window), creating and destroying processes; 3) Writing page content to the browser memory and finally displaying the image on the screen; 4) File storage and other functions.

[0078] In the disclosed embodiment, when the browser is started, the kernel of the operating system created in the browser will initialize the root process. The root process runs silently in the background of the browser until the browser is closed. Therefore, the initialization module can be a module in the kernel; or, it can also be a module that has the function of initializing the root process but is relatively independent of the kernel.

[0079] Step b: Using the initialized root process to create a child process for running the application;

[0080] like Figure 2a As shown in the figure, it is a schematic diagram of the corresponding relationship between the root process, the child process created by the root process, and the application running in the user space. Figure 2a The root process is represented by a box with init written on it; a single child process is represented by a single box with sub task written on it; and a single application is represented by a single box with user space written on it.

[0081] also, Figure 2a The box with name in it indicates the exposed first interface. The "syscall" between the first interface and the application indicates that the application calls the first interface in a "syscall" type of calling mode, which means that the application's call to the first interface requires support from the kernel's system service, so that calling the first interface in this calling mode will trigger the first interface to call the System Call corresponding to the first interface.

[0082] In the disclosed embodiment, the child process created by the root process can be used to run the application. Since the running application may need to display information, the child process can also be used to display the browser page. It can be used to display the running results of the application, such as the application interface, which can be displayed in the page.

[0083] In addition, the initialization module can also be used to use the subprocess to run a pre-set script to implement the function of the system call interface exposure module 12 - the function of this module is as described above, and may include but is not limited to:

[0084] Expose the System Call interface to the application running in the user space, that is, the first interface. Figure 2a In the figure, the first interface is represented as a box with a name written on it, and the box with a name written on it can represent one interface, or can represent several interfaces; a data processing request sent by an application program by calling the interface is received; through a pre-established communication channel between the interface and the System Call in the kernel, the request is sent to the System Call in the kernel for processing, so that the System Call can call the system service in the kernel to process the data processing request; and based on the communication channel, "the processing result data of the system service for the data processing request" returned by the System Call is transmitted to the first interface, and the first interface sends the processing result data to the application program.

[0085] In order to realize the functions of the system call interface exposure module 12, the script accordingly includes codes that can realize the functions of the system call interface exposure module 12 after being executed.

[0086] In addition, the initialization module can also be used to use the subprocess to run the script to establish a communication channel between the interface that can be called by the application and the System Call in the kernel, so that the data processing request sent by the application to the System Call via the interface can be received based on the communication channel.

[0087] Accordingly, in such a case, the script includes codes that can establish the communication channel after being executed.

[0088] Step c: Using the child process created by executing step b, calling the Webworker interface of the browser to create a worker instance. The created worker instance is used to run the application.

[0089] The running result of the application, such as the application interface, etc., can be displayed in a page of the browser displayed based on the child process.

[0090] In an optional implementation, if the System Call provided by the kernel includes: process control, file read and write operations, and socket control, and at the same time, if the data processing request sent by the application includes: pending process processing requests, pending file read and write requests, and pending network connection requests, then the system call interface information exposure module 12 can be further refined to include: process management module, file system, and network implementation module.

[0091] The process management module is used to expose the first interface corresponding to the process control to the application program and can be called by the application program (in Figure 2a denoted as name), so that the first interface performs the following operations:

[0092] Receive a pending process processing request sent by an application to the first interface; send the pending process processing request to the process control for processing through a pre-established communication channel between the first interface and the process control.

[0093] The file system is used to expose the interface corresponding to the file read and write operations to the application program (for the convenience of distinguishing descriptions, it can be called the second interface. Figure 2a (which can also be represented as name) so that the second interface performs the following operations:

[0094] Receive a file read / write request sent by an application to a second interface; send the file read / write request to be processed to the file read / write operation for processing through a pre-established communication channel between the second interface and the file read / write operation.

[0095] The network implementation module is used to expose the interface corresponding to the socket control to the application program (for the convenience of distinguishing descriptions, it can be called the third interface. Figure 2a (which can also be represented as name) so that the third interface performs the following operations:

[0096] The receiving application sends a pending network connection request to the system call interface exposure module 12 by calling the third interface; and sends the pending network connection request to the socket control for processing through a pre-established communication channel between the third interface and the socket control.

[0097] In an optional implementation, the interface sends the data processing request sent by the application to SystemCall, and SystemCall calls the system service matching the data processing request in the kernel for processing, which may specifically include:

[0098] By adopting a communication method across user space and kernel space, the data processing request is sent to SystemCall, and System Call calls the system service in the kernel to process the data processing request.

[0099] The above-mentioned “communication method across user space and kernel space” includes, but is not limited to: at least one of a communication method based on MessageChannel and a communication method based on BroadcastChannel.

[0100] Continuing with the previous example, in an optional implementation, if the System Call provided by the kernel includes: process control, file read and write operations, and socket control, and at the same time, if the data processing request sent by the application includes: pending process processing requests, pending file read and write requests, and pending network connection requests, then the system services that can handle the pending process processing requests, pending file read and write requests, and pending network connection requests are: process scheduler, file read and write service, and network connection service, respectively.

[0101] In a specific example, Figure 2bAs shown, taking the case where the pending process processing request sent by the application is a request for "creating a new process", after the request is sent to the first interface, the first interface sends the new process creation request to the System Call "fork" through the communication channel pre-established between the first interface and the System Call "fork"; after receiving the request, the System Call "fork" calls the process scheduler in the kernel to perform a new process creation operation based on the request - specifically, schd (i.e., process scheduler) can be called to create a new process; after the new process is created, the process scheduler returns the corresponding processing result data to the System Call "fork", and then the SystemCall "fork" sends the processing result data to the first interface through the communication channel, and then sends it to the user program by the first interface.

[0102] Among them, if the request of "creating a new process" is specifically a request from the parent process to create a new child process, the processing result data is the PID of the newly created child process; if a new child process is requested by the child process to create a new child process, the processing result data is 0.

[0103] Although the kernel space and the user space are isolated from each other, and the application running in the user space cannot directly call the System Call, after using the solution provided by the embodiment of the present disclosure, the application can send a data processing request to the first interface, so that the first interface sends the request to the System Call in the kernel for processing through the pre-established communication channel between the first interface and the System Call in the kernel, and the System Call calls the system service in the kernel that matches the data processing request for processing. Subsequently, based on the communication channel, the SystemCall transmits the processing result data of the request to the first interface, and the first interface sends the processing result data to the application, thereby satisfying the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art.

[0104] Example 2

[0105] In order to solve the problem in the prior art of how to use an operating system created in a browser to process application requests, Embodiment 2 of the present disclosure provides a control method for running an application based on a browser.

[0106] The execution subject of the method may be a browser, or a script running in the browser. The embodiments of the present disclosure do not limit the specific execution subject used to execute the method. Any execution subject executing the method is within the protection scope of the present application.

[0107] In addition, different steps of the method can be implemented by different execution entities, and the embodiments of the present disclosure do not limit which execution entity is used to implement which step. At the same time, the embodiments of the present disclosure do not limit the execution order of the various steps included in the method.

[0108] The following takes a script executed by a browser as an example to introduce the specific implementation process of this method.

[0109] The method may specifically include the steps of: exposing a first interface corresponding to SystemCall provided by the kernel and available for application program call to an application program running in the user space; so that the first interface performs the following operations:

[0110] Receiving a data processing request sent by an application to the first interface;

[0111] The data processing request is sent to the System Call in the kernel through a pre-established communication channel between the interface and the System Call in the kernel, and the System Call calls the system service in the kernel to process the data processing request;

[0112] Receiving processing result data of the system service for the data processing request returned by System Call through the communication channel;

[0113] Send the processing result data to the application.

[0114] The user space includes a worker instance; the worker instance is created by calling the Webworker interface of the browser; the kernel is the kernel of the operating system created in the browser; and the System Call runs in the kernel space.

[0115] In an optional implementation, the worker instance may be created by, but is not limited to, the following steps A to D, and the application is run in the created worker instance:

[0116] Step A: Initialize the browser's root process;

[0117] Step B: using the initialized root process, creating a child process for running the application;

[0118] Step C: using the created child process to call the Webworker interface of the browser to create the worker instance;

[0119] Step D: Run the application in the created worker instance.

[0120] In an optional implementation, the communication channel may include: a communication channel across user space and kernel space.

[0121] In an optional implementation, the System Call provided by the kernel may include: process control, file read / write operation and socket control. Correspondingly, the data processing request may include: pending process processing request, pending file read / write request and pending network connection request.

[0122] Although the kernel space and the user space are isolated from each other, and the application running in the user space cannot directly call the System Call, after applying the above method provided in the embodiment of the present disclosure, the application can send a data processing request to the first interface, so that the first interface sends the request to the System Call in the kernel for processing through the pre-established communication channel between the first interface and the SystemCall in the kernel. Subsequently, based on the communication channel, the processing result data obtained after the System Call processes the request by calling the system service is transmitted to the first interface, and the first interface sends the processing result data to the application, thereby meeting the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art.

[0123] Example 3

[0124] In order to solve the problem in the prior art of how to use an operating system created in a browser to process application requests, Embodiment 3 of the present disclosure provides a control method for running an application based on a browser.

[0125] The execution subject of this method may be, but is not limited to, an application program running in the user space. The embodiment of this disclosure does not limit the execution order of the various steps included in this method.

[0126] like Figure 3a As shown, the method may specifically include the following steps:

[0127] Step 301: The application generates a data processing request;

[0128] The user space includes a worker instance; the worker instance is created by calling the Webworker interface of the browser.

[0129] For details on how to create a worker instance, please refer to the relevant instructions in Example 1 of the present disclosure, which will not be repeated here.

[0130] Step 302: The application sends a data processing request to the first interface, so that the first interface executes: through the communication channel established between System Call and the first interface, the data processing request is transmitted to SystemCall in the kernel, and System Call calls the system service in the kernel to process the data processing request.

[0131] The kernel is the kernel of the operating system created in the browser; the System Call runs in the kernel space.

[0132] The first interface is an interface corresponding to the System Call in the kernel and used for application program calls; the communication channel is established between the System Call and the first interface.

[0133] In an optional implementation, the communication channel includes a communication channel across user space and kernel space.

[0134] In an optional implementation, the worker instance may be created by, but is not limited to, the following steps A to D, and the application is run in the created worker instance:

[0135] Step A: Initialize the browser's root process;

[0136] Step B: using the initialized root process, creating a child process for running the application;

[0137] Step C: using the created child process to call the Webworker interface of the browser to create the worker instance;

[0138] Step D: Run the application in the created worker instance.

[0139] In an optional implementation manner, the first interface that can be called by the application is exposed in the following manner:

[0140] The subprocess is used to run a preset script to expose the first interface that can be called by the application program; wherein the script contains code that can expose the first interface that can be called by the application program to the application program after execution.

[0141] In an optional implementation, the communication channel is established by the subroutine running the script; the script includes code that can establish the communication channel after execution.

[0142] Embodiment 3 of the present disclosure also provides a control method for running an application based on a browser, and the execution subject of the method may be, but is not limited to, a System Call running in the kernel space. The embodiment of the present disclosure does not limit the execution order of the various steps included in the method.

[0143] The method may specifically include: Figure 3b The following steps are shown:

[0144] Step 311: receiving a data processing request sent by an application based on a first interface;

[0145] The first interface is an interface corresponding to the System Call in the kernel of the operating system created in the browser and used for the application to call.

[0146] A communication channel is established between the System Call and the first interface.

[0147] Step 312: Transmit the data processing request to the System Call in the kernel through the communication channel, and call the system service in the kernel to process the data processing request;

[0148] Step 313: receiving the processing result data of the system service for the data processing request returned from the System Call;

[0149] Step 314: The processing result data is transmitted to the first interface through the communication channel, and the first interface sends the processing result data to the application.

[0150] Embodiment 3 of the present disclosure further provides a control method for running an application based on a browser, and the execution subject of the method may be, but is not limited to, the first interface. The embodiment of the present disclosure does not limit the execution order of the various steps included in the method.

[0151] The method may specifically include: Figure 3c The following steps are shown:

[0152] Step 321: receiving a data processing request sent by an application based on a first interface;

[0153] The first interface is an interface corresponding to a System Call in a kernel of an operating system created in a browser and used for the application to call, and a communication channel is established between the System Call and the first interface;

[0154] Step 322: Transmitting the data processing request to the System Call in the kernel through the communication channel established between the System Call and the first interface, so as to call the system service in the kernel to process the data processing request;

[0155] Step 323: receiving the processing result data of the system service for the data processing request returned from the System Call;

[0156] Step 324: Send processing result data to the application.

[0157] For Figure 3b and Figure 3c The method shown has the following optional implementations:

[0158] In an optional implementation, the application runs in a user space; the user space includes an instance created by a worker thread; and the instance is created by calling a Webworker interface of the browser.

[0159] In an optional implementation manner, the following method may be adopted to enable the application to run in the instance:

[0160] Initializing the root process of the browser;

[0161] Using the initialized root process, create a child process for running the application;

[0162] Using the child process to call the Webworker interface of the browser to create the instance;

[0163] The user program is run in the created instance.

[0164] In an optional implementation manner, the first interface may be exposed to the application in the following manner:

[0165] The subprocess is used to run a preset script to expose the first interface to the application program, wherein the script includes code that can expose the first interface to the application program after execution.

[0166] In an optional implementation, the communication channel may be established in the following manner:

[0167] The script is run by the subroutine to establish the communication channel, wherein the script includes code that can establish the communication channel between the first interface and the System Call after execution.

[0168] Due to the isolation relationship between the kernel space and the user space, the application running in the user space cannot directly call the system call interface. However, by adopting any of the above methods provided in the embodiments of the present disclosure, the application can call the first interface corresponding to the system call interface and available for the application to call. Specifically, the application can send a data processing request to the first interface, so that the first interface sends the request to the System Call in the kernel for processing through a pre-established communication channel between the first interface and the System Call in the kernel. Subsequently, based on the communication channel, the processing result data obtained by the System Call after processing the request by calling the system service is transmitted to the first interface, and the processing result data is sent to the application by the first interface, thereby meeting the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art.

[0169] Example 4

[0170] In order to enable readers to better understand the solutions provided in Examples 1 to 3 of the present disclosure, in Example 4, the specific implementation process of these solutions in practice is introduced in combination with actual scenarios.

[0171] Please refer to the attached instructions Figure 4a , is a schematic diagram of the specific implementation process of these solutions in practice, which mainly includes the following steps:

[0172] Step 41: When the browser is started, the root process of the browser is initialized;

[0173] Step 42: The browser uses the root process to create a child process for running the target application;

[0174] like Figure 4b , which is a schematic diagram of the interaction between kernel space and user space in a specific application scenario. Figure 4b In the example, the target application can be any one of bash, npm, coreutils, or node.

[0175] In step 42, after receiving the start instruction for the target application, the browser may use the root process to create a child process for running the target application.

[0176] Step 43: The browser uses the child process to call the browser's Webworker interface to create a worker instance;

[0177] Step 44: The browser runs the target application (assuming it is bash) using the created worker instance;

[0178] Step 45: The browser utilizes a child process to run a preset script. By running the script, the following can be achieved: 1. Exposing an interface that can be called by the application (equivalent to the first interface described above) to the target application; 2. Establishing a communication channel between the interface that can be called by the application and the System Call provided by the browser kernel.

[0179] like Figure 4b As shown, it is assumed that the exposed interfaces include: fork, listen, wait and exit. It should be noted that although the names of these interfaces are the same as the System Call in the kernel: fork, listen, wait and exit, there are substantial differences between the exposed interfaces and the System Call. The difference is that the exposed interfaces are APIs, which can be directly called by applications, while the System Call cannot be directly called by applications due to the isolation between user space and kernel space.

[0180] To help readers understand the functions of the script in the embodiments of the present disclosure, Figure 4b In the script, the execution body of the "exposed interface" function is represented as "PCB process control block". PCB is the abbreviation of Process Control Block.

[0181] Since the PCB process control block needs to expose the interface corresponding to System Call (running in KernalSpace) in UserSpace, the capabilities of the PCB process control block will span the kernel space (KernelSpace) provided by the operating system created in the browser and the user space (UserSpace) provided by WebWorker, that is, spanning the two environments of Window and WebWorker.

[0182] from Figure 4b From the above, the PCB process control block spans task and isolate. Task is the instance that runs System Call, while isolate is the instance that runs the script.

[0183] Step 46: Assuming that the target application bash needs to send a request to "create a new process" to the kernel of the operating system - as can be seen from Table 1, the request can be processed by System call "fork" - therefore, the target application sends a new process creation request to the interface "fork" exposed by the PCB process module;

[0184] Step 47: After receiving the new process creation request, the exposed interface "fork" sends the new process creation request to the System Call "fork" according to the pre-established communication channel (such as MessageChannel) between the interface "fork" and the System Call "fork";

[0185] Step 48: After receiving the new process creation request, System Call "fork" calls the relevant function created in the kernel of the browser's operating system according to the parameters in the request to perform corresponding processing. For example, the parameters in the request are used as schd (i.e., process scheduler) shown in 4b to process the request.

[0186] For the specific implementation of step 48, reference may be made to the specific implementation of a process similar to step 48 in the related art, which will not be described in detail here.

[0187] Step 49: System Call "fork" returns the return value obtained after processing the new process creation request to the target application through the interface "fork";

[0188] It should be noted that the System Call "fork" (also known as the fork() function) is used to create a new process from an existing process. The new process is called a child process, and the original process is called a parent process. The child process obtained using the System Call "fork" is a copy of the parent process. It inherits the entire process address space from the parent process, including the process context, code segment, process stack, memory information, open file descriptors, symbolic control settings, process priority, process group number, current working directory, root directory, resource limits and control terminal, etc., while the child process is unique only to its process number, resource usage and timer, etc. Because the child process is almost a complete copy of the parent process, both the parent and child processes will run the same program.

[0189] As for the return value, if the parent process requests to create a child process, the return value returned by System Call "fork" is the PID of the created child process; if the child process requests to create a new child process, the return value returned by System Call "fork" is 0.

[0190] The above is the call to System Call "fork" implemented by the target application bash based on the PCB process control block.

[0191] Similarly, if Figure 4bAs shown, for example, the target application npm can implement the call to System Call "listen" based on the PCB process control block. Since the calling process is similar to the above steps 46 to 48, it will not be repeated here.

[0192] It can be seen from Example 4 that after using the solution provided by any one of Examples 1 to 3 provided by the embodiments of the present disclosure, the application can call the exposed interface corresponding to the System Call that can be called by the application, and the application can send a data processing request to the interface, so that the interface can send the request to the target System Call in the kernel for processing according to the correspondence between the numbers of each System Call and each interface set in advance. Thus, the use requirements of the application in the user space for the services provided by the kernel are met, and the problem of how to use the operating system created in the browser to process the request of the application in the prior art is solved, filling this technical gap in the prior art.

[0193] Example 5

[0194] In order to solve the problem in the prior art of how to use an operating system created in a browser to process application requests, Embodiment 5 of the present disclosure provides a control device for running an application based on a browser.

[0195] The device includes an interface exposure unit. The interface exposure unit is used to expose a first interface corresponding to the System Call provided by the kernel and available for the application to call to the application running in the user space; so that the first interface executes: receiving a data processing request sent by the application to the first interface; sending the request to the SystemCall in the kernel through a pre-established communication channel between the first interface and the System Call in the kernel, and the System Call calls the system service in the kernel to process the data processing request; in addition, the interface exposure unit is also used to receive the processing result data of the system service for the data processing request returned from the System Call; transmitting the processing result data to the first interface through the communication channel, and the first interface sends the processing result data to the application.

[0196] The user space includes a worker instance; the worker instance is created by calling the Webworker interface of the browser; the kernel is the kernel of the operating system created in the browser; and the System Call runs in the kernel space.

[0197] In an optional implementation, the following method may be used to enable the application to run in the worker instance:

[0198] Initializing the root process of the browser;

[0199] Using the initialized root process, create a child process for running the application;

[0200] Using the child process to call the Webworker interface of the browser to create the worker instance;

[0201] In the created worker instance, run the application.

[0202] In an optional implementation, the System Call provided by the kernel includes: process control, file read and write operations and socket control; accordingly, the data processing request includes: pending process processing requests, pending file read and write requests and pending network connection requests.

[0203] In order to solve the problem of how to use the operating system created in the browser to process the request of the application program in the prior art, the embodiment 5 of the present disclosure also provides a control device for running the application program based on the browser. The specific structural diagram of the device is shown in FIG. Figure 5a As shown, including:

[0204] The request receiving unit 501 is used to receive a data processing request sent by the first interface to the System Call in the kernel of the operating system created in the browser through the communication channel;

[0205] The first interface is an interface corresponding to the System Call in the kernel of the operating system created in the browser and is used for application program calls; a communication channel is established between the System Call and the first interface; and the data processing request is sent by the application program to the first interface.

[0206] The calling unit 502 is used to call the system service in the kernel to process the data processing request in response to the data processing request;

[0207] The data return unit 503 is used to receive the processing result data of the system service for the data processing request returned from the system service, and return the processing result data to the first interface through the communication channel. Subsequently, the first interface returns the data processing request to the application.

[0208] In order to solve the problem of how to use the operating system created in the browser to process the request of the application program in the prior art, the embodiment 5 of the present disclosure also provides a control device for running the application program based on the browser. The specific structural diagram of the device is shown in FIG. Figure 5b As shown, including:

[0209] A request receiving unit 511, configured to receive a data processing request sent by an application based on the first interface;

[0210] The first interface is an interface for application program to call corresponding to the system call interface (SystemCall) in the kernel of the operating system created in the browser, and a communication channel is established between SystemCall and the first interface.

[0211] A calling unit 512, used to transmit the data processing request to SystemCall in the kernel through the communication channel, so as to call the system service in the kernel to process the data processing request;

[0212] The data receiving unit 513 is used to receive the processing result data of the system service for the data processing request transmitted through the communication channel and returned by the System Call;

[0213] The transmission unit 514 is used to send the processing result data to the application program.

[0214] In order to solve the problem of how to use the operating system created in the browser to process the request of the application program in the prior art, the embodiment 5 of the present disclosure also provides a control device for running the application program based on the browser. The specific structural diagram of the device is shown in FIG. Figure 5c As shown, including:

[0215] A request generating unit 521, used for generating a data processing request;

[0216] The sending unit 522 is used to send the data processing request to the first interface, so that the first interface executes: the data processing request sent to the System Call in the kernel of the operating system created in the browser through the communication channel;

[0217] The receiving unit 523 is used to receive the processing result data of the data processing request returned by the first interface.

[0218] The first interface is an interface corresponding to the System Call in the kernel of the operating system created in the browser and used for application program to call, and the communication channel is established between the System Call and the first interface.

[0219] The processing result data is the processing result data obtained after the System Call calls the system service in the kernel to process the data processing request. The processing result data is first sent by the system service to the System Call, and then sent by the System Call to the first interface through the communication channel. Further, the processing result data is returned to the receiving unit 523 by the first interface.

[0220] For example Figure 5a , Figure 5b and Figure 5c The control device shown is based on a browser running an application, and the following are some optional implementations:

[0221] In an optional implementation, the application runs in a user space; the user space includes an instance created by a Webworker; and the instance is created by calling a Webworker interface of the browser.

[0222] In an optional implementation manner, the following method may be adopted to enable the application to run in the instance:

[0223] Initializing the root process of the browser;

[0224] Using the initialized root process, create a child process for running the application;

[0225] Using the child process to call the Webworker interface of the browser to create the instance;

[0226] The user program is run in the created instance.

[0227] In an optional implementation manner, the first interface may be exposed to the application in the following manner:

[0228] The subprocess is used to run a preset script to expose the first interface to the application program, wherein the script includes code that can expose the first interface to the application program after execution.

[0229] In an optional implementation, the communication channel may be established in the following manner:

[0230] The script is run by the subroutine to establish the communication channel, wherein the script includes code that can establish the communication channel between the first interface and the System Call after execution.

[0231] By using any of the above-mentioned devices provided in Example 5 of the present disclosure, an application can call the exposed first interface corresponding to the System Call that can be called by the application. Specifically, the application can send a data processing request to the first interface, so that the first interface sends the request to the System Call in the kernel for processing through a pre-established communication channel between the first interface and the SystemCall in the kernel. Subsequently, based on the communication channel, the processing result data obtained after the System Call processes the request by calling the system service is transmitted to the first interface, and the first interface sends the processing result data to the application, thereby satisfying the use requirements of the application in the user space for the services provided by the kernel, solving the problem of how to use the operating system created in the browser to process the request of the application in the prior art, and filling this technical gap in the prior art.

[0232] Example 6

[0233] Based on the same inventive concept as the above-mentioned solution provided in the embodiment of the present disclosure, embodiment 6 of the present disclosure provides an electronic device to solve the problem existing in the prior art of how to use an operating system created in a browser to process application requests.

[0234] like Figure 6 As shown, the electronic device includes: a memory 61 and a processor 62. The memory 61 can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application or method for operating on the electronic device. The memory 61 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk.

[0235] The processor 62 is coupled to the memory 61 and is used to execute the program stored in the memory 61 to execute the method for determining the scene category of the page described in the embodiment of the present disclosure.

[0236] When the processor 62 executes the program in the memory 61, in addition to the above functions, it can also realize other functions, and the details can be referred to the description of the previous embodiments.

[0237] Further, such as Figure 6 As shown, the electronic device also includes: a display 64, a communication component 63, a power component 65, an audio component 66 and other components. Figure 6Only some components are shown schematically, which does not mean that the electronic device only includes Figure 6 Components shown.

[0238] Accordingly, an embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, the steps or functions of the methods provided in the above embodiments can be implemented.

[0239] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0240] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0241] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A control method for running an application based on a browser, characterized in that: include: Receiving a data processing request sent by an application based on a first interface, where the first interface is an interface for the application to call corresponding to a system call interface in a kernel of an operating system created in a browser, and a communication channel is established between the system call interface and the first interface; Transmitting the data processing request to the system call interface in the kernel through the communication channel, and calling the system service in the kernel to process the data processing request; Receiving processing result data of the system service for the data processing request returned from the system call interface; The processing result data is transmitted to the first interface through the communication channel, and the first interface sends the processing result data to the application.

2. The method according to claim 1, characterized in that The application runs in a user space; the user space includes an instance created by a worker thread; the instance is created by calling a worker thread interface of the browser.

3. The method according to claim 1, characterized in that The application is run in the instance in the following manner: Initializing the root process of the browser; Using the initialized root process, create a child process for running the application; Using the child process to call the browser's worker thread interface to create the instance; The user program is run in the created instance.

4. The method according to claim 3, characterized in that The first interface is exposed to the application in the following manner: Using the subprocess to run a preset script to expose the first interface to the application; The script includes code that can expose the first interface to the application after being executed.

5. The method according to claim 4, characterized in that The communication channel is established in the following manner: Utilizing the subroutine to run the script and establish the communication channel; The script includes code that can establish the communication channel between the first interface and the system call interface after being executed.

6. A control device for running an application based on a browser, characterized in that: include: a request receiving unit, configured to receive a data processing request sent by an application based on a first interface, wherein the first interface is an interface corresponding to a system call interface in a kernel of an operating system created in a browser and for the application to call, and a communication channel is established between the system call interface and the first interface; A calling unit, configured to transmit the data processing request to the system call interface in the kernel through the communication channel, so as to call the system service in the kernel to process the data processing request; A data receiving unit, used for receiving the processing result data of the system service for the data processing request returned from the system call interface; A transmission unit is used to transmit the processing result data to the first interface through the communication channel, and the first interface sends the processing result data to the application.

7. The device according to claim 6, characterized in that The application runs in a user space; the user space includes an instance created by a worker thread; the instance is created by calling a worker thread interface of the browser.

8. The device according to claim 6, characterized in that The application is run in the instance in the following manner: Initializing the root process of the browser; Using the initialized root process, create a child process for running the application; Using the child process to call the browser's worker thread interface to create the instance; The user program is run in the created instance.

9. An electronic device, characterized in that: include: Memory and processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to execute the method described in any one of claims 1 to 5.

10. A computer-readable storage medium storing a computer program, wherein the computer program can implement the method according to any one of claims 1 to 5 when executed by a computer.