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

Embedded C Programming Questions and Answers

Answer: A

Keeping it short protects the latency of everything else, and the deferred work belongs in a task where the priority scheme can order it. A handler takes no parameters and returns nothing, being called by the hardware rather than by any code.

Please log in or register to report this question.

Answer: B

The full implementation can add tens of kilobytes and an unbounded stack requirement, and some versions allocate. Cut-down variants without floating point support, or a hand-written formatter, are what a constrained target uses.

Please log in or register to report this question.

Answer: C

A state machine indexing an array of function pointers, or a driver registering a callback, is the natural use. The cost is that the call cannot be inlined and that an uninitialised pointer jumps somewhere arbitrary, which is why such tables are usually const.

Please log in or register to report this question.

Answer: D

The parentheses round the star bind it to the identifier, so f is the pointer; without them the declaration would be a function returning a void pointer. Reading such declarations from the identifier outwards is the reliable technique.

Please log in or register to report this question.

Answer: A

Correct answer: puts the table in flash and protects it from a stray write

Marking the table const lets the linker place it in flash, saving scarce RAM, and a wild pointer writing to it then faults or is simply ignored rather than corrupting the dispatch. The calls through it are no faster; the gains are memory and robustness.

Please log in or register to report this question.

46.

The keyword that tells the compiler a variable is defined in another translation unit is

Answer: B

The declaration in a header says the object exists somewhere and gives its type; exactly one source file must then define it. Putting a definition rather than a declaration in a header is how duplicate symbol errors arise.

Please log in or register to report this question.

Answer: C

Correct answer: volatile, and accessed atomically or under protection

Two distinct problems must both be addressed. volatile stops the compiler caching the value in a register, so each access reads memory. It does nothing about atomicity, so a multi-byte variable can still be read half-updated - which needs a critical section or an atomic type. Neither measure substitutes for the other.

Please log in or register to report this question.

Answer: D

With optimisation on, the compiler reads the variable once, sees nothing in the loop that could change it and generates an infinite loop. Adding the qualifier forces a fresh read on every iteration, and a semaphore would be better still.

Please log in or register to report this question.

Answer: A

A busy loop burns the processor and prevents anything else running, whereas a blocked task costs nothing until the event arrives. The polling loop may actually respond a little sooner, since it avoids the context switch, and that is its only merit.

Please log in or register to report this question.

Answer: B

Recursion is perfectly legal C and sometimes the clearest expression of an algorithm. It is avoided because the stack requirement depends on the data, which defeats both the sizing calculation and the tools that check it.

Please log in or register to report this question.

Loading…
Tags: Embedded C Programming Questions and Answers || Embedded C Programming MCQ Questions and Answers || Embedded C Programming GK Questions and Answers || Embedded C Programming GK MCQ Questions || Embedded C Programming Multiple Choice Questions and Answers || Embedded C Programming GK || GK on Embedded C Programming || Embedded Systems Questions and Answers || Embedded Systems MCQ Questions and Answers || Embedded Systems GK Questions and Answers || GK on Embedded Systems