Method for calling user mode function by kernel mode

A technology for calling functions and kernel state, applied in the field of Linux kernel, to achieve the effect of increasing convenience, improving kernel development efficiency, and satisfying flexible development

Active Publication Date: 2020-10-30
FENGHUO COMM SCI & TECH CO LTD +1
View PDF6 Cites 5 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0003] Aiming at the limitations existing in the prior art, the present invention proposes a method for calling user-mode functions by kernel-mode functions to solve the problem that kernel-mode functions need to be called by user-mode functions in some cases

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for calling user mode function by kernel mode
  • Method for calling user mode function by kernel mode
  • Method for calling user mode function by kernel mode

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0027] The present invention provides a method for calling user-mode functions from the kernel mode, which converts the calling of the user-mode functions from the kernel mode into blocking and waking up the kernel-mode threads: realizing the encapsulation of the parameters of the called user-mode functions in the kernel mode, Kernel mode thread blocking, ioctl message communication to complete the call of the user mode function, when the user mode function returns the call result, the return result of the user mode function is sent to the kernel mode through ioctl message communication, and then the blocked kernel mode thread is woken up to complete the function The entire process of calling.

[0028] figure 1 It is a schematic diagram of the principle of the method for the kernel state to call the user state function in the embodiment of the present invention, including the user state and the kernel state two-part design, the function of the kernel state is the main part, an...

Embodiment 2

[0032] figure 2 It is a schematic flow diagram of the method for calling user mode functions from the kernel mode in the embodiment of the present invention, as shown in figure 2 As shown, the method for calling the user mode function from the kernel mode of the present invention comprises the following steps:

[0033] S1. Implement the encapsulation function of the user mode original function in the kernel mode. For each user mode function that needs to be called, it is first necessary to implement an encapsulation function with the same prototype as the user mode function in the kernel mode. In the encapsulation function, the user mode The name of the encapsulation function is used as a parameter. The parameters of the encapsulation function should also include the parameters passed by the upper-level calling function. In order for the user-mode thread to be able to distinguish calls from different kernel-mode threads, the parameters of the encapsulation function should al...

Embodiment 3

[0043] Demonstrate the implementation process of the scheme of the present invention below with a specific example, as image 3 and Figure 4 As shown, in this example: the kernel state thread kprocB calls the user state function funA, the user state function funA is implemented in the user state thread procA, and the prototype of the procA function in the user state thread is int procA (int arg), and the implementation process includes:

[0044] S11. Realize the encapsulation function kfunA of the user mode function funA in the kernel mode (this function is an encapsulation function, and the prototype is the same as the user mode thread procA). into a data structure;

[0045] S12. The kernel state thread kprocB calls the kernel state encapsulation function kfunA to complete the parameter encapsulation of step 1. After kfunA completes the parameter encapsulation, the parameter data structure is added to a call queue (the call queue is a global queue of a linked list structure...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a method for calling a user mode function by a kernel mode. The method comprises the steps that calling of a kernel mode to a user mode function is converted into blocking andawakening of a kernel mode thread; in the kernel mode, parameter encapsulation, kernel mode thread blockage and ioctl message communication of the called user mode function are realized to complete calling of the user mode function; and after the called user mode function returns a calling result, the user mode function return result is sent to the kernel mode through ioctl message communication,and the blocked kernel mode thread is awakened to finish the whole process of function calling. According to the invention, calling of the kernel mode to the user mode function is achieved; under thecondition that kernel logic is not modified, transparent calling from the kernel mode to the user mode is completed in a blocking awakening mode, and logic of an original function is not modified.

Description

technical field [0001] The invention belongs to the technical field of Linux kernel, and more specifically relates to a method for calling a user mode function in a kernel mode. Background technique [0002] In modern operating systems, for the stability of the system, two execution environments, kernel mode and user mode, are implemented. The two environments have different execution permissions and different address spaces. The core part of the operating system generally runs in the kernel mode for Complete core functions such as task scheduling, memory management, and hardware management. Most of the application layer functions run in user mode, and threads in user mode can fall into kernel mode through special system calls to execute kernel functions. The functions in the kernel mode cannot in turn call the function interface in the user mode. For some systems with separate design, such as modules running in kernel mode and user mode at the same time, there is a need fo...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/48G06F9/54
CPCG06F9/485G06F9/4881G06F9/546G06F2209/548
Inventor 王永强
Owner FENGHUO COMM SCI & TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products