Qualcomm Interview Question
Software Engineer / DevelopersWhat do you mean by virtual destructor? How do you design an ISR? what do you mean by priority inversion? Explain the difference between a semaphore and a ISR?
OK, to start with.
Virtual Dest: It has significance only when you are using a base class pointer to create a new derived class pointer. Now when you delete the derived object, it will get deleted only when the destructor for its class is declared as virtual.
Sample code:
<base-class> *bp = new <derived-class>
delete bp;
How do you design an ISR: If you mean interrupt service rotuines: i would say use callback functions (make use of function pointers, register your functions by passing their corresponding fps as arguments and facilitate the function so that it can catch the interrupt signals.
what do you mean by priority inversion: Not very sure about this.
Distinction: between semaphore and ISR they are totally independent concepts.
Yes, semaphore Vs mutex makes sense. Not sure but it should have something to with the degree of programming. Mutex need cond var to increase the degree whereas semaphore alone acheive this. (not very sure though)
Priority Inversion:
Its an issue with priority scheduler. Lets say there are three processes with high, medium and low priority - say H, M and L respectively. If H has to wait for L (for instance, for a lock held by L), and M is on the ready list, then H will never get the CPU because L (the low priority thread) will never get any CPU time. To solve this problem, H donates its priority to L, till L is holding the lock. And then L recall the donation once L releases (and thus H acquires) the lock.
A little change in my question..Explain the difference between a semaphore and a mutex?
- MostUnlucky February 15, 2010