Thread: Critical-Section Problem. (Dekker)

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    36

    Critical-Section Problem. (Dekker)

    I read this code in my OS book but I'm having trouble understanding it. Would someone explain to me what's happening in this code? This code is the first-known correct software solution to the critical-section problem for two processes and was developed by Dekker.

    Code:
    boolean flag[2];
    int turn;
    
    // Above two variables are shared by the two processes.
    
    do {
        flag[i]=TRUE;
        while (flag[j]){
            if (turn == j){
                while (turn == j)
                   ;// do nothing
                flag[i]=FALSE;
            }
        }
    
    // critical section
    
    turn = j;
    flag[i]=FALSE;
    
    // remainder section.
    
    }while (TRUE);
    I'm totally clueless about what's going on in this code.

  2. #2

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Check this site out too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critical problem dealing with a copy and pasted version
    By DivingPhoenix in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2007, 02:41 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM