Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Don't know about critical section in c

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 15-01-2010
Member
 
Join Date: Dec 2009
Posts: 41
Don't know about critical section in c
  

Hi All,

While referring one C programming book I found one concept known as 'critical section'. I didn't get what does the exact meaning of 'critical section' in C programming. Have you aware about the 'critical section in c'? if yes then please share your knowledge with me so that I can clear my doubts regarding the 'critical section'

Reply With Quote
  #2  
Old 15-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: Don't know about critical section in c

Hi,

Critical section in C programming is the some part of code which can be assessable by multiple processes and threads at the single time. This part of program code is get protected by semaphores to avoid the overwriting of similar memory space. When the work over this critical section finishes the semaphore release it so that it cane be used by other processes while updating and reading the memory space.
Reply With Quote
  #3  
Old 15-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,514
Re: Don't know about critical section in c

In C programming language a critical section is a part of program code and which accesses a shared data structure or device. Critical section can not be accessed by multiple threads while execution of program. The critical section in C normally terminate within fixed amount of period. The Task, process of thread needs to wait for fixed period of time to access the Critical section of C.That is C language has some synchronization mechanism for the use of 'Critical section'.
Reply With Quote
  #4  
Old 15-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,947
Re: Don't know about critical section in c

Hello Friend,

Refer following program for critical section in C. Here I protected two processes from the critical section:
Quote:
while(First process is active)

{

InitializeCriticalSection(&chs);
EnterCriticalSection(&chs);
LeaveCriticalSection(&chs);
DeleteCriticalSection(&chs);

}

while (Second process is active)

{

InitializeCriticalSection(&chs);
EnterCriticalSection(&chs);
LeaveCriticalSection(&chs);
DeleteCriticalSection(&chs);

}
Reply With Quote
  #5  
Old 15-01-2010
Member
 
Join Date: May 2008
Posts: 2,006
Re: Don't know about critical section in c

A critical section in C is normally used when a multithreaded program code try to update multiple c variables which are related to each other without conflicting changes to that particular data. In some conditions 'critical section' can be useful to ensure the resource which are shared. The example of this situation is that a printer could be accessible for only one process at a single time. I hope it will clear you doubts about critical section in c.
Reply With Quote
  #6  
Old 15-01-2010
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: Don't know about critical section in c

critical section in C language is piece of a process which must be indivisibly executed. critical sections must be uninterrupted by particular set of processes.This section must have specific termination time. Sometime the the thread or proceed need to wait for specific amount of time before accessing the critical section in C programming. The overwriting in the critical section is can be avoid by using the semaphores.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Don't know about critical section in c"
Thread Thread Starter Forum Replies Last Post
Hidden section in SSX building Run Hard.Kaur Video Games 6 02-03-2012 07:24 PM
How to get the new secret section of Limbo? CAMDEND Video Games 5 07-08-2011 11:31 PM
Server 2003 Critical Patch KB929969=Critical Problems bpacman Windows Server Help 5 18-11-2010 07:37 AM
Section 2 man pages missing Xmen Operating Systems 3 30-11-2009 10:02 AM
Lighting section in the photoshop Nevermind Customize Desktop 1 12-12-2008 01:30 PM


All times are GMT +5.5. The time now is 05:52 PM.