需要什么单独的“主管”?和“用户”模式?
continue
SUPERVISOR MODE vs USER MODE
Why does the OS need this distinction?
I know that the Supervisor mode is for OS support and I know that the User mode is for application support. I vaguely understand that these are used in order to ensure that the user's operations only occur in user mode while the OS operations only occur in super mode. I'm just looking for a little more in-depth discussion to fill in any gaps i may be missing.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用户模式禁止某些操作(例如写入随机存储器)以保护程序免受彼此的影响。管理员模式允许这些操作,因为操作系统需要它们来执行输入输出、启动程序等操作。
例如,查看内存保护。它可以防止程序写入彼此的内存。但为了使其正常工作,操作系统需要能够为每个程序设置内存页面映射。如果允许任何程序进行设置怎么办?那么就没有保护了——每个程序都可以破坏保护。这就是为什么需要超级用户模式来执行此类操作 - 只有操作系统可以执行此操作,而用户程序则不能执行此操作。
顺便说一句,管理员模式并不禁止“用户操作”——它允许任何操作。
User mode prohibits certain operations - for example writes to random memory - to protect programs from one another. Supervisor mode allows those operations because the operating system needs them to perform stuff like input-output, starting programs and so on.
For example, look at memory protection. It prevents programs from writing to each other's memory. But in order for it to function the operating system needs to be able to setup memory pages mapping for each program. What if any program is allowed to setup that? There's no protection then - each program can subvert protection. This is why superuser mode is required to do that kind of operations - only operating system can do it and user programs can't.
Btw supervisor mode doesn't prohibit "user operations" - it allows anything.
监管模式提供堆栈指针的第二个副本。用户堆栈和管理程序堆栈都位于不同的内存区域中。当前任务的堆栈指针将指向监督模式或用户模式。
USP - A7:用户堆栈指针
SSP - A7:监管堆栈指针
每种模式都有一个堆栈指针,因为每种模式都是独立的代码线程 - 一个用于当前顶级任务,另一个用于操作系统。如果它们都使用相同的堆栈,则操作系统可能会降低为用户应用程序分配的堆栈。换句话说。操作系统可能不知道堆栈的限制是什么,以支持任何给定的操作系统功能。
有两个独立的堆栈要安全得多。如果一个系统只有一个 stakc,操作系统必须自行调整堆栈指针寄存器,以确保不同的内存区域得到适当的使用 - 即。操作系统的内存和任务的内存。
Supervisory mode offers a second copy of a stack pointer. Both user stack and supervisor stack are in separate regions of memory. The stack pointer for the current task will point to either supervisory mode or user mode.
USP - A7: User stack pointer
SSP - A7: Supervisory stack pointer
Each mode has a stack pointer because each mode is self-contained thread of code - One for the current top level task, the other for the OS. If they both used the same stack there is a possibility that the operating system could bow the stack allocated for the user application. In other words. the OS may not know what the limits of the stack are in order to support any given operating system functionality.
It is much safer to have two separate stacks. If a system only has one stakc, the operating system has to adjust the stack pointer register on it's own to ensure that the different memory areas are used appropriately - ie. memory for the OS and memory for the task.