Wednesday, March 29, 2017

Interview Question on Bluetooth

Question Asked in Qualcomm:

1. How to increase or decrease the priority of task in Bluedroid stack.

https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/4128e36%5E!/

we are using the int setpriority(int which, int who, int prio); System call

The getpriority() call returns the highest priority (lowest numerical value) enjoyed by any of the specified processes. 

The setpriority() call sets the priorities of all of the specified processes to the specified value. Only the superuser may lower priorities.

A child created by fork(2) inherits its parent's nice value.


28typedef enum {
29    TASK_HIGH_MEDIA = 0,
30    TASK_HIGH_GKI_TIMER,
31    TASK_HIGH_BTU,
32    TASK_HIGH_HCI_WORKER,
33    TASK_HIGH_USERIAL_READ,
34    TASK_UIPC_READ,
35    TASK_JAVA_ALARM,
36    TASK_HIGH_MAX
37} tHIGH_PRIORITY_TASK;

/system/core/include/system/thread_defs.h
enum {
    /*
     * ***********************************************
     * ** Keep in sync with android.os.Process.java **
     * ***********************************************
     *
     * This maps directly to the "nice" priorities we use in Android.
     * A thread priority should be chosen inverse-proportionally to
     * the amount of work the thread is expected to do. The more work
     * a thread will do, the less favorable priority it should get so that
     * it doesn't starve the system. Threads not behaving properly might
     * be "punished" by the kernel.
     * Use the levels below when appropriate. Intermediate values are
     * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
     */
    ANDROID_PRIORITY_LOWEST         =  19,

    /* use for background tasks */
    ANDROID_PRIORITY_BACKGROUND     =  10,

    /* most threads run at normal priority */
    ANDROID_PRIORITY_NORMAL         =   0,

    /* threads currently running a UI that the user is interacting with */
    ANDROID_PRIORITY_FOREGROUND     =  -2,

    /* the main UI thread has a slightly more favorable priority */
    ANDROID_PRIORITY_DISPLAY        =  -4,

    /* ui service treads might want to run at a urgent display (uncommon) */
    ANDROID_PRIORITY_URGENT_DISPLAY =  HAL_PRIORITY_URGENT_DISPLAY,

    /* all normal audio threads */
    ANDROID_PRIORITY_AUDIO          = -16,

    /* service audio threads (uncommon) */
    ANDROID_PRIORITY_URGENT_AUDIO   = -19,

    /* should never be used in practice. regular process might not
     * be allowed to use this level */
    ANDROID_PRIORITY_HIGHEST        = -20,

    ANDROID_PRIORITY_DEFAULT        = ANDROID_PRIORITY_NORMAL,
    ANDROID_PRIORITY_MORE_FAVORABLE = -1,
    ANDROID_PRIORITY_LESS_FAVORABLE = +1,
};
2. Communication b/w task in Bluedroid stack.

Ans: we are using _senmsg(data) API, inside this we are using the Message QUEUE to communicate between (b/w) the task.

3. Why does Bluetooth only allow 7 simultaneous slaves?

Ans: In a piconet, one master can actively communicate with seven other devices
(limited by a 3 bit address), and up to 255 devices can be part of the piconet but inactive("parked").

In the piconet, one or more slaves are connected to a single master. To identify each slave separately, each
slave is assigned a temporary 3 bit address to be used withn it is active.

Packets exchanged between the master and the slave carry the active member address of slave.
in other words, the address of the slave is used in both master and slave packets and in slave to master packets.
Slave that are disconnnected or parked, give up their address and a new one must be assigned when they re-enter the piconet.

The number of device that can be paired is practically unlimited- as long as you have enough

storage for every device's MAC address and link key.



---others---
Imp links:
1. http://www.cnblogs.com/JCSU/articles/1290373.html
2. http://www.techinterviews.com/c-interview-questions-and-answers

*****************************************************************************

1.How does bluetooth turn on? Explain the steps?
2.Tell anyone API which has been used in the framework from the lower level of stack?
3.Explain the code flow of the OPP profile?
4.Tell the file name of HAL which is used as the interface for your profile?
5.Explain the code flow in of btif,bta,jv,dm layer in bluedroid? How they interact?
6.In which layer is the state machine of the OPP profile exist?
7.Where is the L2cap layer code in the bluedroid stack?
8.How do you change the debugging level in the code?
9.How do the SDP works?
10.Tell the function name which is being called from the bt_sock.c to the corresonding RFCOMM and L2CAP file?

C Questions:
1.Why do you use the Volatile keyword?
2.Explain the storage class in C? Explain them?
3.Write the optimized code to delete a node which is 5th from the end? 
4.If a link list data part should contain all three int,char,float. Then how do you declare the linked list?
5.What is quick sorting? What is its worst and best case?
6.Explain the memory map?
7.Where the static,global,auto varible stored in the memory mapping?
8.What is the difference between inline function and MACRO?


OS questions:
1.How the scheduler works? How many types? Which is the best?
2.What is PCB? What does it store?
3.If a process wake up from the sleep which state it goes and what is the flow?
4.WHat is semaphore, mutex, spin lock? Explain the usage of them?

No comments:

Post a Comment

Qualcomm Short Term

  113 is the SL. 1st Target by mid July.

Total Pageviews