您的位置:程序门 -> linux/unix社区 -> 内核及驱动程序研究区



关于时间片和中断


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于时间片和中断[无满意答案结贴,结贴人:priestath]
发表于:2007-01-15 10:48:46 楼主
请问一下,在中断处理程序执行的过程中,中断处理程序是否分配有时间片。
如果有,当然这只是种假设,因为中断处理程序都能很快的被执行,但如果出现意外,比如自旋,那么中断处理程序会一直占用cpu,   还是在自己的时间片用光后让出cpu?
但是,这时的内核是处于中断上下文中,中断处理程序让出cpu后又怎么会被再次调度呢?
如果没有,那么遇到前述的问题,系统是否就会崩溃?
发表于:2007-01-15 14:50:131楼 得分:0
自旋锁是否关中断呢
发表于:2007-01-17 19:10:372楼 得分:0
中断处理程序没有时间片一说,时间片是针对进程的。
发表于:2007-03-15 17:27:593楼 得分:0
linux的驱动程序分两个部分实现:top-half和bottom-half。
top-half在运行时,不能被其他任何中断再次中断,也不能被其他进程中断,它通过对cpu内的中断屏蔽置位实现,而bottom-half则只对top-half开中断。
这样,系统就可以根据中断服务程序的访问特点,安排那些访问临界区的服务程序为top-half,其他中断服务程序为bottom-half。

每次离开中断处理程序,系统会执行schedule(),发生进程调度。
发表于:2007-03-16 00:54:534楼 得分:0

sect   "spin   locks "   of   chap9       in   linux   kernel   development   2nd  
自旋锁可以在中断处理程序中使用,不过在获得锁之前,首先禁止本地中断(在当前处理器上的中断请求)。。。参见:
spin   locks   can   be   used   in   interrupt   handlers,   whereas   semaphores   cannot   be   used   because   they   sleep.   if   a   lock   is   used   in   an   interrupt   handler,   you   must   also   disable   local   interrupts   (interrupt   requests   on   the   current   processor)   before   obtaining   the   lock.   otherwise,   it   is   possible   for   an   interrupt   handler   to   interrupt   kernel   code   while   the   lock   is   held   and   attempt   to   reacquire   the   lock.   the   interrupt   handler   spins,   waiting   for   the   lock   to   become   available.   the   lock   holder,   however,   does   not   run   until   the   interrupt   handler   completes.   this   is   an   example   of   the   double-acquire   deadlock   discussed   in   the   previous   chapter.   note   that   you   need   to   disable   interrupts   only   on   the   current   processor.   if   an   interrupt   occurs   on   a   different   processor,   and   it   spins   on   the   same   lock,   it   does   not   prevent   the   lock   holder   (which   is   on   a   different   processor)   from   eventually   releasing   the   lock.


还有,中断处理程序运行的时候,相应的中断线在所有处理器上都被屏蔽,以防同一中断线接受另一个新的中断,但通常情况下,其他的所有中断都是打开的。。。。。。,参见:

section   “writing   an   interrupt   handler”of   chap6,
reentrancy   and   interrupt   handlers
interrupt   handlers   in   linux   need   not   be   reentrant.   when   a   given   interrupt   handler   is   EXECuting,   the   corresponding   interrupt   line   is   masked   out   on   all   processors,   preventing   another   interrupt   on   the   same   line   from   being   received.   normally   all   other   interrupts   are   enabled,   so   other   interrupts   are   serviced,   but   the   current   line   is   always   disabled.   consequently,   the   same   interrupt   handler   is   never   invoked   concurrently   to   service   a   nested   interrupt.   this   greatly   simplifies   writing   your   interrupt   handler.
 

sect   “interrupt   context”of   chap6,  
永远牢记:中断处理程序打断了其他代码(甚至可能是打断了在其他中断线上的另一中断处理程序),参见:
always   keep   in   mind   that   your   interrupt   handler   has   interrupted   other   code   (possibly   even   another   interrupt   handler   on   a   different   line!).  



快速检索

最新资讯
热门点击