Question

I was asked this question in an interview. Why is the bottom half of an interrupt service routine not allowed to have sleeps in it.My answer was that since the interrupts will be masked while executing the ISR we will miss some interrupts if the bottom halves have sleeps.I was not able to think of anything else.Is this the right answer.Can anyone think of any other reason for this.

Was it helpful?

Solution

The following is for Linux.

There are two types of bottom halves. The first one is comprised of softirqs and tasklets. Tasklets are build upon softirqs and are very similar. These 2 don't run in process context so therefore they can't sleep.

The second type is workqueue which runs in a kernel thread and can sleep.

There are some bottom halves which have to sleep. To the best of my knowledge the network system uses workqueues. I have written bottom halves that sleep.

Maybe you were asking about top halves which can't sleep out of 2 reasons. They are not running in a process context, therefore they can't and they should be executed as fast as possible and deffer all work to bottom halves, which if needed will sleep.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top