Process and Kernel

本文探讨了进程作为运行程序的抽象概念,并介绍了内核如何通过双模式操作确保进程的安全执行。文中详细解释了安全控制转移的概念,包括从用户模式到内核模式的转换触发条件(如异常、中断和服务调用)以及从内核模式返回用户模式的方式。

Topic :

  • The process abstraction
  • Dual-mode operation
  • Safe control transfer

 

Process 是对运行程序的抽象。a process is an instance of a program. (有一个 process control block 储存了一个特定 process 的所有信息)

而 Kernel 与 program 的关系就像浏览器与第三方插件的关系一样。

为了阻止一个 process 做坏事(如覆盖其它 process 的data),最直接的想法是:Kernel 检查 process 中的每一条指令,但这样速度比较慢,于是设想是否有这样一种机制:允许一些安全的指令直接执行,而危险的指令需要检查。在处理中增加一个一位(mode bit)的寄存器, 用于区分 kernel mode 和 user mode。接下来的问题就是:什么时候两种 mode 互相切换。(safe control transfer)

 

Safe control transfer

User to kernel mode:Exception,Interrupt,System calls

Kernel to user mode:New process,Resume after exception,interrupt or system call,Switch to a different process, User-level upcall

 

Exception & Interrupt (如何执行看数字 x86 实例)

有一个 Interrupt vector:an array of process with each entry pointing to the first instruction of a different handler procedure in the kernel (类似函数调用,有一个 Interrupt stack,甚至许多系统给每个进程\线程 一个 kernel stack)

Interrupt masking

 

System call

System call provide the illusion that the operating system kernel is simply a set of library routines, avaiable for use by user programs: User level program can issue a system call by execute the trap instruction (有时利用 Interrupt) to transfer control to the operating system level.

 

User-level upcall

一个思想:virtualize some part of the operating system kernel, so that applications can behave more like operating system.

virtualized interrupts and exceptions 称作 upcall,在 Unix 称作 Signal

Upcall 的出现是因为就像 kernel 会接受一个 exception/interrupt 然后执行特定事件一样,application 也有接受特定 Signal 然后执行特定事件的需求(比如在 shell 中 ctrl + c) 

 

转载于:https://www.cnblogs.com/whuyt/p/4868324.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值