驱动程序和用户应用程序之间的主要区别是什么?
What is the main difference between drivers and user applications?
我知道用户应用程序只能在用户模式下运行,这是为了系统安全。相反,大多数驱动程序 运行 在内核模式下访问 I/O 设备。尽管如此,一些驱动 运行 在用户模式下,却被允许访问 I/O 设备。所以我有以下问题。驱动程序和用户应用程序之间的主要区别是什么?不能像某些驱动程序那样允许用户应用程序访问 I/O 设备吗?
谢谢。
首先,some preview from this link :-
Applications run in user mode, and core operating system components
run in kernel mode. Many drivers run in kernel mode, but some drivers
run in user mode.
When you start a user-mode application, Windows(/any OS) creates a process for
the application. The process provides the application with a private
virtual address space and a private handle table. Because an
application's virtual address space is private, one application cannot
alter data that belongs to another application.
In addition to being private, the virtual address space of a user-mode
application is limited. A processor running in user mode cannot access
virtual addresses that are reserved for the operating system. Limiting
the virtual address space of a user-mode application prevents the
application from altering, and possibly damaging, critical operating
system data.
All code that runs in kernel mode shares a single virtual address
space. This means that a kernel-mode driver is not isolated from other
drivers and the operating system itself. If a kernel-mode driver
accidentally writes to the wrong virtual address, data that belongs to
the operating system or another driver could be compromised.
Software drivers
Some drivers are not associated with any hardware device at all. For
example, suppose you need to write a tool that has access to core
operating system data structures, which can be accessed only by code
running in kernel mode. You can do that by splitting the tool into two
components. The first component runs in user mode and presents the
user interface. The second component runs in kernel mode and has
access to the core operating system data. The component that runs in
user mode is called an application, and the component that runs in
kernel mode is called a software driver. A software driver is not
associated with a hardware device.
Also, software drivers() always run in kernel mode. The main reason
for writing a software driver is to gain access to protected data that
is available only in kernel mode. But device drivers do not always
need access to kernel-mode data and resources. So some device drivers
run in user mode.
What is the main difference between drivers and user applications?
区别就跟潜艇和轮船的区别一样。驱动程序依赖于硬件并且特定于操作系统。它们通常提供任何必要的异步时间相关硬件接口所需的中断处理。因此,almost 全部 运行 处于内核模式。然而,如第二段所述,为防止应用程序损坏关键 OS 数据,用户应用程序绑定到用户 space.
中的 运行
此外,并非所有驱动程序都直接与设备通信。对于给定的 I/O 请求(如从设备读取数据),通常有多个驱动程序参与请求,这些驱动程序在堆栈中分层。堆栈中直接与设备通信的驱动程序称为功能驱动程序;执行辅助处理的驱动程序称为过滤驱动程序。
Can't user application be allowed to access I/O devices like some
drivers do?
应用程序调用操作系统实现的函数,操作系统调用驱动程序实现的函数。驱动程序知道如何与设备硬件通信以获取数据。驱动程序从设备获取数据后,它 returns 将数据发送给操作系统,然后 returns 将其发送给应用程序。
应用程序通过设备驱动程序(而不是 OS)提供的 APIs/interfaces 连接到 IO 设备。 OS 处理大多数 hardware/software 交互。硬件供应商编写“plugins/modules/drivers”,允许 OS 控制他们的特定硬件。因此,使用 OS 提供的接口,您可以编写应用程序来访问 IO 设备。
所以,你不能让用户应用程序在没有驱动程序帮助的情况下直接访问硬件,因为它是层次结构下面的所有驱动程序来访问设备,因为设备驱动程序是用可以与硬件通信的低级语言编写的,而用户应用程序是用高级语言编写的。
此外,check this answer 了解更多有关驱动程序地址 space 的信息 OS'。
我知道用户应用程序只能在用户模式下运行,这是为了系统安全。相反,大多数驱动程序 运行 在内核模式下访问 I/O 设备。尽管如此,一些驱动 运行 在用户模式下,却被允许访问 I/O 设备。所以我有以下问题。驱动程序和用户应用程序之间的主要区别是什么?不能像某些驱动程序那样允许用户应用程序访问 I/O 设备吗?
谢谢。
首先,some preview from this link :-
Applications run in user mode, and core operating system components run in kernel mode. Many drivers run in kernel mode, but some drivers run in user mode.
When you start a user-mode application, Windows(/any OS) creates a process for the application. The process provides the application with a private virtual address space and a private handle table. Because an application's virtual address space is private, one application cannot alter data that belongs to another application.
In addition to being private, the virtual address space of a user-mode application is limited. A processor running in user mode cannot access virtual addresses that are reserved for the operating system. Limiting the virtual address space of a user-mode application prevents the application from altering, and possibly damaging, critical operating system data.
All code that runs in kernel mode shares a single virtual address space. This means that a kernel-mode driver is not isolated from other drivers and the operating system itself. If a kernel-mode driver accidentally writes to the wrong virtual address, data that belongs to the operating system or another driver could be compromised.
Software drivers
Some drivers are not associated with any hardware device at all. For example, suppose you need to write a tool that has access to core operating system data structures, which can be accessed only by code running in kernel mode. You can do that by splitting the tool into two components. The first component runs in user mode and presents the user interface. The second component runs in kernel mode and has access to the core operating system data. The component that runs in user mode is called an application, and the component that runs in kernel mode is called a software driver. A software driver is not associated with a hardware device.
Also, software drivers() always run in kernel mode. The main reason for writing a software driver is to gain access to protected data that is available only in kernel mode. But device drivers do not always need access to kernel-mode data and resources. So some device drivers run in user mode.
What is the main difference between drivers and user applications?
区别就跟潜艇和轮船的区别一样。驱动程序依赖于硬件并且特定于操作系统。它们通常提供任何必要的异步时间相关硬件接口所需的中断处理。因此,almost 全部 运行 处于内核模式。然而,如第二段所述,为防止应用程序损坏关键 OS 数据,用户应用程序绑定到用户 space.
中的 运行此外,并非所有驱动程序都直接与设备通信。对于给定的 I/O 请求(如从设备读取数据),通常有多个驱动程序参与请求,这些驱动程序在堆栈中分层。堆栈中直接与设备通信的驱动程序称为功能驱动程序;执行辅助处理的驱动程序称为过滤驱动程序。
Can't user application be allowed to access I/O devices like some drivers do?
应用程序调用操作系统实现的函数,操作系统调用驱动程序实现的函数。驱动程序知道如何与设备硬件通信以获取数据。驱动程序从设备获取数据后,它 returns 将数据发送给操作系统,然后 returns 将其发送给应用程序。
应用程序通过设备驱动程序(而不是 OS)提供的 APIs/interfaces 连接到 IO 设备。 OS 处理大多数 hardware/software 交互。硬件供应商编写“plugins/modules/drivers”,允许 OS 控制他们的特定硬件。因此,使用 OS 提供的接口,您可以编写应用程序来访问 IO 设备。
所以,你不能让用户应用程序在没有驱动程序帮助的情况下直接访问硬件,因为它是层次结构下面的所有驱动程序来访问设备,因为设备驱动程序是用可以与硬件通信的低级语言编写的,而用户应用程序是用高级语言编写的。
此外,check this answer 了解更多有关驱动程序地址 space 的信息 OS'。