os 内核是基于事件的吗?内核是多线程还是多进程?
Is os kernel event-based? Does the kernel multithreaded or multiprocess?
最近看了一些关于os内核的书。我知道当一个事件(如时钟滴答声)发生时,它会触发一个中断然后内核指定的例程响应。
所以我的问题是:
1)当一个中断被触发时,其对应的内核例程仍然是运行,然后由于某种原因又触发了另一个中断。内核将如何响应?会不会在处理第一次中断的时候屏蔽掉第二次中断?还是第一个中断对应的例程被第二个中断了?如果第二个条件为真,内核如何确保例程是 "reentrance"?
2)内核是多线程还是多进程?我的意思是当事情像第一个问题一样时,内核会使用 CPU 的额外核心来处理中断?如果是这样,内核如何确保一切正常,就像 运行 在单核 CPU 上一样?
1) If an interruption is triggered and its corresponding kernel routine is still running, then another interruption is triggered for some sort of reason; how will the kernel respond? Will it mask the second interruption when it was handling the first interruption? Or the first interruption's corresponding routine was interrupted by the second one?
是;不同的操作系统可能:
在处理 IRQ 时屏蔽其他 IRQ
允许不同的IRQ嵌套(互相中断)
允许所有IRQ嵌套(包括同一个IRQ自己中断)
屏蔽一些IRQ并允许其他IRQ嵌套
不使用多个 IRQ(例如只使用定时器 IRQ,并轮询其他所有内容)
If the second condition was true, how does the kernel make sure the routines are "reentrant"?
如果 OS 设计者决定(部分或全部)IRQ 可能会中断其他 IRQ;然后他们需要弄清楚在他们允许的任何情况下重入将如何工作。这可以是 "do nothing that causes a problem"(例如,IRQ 处理程序可能只是向稍后执行实际工作的任务发送通知),并且可能是进一步的限制(例如,临时获取一个锁,以防止对 IRQ 处理程序的部分进一步的 IRQ可能会导致重入问题,但不会导致其他部分不会)。
2) Does the kernel multithreaded or multiprocess? I mean when things go like the first question, the kernel will use CPU's extra cores to handle interruptions?
是;不同的操作系统可能使用多线程或多处理(或两者兼而有之);并且可能会也可能不会使用其他内核来处理中断。
If it did, how can the kernel make sure everything works correctly just like running on a single-core CPU?
如果内核确实使用其他内核来处理中断;它还会做一些事情来确保一切正常。 "Something" 可以是锁系统、事务内存、lock-free/block-free 算法、"shared nothing" 方法或这些东西的组合。
最近看了一些关于os内核的书。我知道当一个事件(如时钟滴答声)发生时,它会触发一个中断然后内核指定的例程响应。
所以我的问题是: 1)当一个中断被触发时,其对应的内核例程仍然是运行,然后由于某种原因又触发了另一个中断。内核将如何响应?会不会在处理第一次中断的时候屏蔽掉第二次中断?还是第一个中断对应的例程被第二个中断了?如果第二个条件为真,内核如何确保例程是 "reentrance"?
2)内核是多线程还是多进程?我的意思是当事情像第一个问题一样时,内核会使用 CPU 的额外核心来处理中断?如果是这样,内核如何确保一切正常,就像 运行 在单核 CPU 上一样?
1) If an interruption is triggered and its corresponding kernel routine is still running, then another interruption is triggered for some sort of reason; how will the kernel respond? Will it mask the second interruption when it was handling the first interruption? Or the first interruption's corresponding routine was interrupted by the second one?
是;不同的操作系统可能:
在处理 IRQ 时屏蔽其他 IRQ
允许不同的IRQ嵌套(互相中断)
允许所有IRQ嵌套(包括同一个IRQ自己中断)
屏蔽一些IRQ并允许其他IRQ嵌套
不使用多个 IRQ(例如只使用定时器 IRQ,并轮询其他所有内容)
If the second condition was true, how does the kernel make sure the routines are "reentrant"?
如果 OS 设计者决定(部分或全部)IRQ 可能会中断其他 IRQ;然后他们需要弄清楚在他们允许的任何情况下重入将如何工作。这可以是 "do nothing that causes a problem"(例如,IRQ 处理程序可能只是向稍后执行实际工作的任务发送通知),并且可能是进一步的限制(例如,临时获取一个锁,以防止对 IRQ 处理程序的部分进一步的 IRQ可能会导致重入问题,但不会导致其他部分不会)。
2) Does the kernel multithreaded or multiprocess? I mean when things go like the first question, the kernel will use CPU's extra cores to handle interruptions?
是;不同的操作系统可能使用多线程或多处理(或两者兼而有之);并且可能会也可能不会使用其他内核来处理中断。
If it did, how can the kernel make sure everything works correctly just like running on a single-core CPU?
如果内核确实使用其他内核来处理中断;它还会做一些事情来确保一切正常。 "Something" 可以是锁系统、事务内存、lock-free/block-free 算法、"shared nothing" 方法或这些东西的组合。