GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 423 of 453    Print  
what do you mean by critical section in c?

  
Total Answers and Comments: 3 Last Update: September 09, 2008     Asked by: vmannur 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: preetin
 
Critical section is the part of the code that can be assessed by multiple threads or processes at the same time.

In order to protect the overwriting of the same memory space, this part of the code is protected by use of semaphores. One process takes the semaphore and during this period, it cannot be executd by any other thread. When the work is finished, the semaphore is released so that other processes can use it to update the memory space or read from it.

Above answer was rated as good by the following members:
sourabh_t, rajani_vaddepalli15
July 16, 2008 08:58:26   #1  
preetin Member Since: July 2008   Contribution: 1    

RE: what do you mean by critical section in c?
Critical section is the part of the code that can be assessed by multiple threads or processes at the same time.

In order to protect the overwriting of the same memory space this part of the code is protected by use of semaphores. One process takes the semaphore and during this period it cannot be executd by any other thread. When the work is finished the semaphore is released so that other processes can use it to update the memory space or read from it.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
July 17, 2008 00:05:07   #2  
deshdeepak53 Member Since: July 2008   Contribution: 1    

RE: what do you mean by critical section in c?
Critical section is the part of the code that can be assessed by multiple threads or processes at the same time.
 
Is this answer useful? Yes | No
September 09, 2008 16:03:44   #3  
rashmi.mohanty Member Since: September 2008   Contribution: 8    

RE: what do you mean by critical section in c?
critical section in c is a piece of code that accesses a shared resource (data structure or device) that must not be concurrently accessed by more than one thread/process of execution.
eg :-
while(1st thread is active)
{
Initialize CriticalSection
Enter Into CriticalSection
perform operation
Leave/release CriticalSection
Delete CriticalSection(1st thread)
}

while (2nd thread is active)
{
Initialize CriticalSection
Enter Into CriticalSection
perform 2nd thread operation
Leave/release CriticalSection
Delete CriticalSection(2nd thread)

}

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape