RTOS Question:
Download Questions PDF

What are the rules you follow when you are writing critical section of code?


a) Use Atomic Instructions
b) Remember to enable interrupts
c) Make the critical section code as small as possible.
(Prefer not more than 20 instructions)
d) Prefer not to call other functions from the critical
section. if u r calling, see that there is no critical
section in the other function too. Critical section is
bounded by Disable Interrupt and Enable Interrupt.
Check the example below.
/* Critical Section Start */
Some Instructions A ....
Call FnB();
/* do Something B */
Some Instructions B ....
/* Critical Section End */

/* Critical Section Start */
Some Instructions ..
/* Critical Section End */

Now the Enable_Interrupts in fnB() will enable the
interrupts and hence "Some Instructions B .." in fnA()
which should have been in critical section will no more be
in critical section because the interrupts are already

Please check if this condition is handled by the Enable and
Disable functions. If you want suggestions on how to solve
this problem, do revert back

Download Real-Time Operating System (RTOS) Interview Questions And Answers PDF

Previous QuestionNext Question
What is the need of creating 4GB of pages in Linux?What are the advantages and disadvantages of winCE compared to GPOS?