Machine-translated by Google. Questions are authored in English.
Top

Device Drivers Questions and Answers

Answer: A

Matching happens by compatible string from the device tree or by name, and the probe then maps the registers, requests the interrupt and registers the device with its subsystem. The remove function undoes exactly those steps in reverse.

Please log in or register to report this question.

22.

Put the steps of a platform driver's probe in order.

1. Register the device with its subsystem   2. Map the register block with ioremap   3. Read the addresses and interrupt from the device node   4. Request the interrupt

Answer: B

The node supplies the resources, they are mapped, the interrupt is requested once the handler can safely run, and the device is announced to the rest of the kernel only when it is fully ready. Registering first would expose a half-initialised device to a user.

Please log in or register to report this question.

Answer: C

Correct answer: acknowledge the device and schedule the deferred work

The top half runs with interrupts disabled or at high priority, so it must be as short as possible: acknowledge the device so it stops asserting, take whatever must be taken immediately, and schedule a tasklet or work item for the rest. It cannot sleep, so it cannot allocate in a way that might block.

Please log in or register to report this question.

Answer: D

Correct answer: runs in interrupt context and may not sleep

A tasklet is deferred but still in interrupt context, so it must not sleep and runs soon after the handler returns. A workqueue item runs in process context on a kernel thread and may sleep, which is what makes it the right choice for work needing to block. That difference decides between them.

Please log in or register to report this question.

Answer: A

Reading a sensor over I2C from a handler is impossible because the bus transfer sleeps; a threaded handler runs in a kernel thread and may do it. The primary handler merely quiets the device and asks for the thread to be woken.

Please log in or register to report this question.

Answer: B

Correct answer: is short and may be entered from interrupt context

A spinlock busy-waits, so it wastes processor time and is worth using only for a short section; and unlike a mutex it can be taken in interrupt context, where sleeping is impossible. Where the section is long or may sleep, a mutex is correct and a spinlock would be a serious fault.

Please log in or register to report this question.

Answer: C

Correct answer: another processor or the same one may spin for ever waiting for it

A spinlock is held while the holder sleeps, and anything else wanting it spins with interrupts disabled rather than yielding. On the same processor that is an immediate deadlock; on another it wastes the processor until the holder wakes, which it may never be scheduled to do.

Please log in or register to report this question.

28.

The function that maps a device's physical register block into kernel virtual address space is

Answer: D

The kernel runs with virtual addresses, so a physical peripheral address must be mapped before it can be dereferenced, and the mapping is marked uncached so accesses reach the device. Dereferencing the physical address directly gives a fault.

Please log in or register to report this question.

Answer: A

A process can pass any address, including one that is not mapped or belongs to the kernel, and the checked copy faults safely instead of corrupting memory or leaking it. Trusting a user pointer is a classic privilege escalation.

Please log in or register to report this question.

Answer: B

The accessors carry the compiler and processor barriers appropriate to the architecture and handle byte order where it differs, which a bare pointer dereference does not. On some architectures the difference is decisive.

Please log in or register to report this question.

Loading…
Tags: Device Drivers Questions and Answers || Device Drivers MCQ Questions and Answers || Device Drivers GK Questions and Answers || Device Drivers GK MCQ Questions || Device Drivers Multiple Choice Questions and Answers || Device Drivers GK || GK on Device Drivers || Embedded Systems Questions and Answers || Embedded Systems MCQ Questions and Answers || Embedded Systems GK Questions and Answers || GK on Embedded Systems