while (true) {
    Local_section(1);
    K1 = 0;
    while (K2 != 1) {
      if (turn == 2) {
        K1 = 1;
        while (turn != 1) {
          //  
        };
        K1 = 0;
      }
    }
    Critical_section(1);
    K1 = 1;
    turn = 2;
  }

  while (true) {
    Local_section(2);
    K2 = 0;
    while (K1 != 1) {
      if (turn == 1) {
        K2 = 1;
        while (turn != 2) {
          //  
        };
        K2 = 0;
      }
    }
    Critical_section(2);
    K2 = 1;
    turn = 1;
  }
K1 turn K2
1 1 1