McAfee Interview Question
Software Engineer / DevelopersThese are called top halves and bottom halves. When a device raises an interrupt the isr should be executed fastly as the other processes are stopped while the isr is being executed, that means interrupt latency should be very less. When an interrupt is raised you just check the Interrupt status register to find what the interrupt is for(read/write/error) and differ the work of reading the data, taking actions on based on interrupts to be done later. In Linux this is done a technique called bottom halves, like softirqs, tasklets.
I guess both softirq and tasklets are bottom halves. Ans ISR may be the top half. ( Correct me otherwise)
hardware devices interact with kernel through sending signals to kernel.this is called interrupt.after receiving interrupt kernel must do corresponding actions by interrupt handlers called interrupt service routines.(ISR).
if ISR not preemtable and interrupts on the current processor or on all processors are disabled. now if ISR takes longer time to finish its work,system's interactive response will be degraded.
So to improve this ,total work is divided into two parts/halves.
1.top half-interrupt handler
2.bottom half-softirq,tasklet,workqueue.
In the top half , ISR will do most important time critical work like receiving data from network device or sending data to network device .
In the bottom half ,remaining data processing work like passing data to upper layers of newnetwork protocols by one of these like softirqs or tasklets or workqueues.
for most device drivers tasklets are good choice.
for very very time critical works, like network data or blocl data softirqs are used.
in the process context workqueues are used.
i never heard of such terms in developing device drivers.
my guess-
lower half is the harware(device)
upper half is the process requesting the status of the the device
upper half and lower half are the terms related to interrupt handler and hardware devices only via drivers raise interrupts in this context , they asked u in form of device driver. Each device has to register its interrupt handler (which is the part of device driver. Now for devices which raise interrupt frequently or in case when same interrupt handler is used via devices so to increase the service performance driver designers design the handlers in such a way that whenever an interrupt occurs the OS does the most important part of handler "upper half" to respond to interrupt,create a data structure containing device specific data called "lower half" for later processing when CPU becomes available. This way interrupt handlers can be used in case when the interrupt raise frequency is high.
- mrn July 13, 2011