Top VxWorks Interview Questions
Q – 1 What is priority inversion?
Ans- Priority inversion is a situation where in lower priority tasks will run blocking higher priority tasks waiting for
resource (mutex). For ex: consider 3 tasks. A, B and C, A being highest priority task and C is lowest. Look at
sequence of context swaps
A goes for I/O . unlocks mutex.
C was ready to run. So C starts running. locks mutex
B is ready to run. Swaps out C and takes mutex.
A is ready to run. but A is blocked as mutex is locked by B.
but B will never relinqishes the mutex as its higher
priority than C.
The solution to priority inversion is Priority inheritance.
Q – 2 What are the various methods to overcome it?
Ans- Priority Inheritance is the solution for priority inversion. whenever a high priority task request for some
resource which is locked by a low priority task, the priority of lower task is inherited to the priority of the
higher task. The instance it unlocks the resource the prioity is changed to its original value.
Another solution for this is priority ceiling where you inherit the priority of the lower task whenever a higher task is created.Even if the higher priority task doesnot request for the resource
Q – 3 What is another for creating a task without using taskspawn?
Ans- Instead of taskspawn
taskInit and taskActivate can be used to create task.
taskInit->It will initialize the task at specified address
taskActivate->It will activate the initialised task
Q – 4 Which RTOS supports Non-Preemptive scheduling? Why other scheduling methods are supported by such Oses?
Ans- The standard UNIX kernel is a nonpreemptive kernel; it does not allow a user process to preempt a process executing in
kernel mode. Once a running process issues a system call and enters kernel mode, preemptive context switches are disabled
until the system call is completed.
Although there are context switches, a system call may take an arbitrarily long time to execute without voluntarily giving up the processor.
During that time, the process that made the system call may delay the execution of a higher-priority, runnable, realtime
process.
The maximum process preemption latency for a nonpreemptive kernel is the maximum amount of time it can take for the running, kernel-mode process to switch out of kernel mode back into user mode and then be preempted by a
higher-priority process.
Under these conditions it is not unusual for worst-case preemption to take seconds, which is clearly unacceptable for many realtime applications.
Q – 5 What do you mean by Semaphore and when we will go for using this?
Ans- semaphore is used to avoid the effect of dead lock.
there are three types of semaphore .
1)binary semaphore->it is only to acquire and release the semaphore.zero is used for unavailabel and one is used for available.
2)counting semaphore->when semaphore is acquired counter is incremented and when semaphore is released conter is decremented.when counter is zero it is goes to blocked state.
3)mutual exclusion->it is same as binary semaphore.but it is used for safty purpose.it is two state locked state and unlocked state.when semaphore is acquired it is goes to locked state and when semaphore is released it goes to unlocked state.
Q – 6 Suppose there is a global variable & a static global variable.Both gets memory allocated from the data segment. Then how does the visiblity of static global varible gets limited to the file alone (in which it gets declared)
Ans- Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say
for a static variable inside a function cannot be called from outside the function (because it’s not in scope) but is
alive and exists in memory. The next time this function is entered (within the same program) the same chunk of memory
would be accessed now retaining the variables old value and no new memory is allocated this time for this variable like
other variables in the function (automatic variables).
So basically the variable persists throughout the program. Similarly if a static variable is defined in a global space
(say at beginning of file) then this variable will be accessible only in this file (file scope).
Q – 7 Write a code to connect Hardware interrupt to ISR and explain?
Ans- In Keil
void serial_ISR() interrupt 4 using 0
{
}
& in AVR studio
SIGNAL(Inteerupt_no)
{
}
hardware intterupt normally redirects the uC to predefined addresses. In case of high end processors the interrupt
table will decide the interrupt vector address and whenever intterrupt pin goes low, the table is searched for type and source of interrupt.
Q – 8 Explain task spawn in vxworks?
Ans- The VxWorks multitasking kernel, wind, uses interrupt-driven, priority-based task scheduling. It features fast context switch times and low interrupt latency. Under VxWorks, any subroutine can be spawned as a separate task, with its own context and stack. Other basic task control facilities allow tasks to be suspended, resumed, deleted, delayed, and moved in priority.
Is This Answer Correct? 1 Yes 0 No