what are the rules u follow when u r writing critical
section of code?

Answers were Sorted based on User's Feedback



what are the rules u follow when u r writing critical section of code?..

Answer / teja

1.The operation must be atomic
2.The atomicity is ensured by disabling the interrupts and
immediately after crictical section enabling the
interrupts..here slight precausion has to be taken i.e do
not forget the enabling of interrupts ....

Is This Answer Correct ?    14 Yes 2 No

what are the rules u follow when u r writing critical section of code?..

Answer / bb

Always keep your execution code as minimal as possible in
the critical section.
Never use blocking calls in the critical section.

Is This Answer Correct ?    9 Yes 0 No

what are the rules u follow when u r writing critical section of code?..

Answer / vinod

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.
fnA()
{
/* Critical Section Start */
Disable_Interrupt();
Some Instructions A ....
Call FnB();
/* do Something B */
Some Instructions B ....
/* Critical Section End */
}


fnB()
{
/* Critical Section Start */
Disable_Interrupt();
Some Instructions ..
Enable_Interrupts();
/* 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
enabled!!

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

Is This Answer Correct ?    10 Yes 1 No

what are the rules u follow when u r writing critical section of code?..

Answer / vineesh mca@tkm

1. Operation Must be Atomic
2. The process which are not currently executing its
rtemainder section are only allowed to make request to
execute its critical section

Is This Answer Correct ?    6 Yes 1 No

what are the rules u follow when u r writing critical section of code?..

Answer / rk

1.The operation must be atomic
2.The atomicity is ensured by disabling the interrupts and
immediately after crictical section enabling the
interrupts..here slight precausion has to be taken i.e do
not forget the enabling of interrupts ....

Is This Answer Correct ?    1 Yes 0 No

what are the rules u follow when u r writing critical section of code?..

Answer / ac

Also do not access any slow I/O device.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More RTOS AllOther Interview Questions

Explain the difference between microkernel and macro kernel.

5 Answers   Infosys, Tech Mahindra,


Describe different job scheduling in operating systems.

9 Answers  


what are the rules u follow when u r writing critical section of code?

6 Answers   TCS,


What is the state of the processor, when a process is waiting for some event to occur?

14 Answers   MTS,


What is a Real-Time System ?

5 Answers  






When would you choose top down methodology?

3 Answers   CTS,


When would you choose bottom up methodology?

5 Answers   Knowx Innovations,


What is a mission critical system ?

3 Answers  


What is the difference between Hard and Soft real-time systems ?

11 Answers   Google, Hella, Satyam,


Give an example of microkernel.

13 Answers   Global Edge, Samsung,


what is difference between IRQ and FRQ ?

4 Answers   Bosch,


If two processes which shares same system memory and system clock in a distributed system, What is it called?

7 Answers  


Categories