A method and device for designing an operating system kernel, and a storage medium

By dynamically configuring the operating state and mode of the operating system kernel components and integrating the advantages of macro kernel, micro kernel and exokernel, the problem that the existing kernel architecture cannot be dynamically adjusted is solved, an adaptive kernel architecture is realized, and the system versatility and application portability are improved.

CN119415160BActive Publication Date: 2025-10-10NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411372831.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-10-10
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

The existing operating system kernel architecture cannot determine the kernel architecture at compile time and then dynamically adjust it according to application requirements. It is difficult to meet the needs of multiple applications with different requirements at the same time. The hybrid kernel increases development complexity and affects portability.

Method used

Dynamically select the component operating state and operation mode of kernel components such as file system, network stack, device driver, etc. through user configuration, integrate the architectural advantages of traditional macro kernel, micro kernel and exokernel to form an adaptive architecture, support the coexistence of multiple operation modes, and realize component functions through kernel component management objects and service threads.

Benefits of technology

It enables flexible configuration of kernel component operating modes, improves the system's versatility and application code portability, and supports users in selecting the appropriate architecture based on different application requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415160B_ABST
    Figure CN119415160B_ABST
Patent Text Reader

Abstract

The application discloses a kind of operating system kernel design method, device and storage medium.It belongs to the technical field of computer operating system.The operating system kernel architecture design designed in the application supports multiple running modes of kernel component to coexist, and running mode between components does not affect each other, and the running mode of component can be dynamically decided according to user configuration during runtime;The multiple running modes of kernel component directly reflect to application, i.e.application does not need to perceive the running mode used for running itself, application developers do not need to adapt code, improve the versatility of system use scene and the portability of application code;Supporting user to select different architecture for different applications, it is a kind of adaptive system kernel architecture that adapts to user intention sensitivity.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer operating system, and in particular to an operating system kernel design method, device and storage medium. BACKGROUND

[0002] The operating system is an important component of the computer system, which manages hardware resources downward and serves user programs upward. The operating system kernel is the core component of the computer operating system, which is responsible for hardware resource management and supports application execution environment, including but not limited to task management, memory management, IPC management, device management, file system, network, inter-process communication and other functions. Through the system call interface provided to the outside, the user state program is supported to use the underlying hardware resources reasonably. The existing operating system faces different application scenarios, and designs different architecture of operating system kernel to meet the different needs of application scenarios for performance, reliability, general-purpose software properties, etc. The traditional operating system kernel architecture mainly includes macro kernel, micro kernel, outer core\single core, hybrid kernel, etc. Different kernel architectures are different in design concept, which leads to different advantages and disadvantages.

[0003] The existing kernel architecture has different characteristics in terms of safety, performance, reliability, etc. Different applications are suitable for different architectures with different characteristics, but there are still the following shortcomings.

[0004] The single kernel needs to determine the kernel architecture at compile time (determine the running mode at the same time), and the running time cannot be dynamically adjusted according to the application requirements, which is difficult to meet the needs of multiple applications with different characteristics; the hybrid kernel supports the simultaneous compilation of multiple kernels (such as macOS\iOS kernel), which requires application developers to call different interfaces to select the kernel used, increasing the complexity of development and affecting the portability of the application; users cannot control the kernel architecture and take advantage of the architecture, such as trusted applications that can relax security requirements to improve performance, and untrusted applications that can sacrifice performance to enhance security restrictions. SUMMARY

[0005] In view of the above problems of the prior art, the present application provides an operating system kernel design method, device and storage medium, which performs fusion design on the existing operating system kernel architecture, dynamically selects the component running state and running mode of kernel components such as file system, network stack and device driver through user configuration, combines the architecture advantages of traditional macro kernel, micro kernel and outer core, dynamically configures the running mode of application dependent components according to the specific needs of different user processes in the system, forms an adaptive architecture suitable for different demand characteristics, and realizes a better balance between performance and reliability.

[0006] In one aspect, the present application provides an operating system kernel design method, which is applied to an operating system, and the method comprises:

[0007] creating kernel component management objects for the components and executing corresponding kernel service threads;

[0008] running the component normal processes in response to the kernel component management objects receiving requests for services sent by the component normal processes, the component normal processes being used to implement functions of the components after being run, wherein one component corresponds to at least one normal process, and one normal process is for at least one component;

[0009] running the component main processes in response to the user state running the component main processes through a function call mode, the component main processes being used to implement functions of corresponding components through the function call mode in the user state, wherein one component has at most one component main process at the same time, each component main process creates a user service thread, the user service thread is used to listen to requests of other processes accessing the component, and one component has at most one user service thread running at the same time;

[0010] running the user service thread of the component main process.

[0011] Optionally, the creating kernel component management objects for the components and executing corresponding kernel service threads through the kernel comprises:

[0012] Step one, creating kernel component management objects for the components and creating corresponding kernel service threads through the kernel;

[0013] Step two, starting the kernel service threads and setting the component library to the function call mode;

[0014] Step three, checking a control queue of the kernel component management objects to determine whether there is a request, if not, executing step four, otherwise executing step seven;

[0015] Step four, checking a data queue of the kernel component management objects to determine whether there is a request, if not, executing step five, otherwise executing step six;

[0016] Step five, in response to the control queue and the data queue of the kernel component management objects both having no request, triggering the kernel service thread to give up scheduling, and checking the control queue and the data queue through processor scheduling, in response to any queue having a request, resuming scheduling of the kernel service thread and executing step three;

[0017] Step six, processing the request through the function call mode, the processing process of the request including responding to a data request and returning a result, and the sender of the request can continue to run after responding, and executing step three;

[0018] Step seven, the request triggering the control queue becomes a preemption request, and a component cleaning operation is performed before responding to the preemption request, and after responding, the request sender can continue running;

[0019] Step eight, ending the kernel service thread.

[0020] Optionally, the kernel service thread created by the kernel includes a file system service thread, a block device driver service thread, a network stack service thread, and a network device driver service thread.

[0021] In the embodiment of the application, the kernel component refers to a file system, a block device driver, a network stack, and a network device driver.

[0022] Optionally, the running of the component ordinary process in response to the kernel component management object receiving a request service sent by the component ordinary process includes:

[0023] Step nine, starting at least one ordinary process (possibly multiple simultaneous running), and setting the mode of process accessing the component to a request service mode;

[0024] Step ten, executing application code, accessing the component in the request service mode and sending a data request, judging whether the ordinary process is ended after the request is completed, if not, continuing to execute step ten, otherwise, executing step eleven;

[0025] Step eleven, ending the ordinary process.

[0026] Optionally, the running of the component master process in the function call mode by the user state includes:

[0027] Step twelve, starting at least one component master process in the function call mode by the user state, issuing a preemption request and waiting for the request to be processed, setting the mode of process accessing the component to a function call mode, creating and starting the user service thread;

[0028] Step thirteen, executing application code until the end;

[0029] Step fourteen, sending an end request to the kernel component management object, the end request being attached with a process number of a current process as an identifier, and waiting for the request to be processed;

[0030] Step fifteen, waiting for the user service thread of the current process to end in response to the request being processed;

[0031] Step sixteen, triggering the component master process to end in response to the user service thread being ended.

[0032] Optionally, the running of the user service thread of the component master process includes:

[0033] Step seventeen, starting the user service thread of the component main process;

[0034] Step eighteen, taking out requests from the control queue and the data queue in turn, if there is no request, waiting, if there is a request, judging the request type, if it is a data request, executing step nineteen, if it is a preemption request, executing step twenty, if it is an end request, executing step twenty-one;

[0035] Step nineteen, processing the request using the function call mode, responding to the data request and returning the result, and executing step eighteen;

[0036] Step twenty, executing the component cleaning operation and setting the mode of the current process accessing the component to request service, responding to the preemption request, and then the request sender can continue to run, executing step twenty-three;

[0037] Step twenty-one, judging whether the process number of the request is the same as the process number of the current process, if yes, executing step twenty-two, otherwise, not executing the processing operation and responding to the end request, and continuing to execute step eighteen;

[0038] Step twenty-two, executing the component cleaning operation, and creating and starting the kernel service thread, responding to the end request, and executing step twenty-three;

[0039] Step twenty-three, ending the user service thread.

[0040] Optionally, the method further comprises:

[0041] Developing each application using the POSIX interface;

[0042] Designing a function kernel component management object in the kernel, wherein each component comprises a kernel service thread, a user service thread, a control queue and a data queue, and the component method comprises creating a component, creating a kernel service thread, creating a user service thread, and adding, obtaining and responding operations of the control queue and the data queue;

[0043] Implementing a component library for each kernel component;

[0044] Configuring the running mode of each application depending on the kernel component according to the intention of the system end user.

[0045] On the other hand, an operating system kernel design device is also provided, and the device comprises:

[0046] A first design module, configured to create a kernel component management object for each component through the kernel and execute a corresponding kernel service thread;

[0047] A second design module is configured to run the component common process in response to the kernel component management object receiving a request service sent by the component common process, the component common process being configured to implement the functions of the components after being run, wherein one component corresponds to at least one common process, and one common process is at least the common process of one component;

[0048] A third design module is configured to run the component main process in response to the user state running the component main process through a function call mode, the component main process being configured to implement the functions of the corresponding component through the function call mode in the user state, wherein one component has at most one component main process, each component main process creates a user service thread, the user service thread is configured to listen to the request of other processes accessing the component, and one component has at most one user service thread running at the same time.

[0049] A fourth design module is configured to run the user service thread of the component main process.

[0050] The present application has at least the following beneficial effects.

[0051] The operation system kernel architecture designed in the present application supports multiple running modes of the kernel components at the time of compiling, and the running modes of the components do not affect each other, and the running mode of the components can be dynamically decided according to the user configuration at the time of running; the multiple running modes of the kernel components directly reflect the application, that is, the application does not need to perceive the running mode used by itself, the application developer does not need to adapt the code, and the universality of the system use scene and the portability of the application code are improved; the different architecture can be selected for different applications by the user, and it is a self-adaptive system kernel architecture sensitive to the user intention. BRIEF DESCRIPTION OF DRAWINGS

[0052] Figure 1 The figure is a schematic diagram of the overall architecture of the embodiment method of the present application;

[0053] Figure 2 The figure is a schematic diagram of the kernel function kernel component management object in the embodiment of the present application;

[0054] Figure 3 The figure is a schematic diagram of the kernel component library in the embodiment of the present application;

[0055] Figure 4 The figure is a schematic diagram of the kernel service thread execution flow in the embodiment of the present application;

[0056] Figure 5 The figure is a schematic diagram of the component common process execution flow in the embodiment of the present application;

[0057] Figure 6 The figure is a schematic diagram of the component main process execution flow in the embodiment of the present application;

[0058] Figure 7 Flowchart for user service thread execution in an embodiment of the present application. DETAILED DESCRIPTION

[0059] For the purpose of making the present application, technical solutions and advantages more clear, the embodiments of the present application will be described in further detail below with reference to the drawings.

[0060] In the present text, "multiple" refers to two or more. "And / or" describes the association between the associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents an "or" relationship between the associated objects before and after it.

[0061] Embodiment 1

[0062] The present application provides a method for designing an operating system kernel, which is applied to an operating system, and includes the following contents.

[0063] Step one, the kernel creates a kernel component management object for each component and executes the corresponding kernel service thread.

[0064] Optionally, the kernel service thread created by the kernel includes a file system service thread, a block device driver service thread, a network stack service thread, and a network device driver service thread.

[0065] In one example, the kernel creates a kernel component management object for each component and creates a kernel service thread, as shown in Figure 1 The kernel creates a file system service thread, a block device driver service thread, a network stack service thread, a network device driver service thread, and a character device driver service thread, etc. Taking the file system kernel service thread as an example, its implementation depends on Figure 3 The file system component library, and the specific execution process is as shown in Figure 4 .

[0066] In a possible implementation, step one includes steps one to eight.

[0067] Step one, the kernel creates a kernel component management object for each component and creates a kernel service thread;

[0068] Step two, start the kernel service thread, and set the component library to function call mode (i.e. use the interface of FsServer to implement fs_trait), and continue to step three;

[0069] Step three, check the control queue of the kernel component management object to determine whether there is a request, if not, execute step four, otherwise execute step seven;

[0070] Step four, check the data queue of the kernel component management object to determine whether there is a request, if not, execute step five, otherwise execute step six;

[0071] Step five, in response to the control queue and the data queue of the kernel component management object having no request, trigger the kernel service thread to give up scheduling, and check the control queue and the data queue through processor scheduling, and in response to any queue having a request, restore the scheduling of the kernel service thread and execute step three;

[0072] Step six, process the request using the function call mode, the processing process of the request including responding to a data request and returning a result, and the request sender can continue to run after responding;

[0073] Step seven, trigger the request of the control queue to become a preemption request (the end request is sent when the component main process exits, and only the user service thread can respond to it), and perform a component cleaning operation (such as file system sync) before responding to the preemption request, and the request sender can continue to run after responding;

[0074] Step eight, end the kernel service thread.

[0075] Step two, in response to the kernel component management object receiving a request service sent by a component ordinary process, run the component ordinary process, the component ordinary process being used to implement the functions of the components after being run, wherein one component corresponds to at least one ordinary process, and one ordinary process is at least the ordinary process of one component.

[0076] In one example, the component ordinary process implements the component-related functions by sending a request service to the kernel component management object. For example, Figure 1 Process B is a file system component ordinary process, and process C is a network stack component ordinary process. One component can have multiple ordinary processes, and one process can be the ordinary process of multiple components. Taking the file system component ordinary process as an example, its implementation depends on the file system component library shown in Figure 3 , and the execution flow of each process is shown in Figure 5 .

[0077] In a possible implementation, step two includes steps nine to eleven.

[0078] Step nine, start at least one ordinary process (which can be multiple processes running at the same time), and set the mode of process access to the component to a request service mode (i.e., implement fs_trait using the interface of FsClient);

[0079] Step ten, execute the application code, access the component in the request service mode and send a data request, judge whether the common process is ended after the request is completed, if not, continue to execute step ten, otherwise execute step eleven.

[0080] Step eleven, end the common process.

[0081] Step three, in response to the user state, run the component main process in the function call mode, the component main process is used to realize the function of the corresponding component in the user state through the function call mode, wherein a component has at most one component main process at the same time, each component main process creates a user service thread, the user service thread is used to listen to the request of other processes accessing the component, and a component has at most one user service thread running at the same time.

[0082] In one example, the component main process directly realizes the component function in the user state through the function call mode, such as Figure 1 The process A in the file system is a file system main process. A component has at most one main process at the same time, when a process starts as a component main process, if there are other processes as main processes, the main process can also be preempted, and the old main process runs in the common process mode after preemption. Taking the file system component main process as an example, its implementation depends on the file system component library shown in Figure 3 , and the execution flow of the component main process is shown in Figure 6 .

[0083] In a possible implementation, step three includes steps twelve to sixteen.

[0084] Step twelve, in response to the user state, start at least one component main process (possibly multiple at the same time) in the function call mode, issue a preemption request and wait for the request to be processed, set the mode of the process accessing the component to the function call mode (that is, realize fs_trait by using the interface of FsServer), and create and start the user service thread.

[0085] Step thirteen, execute the application code until the end.

[0086] In addition, in step thirteen, when the application code is executed, the process can be judged to be ended after the component access is completed in the function call mode, if not, the function call is cycled, otherwise step fourteen is executed; in addition, in step thirteen, the application code is executed until the end, during which the process access component mode can be modified (twenty), from the beginning of the function call to the request service.

[0087] Among them, the function call mode and the request service mode are two of the process access component modes.

[0088] Step fourteen, send an end request to the kernel component management object, the end request is attached with the process number of the current process as an identifier, and waits for the request processing to be completed.

[0089] Step fifteen, waits for the user service thread of the current process to end in response to the request processing being completed.

[0090] Step sixteen, triggers the end of the component main process in response to the user service thread being ended.

[0091] Step four, runs the user service thread of the component main process.

[0092] In one example, each component main process is responsible for creating a user service thread for listening to the requests of other processes accessing the component. A component has at most one main process and at most one user service thread running at the same time. Taking the file system user service thread as an example, its implementation depends on Figure 3 the file system component library, and the specific execution flow is as shown in Figure 7 .

[0093] In one possible implementation, step four includes steps seventeen to twenty-three.

[0094] Step seventeen, starts the user service thread of the component main process;

[0095] Step eighteen, takes the requests from the control queue and the data queue in turn, and waits if there is no request. If there is a request, judges the request type. If it is a data request, executes step nineteen. If it is a preemption request, executes step twenty. If it is an end request, executes step twenty-one.

[0096] Step nineteen, processes the request using the function call mode, responds to the data request and returns the result, and executes step eighteen.

[0097] Step twenty, executes a component cleaning operation (such as file system sync) and sets the mode of the current process accessing the component to request service, responds to the preemption request, and then the request sender can continue to run, and executes step twenty-three.

[0098] Step twenty-one, judges whether the process number of the request is the same as the process number of the current process. If yes, executes step twenty-two. If not, does not execute the processing operation and responds to the end request. The process that sends the request is no longer the main process, so there is no need for processing, and the end request is responded to directly (the request sender can continue to run) and step eighteen is executed.

[0099] Step twenty-two, executes a component cleaning operation (such as file system sync) and creates and starts a kernel service thread, responds to the end request (the request sender can continue to run) and executes step twenty-three.

[0100] Step twenty-three, end the user service thread.

[0101] The present application has at least the following beneficial effects.

[0102] The operating system kernel architecture designed by the present application supports multiple running modes of kernel components at compile time, and the running modes of components do not affect each other. At runtime, the running mode of a component can be dynamically decided according to user configuration. The multiple running modes of kernel components are directly reflected to applications, that is, the application does not need to perceive the running mode used by itself, and the application developer does not need to adapt the code, thereby improving the versatility of the system use scenario and the portability of the application code. The present application supports users to select different architectures for different applications, and is a self-adaptive system kernel architecture sensitive to user intentions.

[0103] Embodiment 2

[0104] In addition, before the above kernel design method, a preparation stage is further included.

[0105] Preparation stage one, develop each application using the POSIX interface.

[0106] The application developer develops the application using the POSIX interface (consistent with Linux-based application development). As shown in the upper left of FIG. 1, the application can depend on the file system kernel component (such as application A and application B) and the network stack kernel component (such as application C). Figure 1

[0107] Preparation stage two, design a functional kernel component management object in the kernel, wherein each component includes a kernel service thread, a user service thread, a control queue and a data queue, and the component methods include creating a component, creating a kernel service thread, creating a user service thread, and adding, obtaining and responding to the control queue and the data queue.

[0108] Design a functional kernel component management object in the kernel. As shown in FIG. 2, the component members include a kernel service thread, a user service thread, a control queue (receiving two kinds of requests of preemption and end), and a data queue (receiving data access requests); the component methods include creating a component, creating a kernel service thread, creating a user service thread, and adding, obtaining and responding to the control queue and the data queue. Figure 2

[0109] Preparation stage three, implement a component library for each kernel component.

[0110] Implement a component library for each kernel component. Figure 3 ​​The component library design is demonstrated by taking the file system component and Rust language as an example. The core member fs_trait is a trait object type variable (similar to a virtual interface) in Rust language, which can be dynamically distributed to a specific type. The type FsTrait of fs_trait includes the interface definition required by the file system component to provide to the application, such as creating a file, reading and writing a file, synchronization, and the like. FsServer and FsClient specifically implement the interfaces in FsTrait, wherein FsServer specifically implements the file system function through a function call mode, is independent of the kernel, and can run in the kernel mode or the user mode; FsClient implements the related function by sending a data access request to the kernel component of the kernel file system, is dependent on the kernel, and can only run in the user mode.

[0111] In the fourth preparation stage, the running mode of each application dependent on the kernel component is configured according to the intention.

[0112] The terminal user of the system configures the running mode of the application dependent on the kernel component according to the intention. As shown in the upper right of Figure 1 , it is assumed that the application A is performance sensitive, and the user can configure it as a file system master process; the application B is a normal process dependent on the file system; and the application C is a normal process dependent on the network stack.

[0113] On the other hand, an operating system kernel design apparatus is also provided, and the apparatus includes:

[0114] A first design module is configured to create a kernel component management object for each component by the kernel and execute a corresponding kernel service thread;

[0115] A second design module is configured to run a component normal process in response to that the kernel component management object receives a request service sent by the component normal process, the component normal process being used to realize the function of the component after being run, wherein one component corresponds to at least one normal process, and one normal process is at least the normal process of one component;

[0116] A third design module is configured to run a component master process in the user mode through a function call mode in response to that the user mode runs the component master process through the function call mode, the component master process being used to realize the function of the corresponding component in the user mode through the function call mode, wherein one component has at most one component master process, each component master process creates a user service thread, the user service thread being used to listen to the request of other processes accessing the component, and one component has at most one user service thread running at the same time;

[0117] A fourth design module is configured to run the user service thread of the component master process.

[0118] Optionally, the first design module is configured to execute:

[0119] Step one, creating kernel component management objects and corresponding kernel service threads for each component by kernel;

[0120] Step two, starting the kernel service thread and setting the component library to function call mode;

[0121] Step three, checking the control queue of the kernel component management object to determine whether there is a request, if not, executing step four, otherwise executing step seven;

[0122] Step four, checking the data queue of the kernel component management object to determine whether there is a request, if not, executing step five, otherwise executing step six;

[0123] Step five, in response to the control queue and the data queue of the kernel component management object both having no request, triggering the kernel service thread to give up scheduling, and checking the control queue and the data queue by processor scheduling, in response to any queue having a request, resuming the scheduling of the kernel service thread and executing step three;

[0124] Step six, processing the request using the function call mode, the processing process of the request including responding to data request and returning results, the request sender of the data queue can continue to run after responding, executing step three;

[0125] Step seven, triggering the request of the control queue to become a preemption request, and executing component cleaning operation before responding to the preemption request, the request sender of the control queue can continue to run after responding;

[0126] Step eight, ending the kernel service thread.

[0127] Optionally, the second design module is used to execute:

[0128] Step nine, setting the mode of process accessing component to request service mode;

[0129] Step ten, executing application code, accessing the component in the request service mode and sending data request, and determining whether the normal process is ended after the request is completed, if not, continuing to execute step ten, otherwise executing step eleven;

[0130] Step eleven, ending the normal process.

[0131] Optionally, the third design module is used to execute:

[0132] Step twelve, in response to at least one component master process being started by user state through function call mode, issuing a preemption request and waiting for request processing to be completed, setting the mode of process accessing component to function call mode, and creating and starting the user service thread;

[0133] Step thirteen, executing application code to the end;

[0134] Step fourteen, sending an end request to the kernel component management object, the end request being attached with the process number of the current process as an identifier, and waiting for the request processing to be completed;

[0135] Step fifteen, waiting for the user service thread of the current process to end in response to the request processing being completed;

[0136] Step sixteen, triggering the end of the component main process in response to the user service thread being ended.

[0137] Optionally, the fourth design module is configured to perform:

[0138] Step seventeen, starting the user service thread of the component main process;

[0139] Step eighteen, sequentially taking out requests from the control queue and the data queue, if there is no request, waiting, if there is a request, judging the request type, if it is a data request, performing step nineteen, if it is a preemption request, performing step twenty, if it is an end request, performing step twenty-one;

[0140] Step nineteen, processing the request using the function call mode, responding to the data request and returning a result, and performing step eighteen;

[0141] Step twenty, performing component cleaning operation and setting the mode of the current process accessing the component to request service, responding to the preemption request, and then the request sender of the preemption request can continue to run, and performing step twenty-three;

[0142] Step twenty-one, judging whether the process number of the request is the same as the process number of the current process, if yes, performing step twenty-two, otherwise, not performing processing operation and responding to the end request, and performing step eighteen;

[0143] Step twenty-two, performing component cleaning operation, and creating and starting a kernel service thread, and performing step twenty-three in response to the end request;

[0144] Step twenty-three, ending the user service thread.

[0145] Optionally, the apparatus further comprises:

[0146] An application use module configured to develop each application using a POSIX interface;

[0147] An object management module is used for designing a kernel component management object in the kernel, wherein each component comprises a kernel service thread, a user service thread, a control queue and a data queue, and component methods comprise creating a component object, creating a kernel service thread, creating a user service thread, and adding, obtaining, and responding operations of the control queue and the data queue;

[0148] A component library management module is used for implementing a component library for each kernel component;

[0149] A running mode module is used for configuring a running mode of each application dependent kernel component according to an intention of a system terminal user.

[0150] The above only describes the preferred embodiments of the present application, and the protection scope of the present application is not limited to the above-mentioned embodiments only, and any technical solution falling within the concept of the present application belongs to the protection scope of the present application. It should be noted that, for ordinary skilled in the art, some improvements and refinements without departing from the principles of the present application should be considered as the protection scope of the present application.

Claims

1. A method for designing an operating system kernel, characterized in that: The method is applied to an operating system and includes: The kernel creates kernel component management objects for each component and executes corresponding kernel service threads. Each component includes a kernel service thread, a user service thread, a control queue, and a data queue. Component methods include creating component objects, creating kernel service threads, creating user service threads, and adding, obtaining, and responding to control queues and data queues. The method of creating a kernel component management object for each component and executing a corresponding kernel service thread through the kernel includes: step 1, creating a kernel component management object and a corresponding kernel service thread for each component through the kernel; step 2, starting the kernel service thread and setting the component library to function call mode; step 3, checking the control queue of the kernel component management object to determine whether there is a request, if there is no request, executing step 4, otherwise executing step 7; step 4, checking the data queue of the kernel component management object to determine whether there is a request, if there is no request, executing step 5, otherwise executing step 6; step 5, responding to the control queue and data queue of the kernel component management object, If there is no request in any of the data queues, the kernel service thread is triggered to abandon scheduling, and the control queue and the data queue are checked through processor scheduling. In response to the presence of a request in any of the queues, the scheduling of the kernel service thread is restored and step three is executed; step six, the request is processed using the function call mode, and the request processing process includes responding to the data request and returning a result. After the response, the request sender of the data queue can continue to run and step three is executed; step seven, the request of the control queue is triggered to become a preemption request, and a component cleanup operation is performed before responding to the preemption request. After the response, the request sender of the control queue can continue to run; step eight, the kernel service thread is terminated; In response to the component ordinary process running, the kernel component management object receives a service request sent by the component ordinary process, the component ordinary process is used to use the component in a service requesting manner, a component has no ordinary process or corresponds to at least one ordinary process, and an ordinary process is at least an ordinary process of one component; In response to the user state running the component main process through the function call mode, the component main process is used to implement the function of the corresponding component through the function call mode in the user state, wherein a component has at most one component main process at the same time, and each component main process creates a user service thread, and the user service thread is used to monitor requests from other ordinary processes to access the component. The main process component corresponds to one user service thread running at the same time; A user service thread that runs the main process of the component.

2. The method according to claim 1, characterized in that In response to the component normal process running, the kernel component management object receives a service request sent by the component normal process, including: Step 9: Set the process access component mode to request service mode; Step 10: Execute the application code, access the component in the request service mode, and send a data request. After the request is completed, determine whether the normal process has ended. If not, continue with step 10; otherwise, proceed to step 11. Step 11: End the normal process.

3. The method according to claim 1, characterized in that The step of running the component main process in a function call mode in response to the user state includes: Step 12: In response to the user state starting at least one component main process in a function call mode, issuing a preemption request and waiting for the request to be processed, setting the process access mode of the component to a function call mode, and creating and starting the user service thread; Step 13: Execute the application code to completion; Step 14: Send an end request to the kernel component management object, wherein the end request is accompanied by the process ID of the current process as an identifier, and wait for the request to be processed; Step 15, in response to the request processing being completed, waiting for the user service thread of the current process to end; Step 16: In response to the termination of the user service thread, trigger the termination of the component main process.

4. The method according to claim 1, wherein The user service thread running the component main process includes: Step 17: Start the user service thread of the component main process; Step 18, sequentially taking requests from the control queue and the data queue, waiting if there is no request, and determining the request type if there is a request, executing step 19 if it is a data request, executing step 20 if it is a preemption request, and executing step 21 if it is an end request; Step 19: Process the request using the function call mode, respond to the data request and return the result, and then execute step 18; Step 20: Execute component cleanup and set the current process's access mode to request service, respond to the preemption request, and then the sender of the preemption request can continue to run, and execute step 23; Step 21: determine whether the requested process ID is the same as the process ID of the current process. If so, proceed to step 22; otherwise, do not perform the processing operation and respond to the end request, and continue to step 18; Step 22: Execute component cleanup operations, create and start a kernel service thread, and execute step 23 in response to the end request; Step 23: End the user service thread.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Use POSIX interfaces to develop various applications; Design kernel component management objects in the kernel; Implement component libraries for each kernel component; Configure how each application depends on kernel components to run based on the system end user's intent.

6. An operating system kernel design device, characterized in that: The device comprises: The first design module is used to create a kernel component management object for each component through the kernel and execute the corresponding kernel service thread, wherein each component includes a kernel service thread, a user service thread, a control queue and a data queue. The component method includes creating component objects, creating kernel service threads, creating user service threads, and adding, obtaining, and responding to control queues and data queues; The first design module is also used for: step 1, creating a kernel component management object and a corresponding kernel service thread for each component through the kernel; step 2, starting the kernel service thread and setting the component library to function call mode; step 3, checking the control queue of the kernel component management object to determine whether there is a request, if there is no request, executing step 4, otherwise executing step 7; step 4, checking the data queue of the kernel component management object to determine whether there is a request, if there is no request, executing step 5, otherwise executing step 6; step 5, in response to the fact that there is no request in both the control queue and the data queue of the kernel component management object, triggering the The kernel service thread abandons scheduling, and checks the control queue and the data queue through processor scheduling, and resumes scheduling of the kernel service thread in response to a request in any queue and executes step three; step six, processes the request using the function call mode, and the request processing process includes responding to the data request and returning a result. After the response, the request sender of the data queue can continue to run, and execute step three; step seven, triggers the request of the control queue to become a preemption request, and executes a component cleanup operation and then responds to the preemption request. After the response, the request sender of the control queue can continue to run; step eight, ends the kernel service thread; A second design module is configured to respond to a component common process running, the kernel component management object receiving a service request sent by the component common process, the component common process being configured to use the component in a service requesting manner, a component having no common process or corresponding to at least one common process, and a common process being a common process of at least one component; The third design module is used to respond to the user state by running the component main process through the function call mode. The component main process is used to implement the functions of the corresponding component through the function call mode in the user state. Among them, a component can have at most one component main process at the same time. Each component main process creates a user service thread. The user service thread is used to monitor requests from other ordinary processes to access the component. One main process component corresponds to one user service thread running at the same time; The fourth design module is used to run the user service thread of the component main process.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the operating system kernel design method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Microkernel operating system and access control method thereof, chip, equipment and medium

    CN116702180A

  • Improved operating system performance

    CN1782993A