Results 1 to 6 of 6

Thread: Don't know about critical section in c

  1. #1
    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'

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    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.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    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'.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    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:
    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);

    }

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    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.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    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.

Similar Threads

  1. Hidden section in SSX building Run
    By Hard.Kaur in forum Video Games
    Replies: 6
    Last Post: 02-03-2012, 08:24 PM
  2. How to get the new secret section of Limbo?
    By CAMDEND in forum Video Games
    Replies: 5
    Last Post: 07-08-2011, 11:31 PM
  3. Server 2003 Critical Patch KB929969=Critical Problems
    By bpacman in forum Windows Server Help
    Replies: 5
    Last Post: 18-11-2010, 08:37 AM
  4. Section 2 man pages missing
    By Xmen in forum Operating Systems
    Replies: 3
    Last Post: 30-11-2009, 11:02 AM
  5. Lighting section in the photoshop
    By Nevermind in forum Customize Desktop
    Replies: 1
    Last Post: 12-12-2008, 02:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,448,640.12108 seconds with 17 queries