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

Inter Task Communication Questions and Answers

61.

What is the occupancy of a 16-slot ring buffer with these indices, under the one-empty-slot convention?

write = 3;
read  = 14;

Answer: A

The write index has wrapped past the end, so the occupancy is the write index minus the read index taken modulo sixteen: three minus fourteen is minus eleven, and adding sixteen gives five. Doing that arithmetic with a mask rather than a conditional is why the size is a power of two.

Please log in or register to report this question.

62.

A counting semaphore is initialised to 3 to guard a pool of three buffers. After two successful takes its count is

Answer: B

Each take decrements the count, so two takes leave one buffer available and a third take would succeed before the fourth blocked. Initialising such a semaphore to the number of resources rather than to zero is the distinction between guarding a pool and signalling an event.

Please log in or register to report this question.

Answer: C

Starting at zero means the waiting task blocks until something actually happens, which is what signalling means. Starting at one is right for a lock, where the resource is free to begin with, and confusing the two initialisations gives a first iteration that runs on no data.

Please log in or register to report this question.

64.

A design gives a semaphore from a 1 kHz interrupt and takes it in a task that needs 1.2 ms per item. The outcome is

Answer: D

A thousand events a second against 833 the task can process is a sustained imbalance of a fifth, so the pending count rises until it reaches the semaphore's maximum and further events are lost silently. No buffer absorbs a sustained mismatch, and the arithmetic must be done before the design is committed.

Please log in or register to report this question.

Answer: A

The kernel protects the queue's own contents and the copy semantics mean neither task touches the other's storage, so there is nothing left to guard. Where a pointer is queued, ownership of the pointed-to buffer becomes a convention the two must observe, and that convention takes the place of the lock.

Please log in or register to report this question.

Answer: B

By the time the receiving task runs, the sender's function has very likely returned and the storage has been reused by something else, so the receiver reads whatever now occupies it. The buffer must come from a pool, from static storage or from the heap, and its ownership must pass to the receiver.

Please log in or register to report this question.

Answer: C

Every block is the same size, so a free list gives allocation and release in a fixed few instructions with no possibility of fragmentation, which is exactly what a long-running system needs. It wastes memory whenever an item is smaller than the block, and that waste is the price of the determinism.

Please log in or register to report this question.

Answer: D

Most kernels take no interest in what a deleted task was holding, so the lock is orphaned and every future acquirer blocks for ever. This is the strongest of the several reasons that deleting tasks at run time is discouraged in embedded designs.

Please log in or register to report this question.

Answer: A

Waking a high priority task is pointless if the system then resumes the low priority task it interrupted and waits for the next tick. The from-ISR calls therefore report whether a switch is wanted, and the handler yields on its way out, which is what keeps the response time short.

Please log in or register to report this question.

Answer: B

A counting semaphore records how many events occurred and nothing about them, so any payload needs a queue. Both count multiple events, both work from a handler and both accept a timeout, so the data is the only distinction that matters.

Please log in or register to report this question.

Loading…
Tags: Inter Task Communication Questions and Answers || Inter Task Communication MCQ Questions and Answers || Inter Task Communication GK Questions and Answers || Inter Task Communication GK MCQ Questions || Inter Task Communication Multiple Choice Questions and Answers || Inter Task Communication GK || GK on Inter Task Communication || Embedded Systems Questions and Answers || Embedded Systems MCQ Questions and Answers || Embedded Systems GK Questions and Answers || GK on Embedded Systems