Wednesday, June 9, 2010

RTOS

RTOS has become very important as it is concerned with time critical events. Okay, let me list down few of the famous RTOS questions that can be discussed here.

1. What is priority inversion ?
2. What are the solutions for priority inversion ?
3. What is priority inheritance ?
4. What is priority ceiling ?
5. What is deadlock ?
6. What is the famous diners problem ?
7. What is mutex ?
8. What is spinlock ?
9. Where are spinlocks used ?
10. What do you mean by atomic operations ?
11. what is a semaphore ?
12. What are the types of semaphore ?
13. What is binary semaphore ?
14. What is a counting semaphore ?
15. What is message queue ?
16. What is the role of a scheduler ? How does it function ?
17. What is the difference between a normal OS and RTOS ?
18. What is preemption ?
19. What is preemptive multi-tasking/time-sharing ? What is its difference with co-operative multi-tasking/time-sharing ?
20. Threads are described as lightweight because switching between threads does not involve changing the memory context - True/False ?
21.What are the factors considered for a RTOS selection ?
22. What is the use of the method of temporarily masking / disabling interrupts ? When is it used ? What should be taken care while doing this method ?
23. Since, disabling/masking of interrupts can be done whent the critical section is ONLY SHORT,What method can be used if the critical section is longer than few source lines or if it involves few lengthy loopings ?
24. Difference between semaphores and disabling/masking of interrupts method ?
25. Binary semaphore is equivalent to Mutex - True/False. How ?
26. How can you avoid deadlocks incase of semaphore based designs ?
27. What is Message passing method ? What is its advantages ?
28. Tell about the design of Interrupt Handler and Scheduler in RTOS ?
29. What is interrupt latency ?
30. Even if we never enables interrupts in the code, the processor automatically disables them often during hardware access - True/False ? In this case how to reduce interrupt latency ?
31. When should we re-enable the interrupts in an ISR and why ?
32. How do you measure the latency of your system ?
33. What are First Level Interrupt handlers and Second level Interrupt handlers ?
34. What could be the typical design/implementation of FLIH and SLIH ?
35. Reentrant interrupt handlers might cause a stack overflow from multiple preemptions by the same interrupt vector - True / False ?
36. What kind of memory allocation procedure is good for embedded systems ?
37. Is there any RTOS that has non-preemptive scheduling ?
38. What is reentrant code ?
39. What is preemptive multitasking ?
40. What does timeslice refer to ?
41. If the time slice is too short then the scheduler will consume too much of processing time - True / False
42. What is I/O bound ? What is CPU bound ?
43. What is non-preemptive multitasking ?
44. CFS uses 'nanosecond' granularity accounting, the atomic units by which individual process share the CPU instead of previous notion of 'timeslice' - True/False .
45. When will you use binary semaphore ?
46. When will you choose busy-wait instead of context switch ?
47. What are the possible scenarios in which context switching of threads can occur ?
48. Can you use mutex/semaphore inside an ISR ?
49. Explain a scenari that could cause deadlock ? What is the best solution for a deadlock ?
50. Will the performance of your application improve if it has only a single thread and it is running on multiple cores of a processor ?
51. What will happen if there are more threads requesting for CPU resource such as time ?
52. What is Gang Scheduling and how is it useful ?
53. Can you sleep in interrupt handler ?
54. What is the main drawback for not considering Linux as realtime / RTOS ?
55. What is the drawback in using semaphore for synchronization ? How does spinlock help in overcoming it ?
56. What does a semaphore consist of ? and What does a spinlock consist of ?
57. Why spinlocks are useless in uniprocessor systems ?
58. What is timeslice ?
59. What is the difference between multiprogramming and multiprocessing ?
60. What is parallel programming ?
61. What are the types of IPC mechanisms ?
62. What are the types of synchronization problems and what are the resources that can cause such problems ?
63. What is data race ?
64. What is Indefinite Postponement / Indefinite blocking or starvation ?
65. What are the synchronization relationships that are present in a multithreaded or mulitprogramming applications ?
66. How Many Processes or Threads Are Enough for an application ?
67. Tell the advantages and disadvantages of Co-operative multitasking.
67. When should we use mutex and when should we use semaphore ?
68. How do you select a scheduler for your project
69. What are the types of approach for designing a scheduler
70. 

12 comments:

  1. 1. What is priority inversion ?
    Ans:- It is a situation where high priority task dont get execution time (have to wait even if RTOS is pre-emptive scheduler) because low priority task have already acquired the resource which is requested by high priority task.

    ReplyDelete
    Replies
    1. In the above case High priority task is blocked till the resource got free. This time is any task with middle priority is in ready state then Middle priority task will active while High priority task is blocked.

      Delete
  2. 2. What are the solutions for priority inversion ?
    Ans:- below are the two approach to solve priority inversion.
    a. Priority inheritance
    b. priority ceiling

    ReplyDelete
  3. 3. What is priority inheritance ?
    Ans: It is a approach to reduce the waiting time of high priority task to get resource which is acquired by low priority task . It is achieved by making low priority task priority highest till it release the resource requested by high priority task.

    ReplyDelete

  4. 4. What is priority ceiling ?
    Ans:- It is a approach to reduce the waiting time of high priority task to get resource which is acquired by low priority task . In this approach every resource have predefined priority assigned, this priority is equal to the highest priority task who will request to acquire the resource, due to this any task who acquire the resource get priority raised equal to the resource priority till it release the resource , so resource get quickly release and no task has to wait even if it don't request for the resource which was a draw back of "priority inheritance" approach , in which task was getting highest priority for execution by which other higher priority task UN-necessarily has to wait even they don't want to acquire respective resource.

    5. What is deadlock ?
    Ans:- It is a situation where each task is interdependent on other resource which is already acquired by other task for completing further execution, which results in deadlock situation.

    ReplyDelete
  5. 6. What is the famous diners problem ?
    Ans:-The Dining Philosophers problem is a classic OS problem that’s usually stated in very non-OS terms:
    There are N philosphers sitting around a circular table eating spaghetti and discussing philosphy.
    The problem is that each philosopher needs 2 forks to eat, and there are only N forks, one
    between each 2 philosophers. if every philosopher try to eat spaghetti then no one can eat its a condition of dead lock

    7. What is mutex ?
    Ans:- It is a technique to achieve mutual exclusion.

    8. What is spinlock ?
    Ans:- Here a task keep on polling to get resource acquired which is already acquired by other task.

    9. Where are spinlocks used ?
    Ans:- In interrupt handler where process have sleep senario.


    10. What do you mean by atomic operations ?
    Ans:- An execution which not get interrupted by any thing.

    ReplyDelete
  6. 11. what is a semaphore ?
    ANS:- Mutual exclusion technique

    12. What are the types of semaphore ?
    Ans:- their are two tyes
    a) counting semaphore
    b) binary semaphore

    13. What is binary semaphore ?
    Ans:- where counting is limited to one and zero.

    14. What is a counting semaphore ?
    Ans:- counting is more then zero and one.

    15. What is message queue ?
    Ans:- It is a inter process communication (IPC) technique, to send and receive data in multiple processes.

    16. What is the role of a scheduler ? How does it function ?
    Ans:- The function of scheduler is to give time to every task for the execution, It function by adopting various scheduling policy like time slicing, per-emptive, rate monotonous .

    17. What is the difference between a normal OS and RTOS ?
    Ans:- Genral OS follows fairness policy where as RTOS follows time bound policy. In genral OS every task will get chance for execution , where is inRTOS task may get starve and their is predefined time task execution.

    18. What is preemption ?
    Ans:- Its a type of scheduling, where high priority task always get chance by pre-empting low priority task for the execution.

    19. What is preemptive multi-tasking/time-sharing ? What is its difference with co-operative multi-tasking/time-sharing ?

    20. Threads are described as lightweight because switching between threads does not involve changing the memory context - True/False ?
    Ans:- FALSE

    ReplyDelete
    Replies
    1. Answer for 19) The term preemptive multitasking is used to distinguish a multitasking operating system, which permits preemption of tasks, from a cooperative multitasking system wherein processes or tasks must be explicitly programmed to yield when they do not need system resources.
      In simple terms: Preemptive multitasking involves the use of an interrupt mechanism which suspends the currently executing process and invokes a scheduler to determine which process should execute next. Therefore, all processes will get some amount of CPU time at any given time.
      In preemptive multitasking, the operating system kernel can also initiate a context switch to satisfy the scheduling policy's priority constraint, thus preempting the active task

      Delete
  7. 21.What are the factors considered for a RTOS selection ?
    Ans:-
    a) size of foot print
    b) kind of licensing like open source etc
    c) Availability of support for the development
    d) Need of project to get satisfied by the RTOS

    22. What is the use of the method of temporarily masking / disabling interrupts ? When is it used ? What should be taken care while doing this method ?
    Ans:- while executing critical area code or atomic operation this method is used , the care should be taken to avoid hazardous condition which may arise due to interrupts by allotting very high priority interrupt enable.

    23. Since, disabling/masking of interrupts can be done whent the critical section is ONLY SHORT,What method can be used if the critical section is longer than few source lines or if it involves few lengthy loopings ?
    Ans:- Use semaphores for large critical section are.

    24. Difference between semaphores and disabling/masking of interrupts method ?
    Ans:-Semaphore is a technique for achieving mutual exclusion, where as disabling/masking of interrupt method is used to uninterruptedly execute the code.

    25. Binary semaphore is equivalent to Mutex - True/False. How ?
    Ans :- True, in both only two condition are their lock and unclock

    26. How can you avoid deadlocks incase of semaphore based designs ?
    Ans:- By segnaling to release semaphore from other process

    27. What is Message passing method ? What is its advantages ?
    Ans:-

    28. Tell about the design of Interrupt Handler and Scheduler in RTOS ?
    Ans:-

    ReplyDelete
    Replies
    1. answer 27) Message passing in computer science is a form of communication used in parallel computing, object-oriented programming, and interprocess communication. In this model, processes or objects can send and receive messages (comprising zero or more bytes, complex data structures, or even segments of code) to other processes. By waiting for messages, processes can also synchronize.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. The advantage of message passing is that the receiver of the message has the option to read the required message instead of reading from the start in FIFO or pipes.

    ReplyDelete