vxworks

Semaphore/Mutex Interview Question for Embedded Systems Engineers

Q: What are the different types of semaphores in vxworks? Which is the fastest?
A: VxWorks supports three types of semaphores. Binary, mutual exclusion, and counting semaphores. Binary is the fastest semaphore.

Q: When will you use binary semaphore ?
A: Binary semaphores are used for basic task synchronization and communication.

Q: When will you use mutual exclusion semaphore?
A: Mutual exclusion semaphores are sophisticated binary semaphores that are used to address the issues relating to task priority inversion and semaphore deletion in a multitasking environment.

Q: When will you use Counting semaphore?
A: Counting semaphores maintain a count of the number of times a resource is given. This is useful when an action is required for each event occurrence. For example if you have ten buffers, and multiple tasks can grab and release the buffers, then you want to limit the access to this buffer pool using a counting semaphore.

Q: What is the difference between Mutex and binary semaphore?
A: The differences are:
1) Mutex can be used only for mutual exclusion, while binary can be used of mutual exclusion as well as synchronisation.
2) Mutex can be given only by the task that took it.
3) Mutex cannot be given from an ISR.
4) Mutual-exclusion semaphores can be taken recursively. This means that the semaphore can be taken more than once by the task that holds it before finally being released.
5) Mutex provides a options for making the task that took it as DELETE_SAFE. This means, that the task cannot be deleted when it holds mutex.

VxWorks Task, Interview Questions

Q: What is a task in VxWorks?
A: A task is an independent program with its own thread of execution and execution context. VxWorks uses a single common address space for all tasks thus avoiding virtual-to-physical memory mapping. Every task contains a structure called the task control block that is responsible for managing the task's context.

Q: How do task's manage the  context of execution ?
A: Every task contains a structure called the task control block that is responsible for managing the task's context. A task's context includes

· program counter or thread of execution
· CPU registers
· Stack of dynamic variables and function calls
· Signal handlers
· IO assignments
· Kernel control structures etc.,

Q: What are the Different states of tasks?
A task has 4 states. Read, Pend, Delay, Suspended

Q: Explain the task State transition ?
A: A task can be created with taskInit() and then activated with taskActivate() routine or both these actions can be performed in a single step using taskSpawn(). Once a task is created it is set to the suspend state and suspended until it is activated, after which it is added to the ready queue to be picked up by the scheduler and run. A task may be suspended by either the debugging your task, or the occurrence an exception. The difference between the pend and suspend states is that a task pends when it is waiting for a resource. A task that is put to sleep is added to delay queue.

VxWorks Interview Question for Embedded Systems Engineers

Q: What is a RealTime System ?
A: A Real-time system is defined as a system where the response time for an event is predictable and deterministic with minimal latency.

Q: How is RTOS different from a general operating system?
A:
TaskScheduling:
RTOS generally have priority-based preemptive scheduling, which allows high-priority threads to meet their deadlines consistently. Whereas In a GPOS, the scheduler typically uses a "fairness" policy to dispatch threads and processes onto the CPU. Such a policy enables the high overall throughput required by desktop and server applications, but offers no assurances that high-priority, time-critical threads will execute in preference to lower-priority threads.

Preemetive Kernel:
In RTOS, kernel operations are preemptible. And so the RTOS kernel must be simple and elegant as possible.

Mechanisms to Avoid Priority Inversion:
This occurs when a lower-priority thread can inadvertently prevent a higher-priority thread from accessing the CPU. VxWorks specifically has protection for this.

Q: What is a task in VxWorks?

Embedded Systems Interview Questions

In general the question would be of two type

1) Questions concentrating more on general skills as a software engineer
On C lang, algorithms, design skills, Tools used etc

2) Questions concentrating more on specific skills in real-time system design
On RTOS,multi-tasking issues (synchronization,exclusion, scheduling),device driver skills (interrupt handling, device addressing)

Typical questions (assuming VxWorks Experience):

1) What is an Interrupt Service Routine? What are the typical requirements for an ISR?
2) What are the advantages and disadvantages of cache memory in a real-time system that uses DMA?
3) What are the different types of timing requirements that real-time systems have?
4) What is priority inversion and how is it typically addressed?
5) How many levels of task priority are there in VxWorks? Explain the task priority settings in your system?
6) You finished writing a real-time system but find that the system performs much worse than expected. What should you do? (Answers shouldinclude: hardware verification [cache, SDRAM and device timing], compiler
settings, task priority settings, profiling, bad coding, etc.)

eg:
Soving issues in signaling to devices (ie being able to look at a logic analyser and find the problem with interdevice communication), Solving issues with data throught put(ie minimizing bus activity and processor useage to move data through a system), Service times for various threads/processes and activities ...

7) Discuss issues with dynamic memory allocation in real-time systems.
(If they don't mention the words "memory leak" or "thread-safe", they should
probably be excused.)

8) "What is the difference between the three types of semaphores in vxWorks'mutual-exclusion','binary', and 'counting'?"

Syndicate content