Ticket #508: recursive-critical-sections3.diff
File recursive-critical-sections3.diff, 2.5 KB (added by , 16 years ago) |
---|
-
api/boinc_api.C
96 96 static volatile double fraction_done; 97 97 static volatile double last_checkpoint_cpu_time; 98 98 static volatile bool ready_to_checkpoint = false; 99 static volatile boolin_critical_section;99 static volatile int in_critical_section; 100 100 static volatile double last_wu_cpu_time; 101 101 static volatile bool standalone = false; 102 102 static volatile double initial_wu_cpu_time; … … 866 866 if (options.handle_trickle_downs) { 867 867 handle_trickle_down_msg(); 868 868 } 869 if ( !in_critical_section&& options.handle_process_control) {869 if (in_critical_section == 0 && options.handle_process_control) { 870 870 handle_process_control_msg(); 871 871 } 872 872 if (options.backwards_compatible_graphics) { … … 877 877 // see if the core client has died, which means we need to die too 878 878 // (unless we're in a critical section) 879 879 // 880 if ( !in_critical_section&& options.check_heartbeat && heartbeat_active) {880 if (in_critical_section == 0 && options.check_heartbeat && heartbeat_active) { 881 881 if (heartbeat_giveup_time < interrupt_count) { 882 882 fprintf(stderr, 883 883 "No heartbeat from core client for %d sec - exiting\n", … … 947 947 // 948 948 void worker_signal_handler(int) { 949 949 if (options.direct_process_action) { 950 while (boinc_status.suspended && !in_critical_section) {950 while (boinc_status.suspended && in_critical_section == 0) { 951 951 sleep(1); // don't use boinc_sleep() because it does FP math 952 952 } 953 953 } … … 1050 1050 // 1051 1051 int boinc_time_to_checkpoint() { 1052 1052 if (ready_to_checkpoint) { 1053 in_critical_section = true;1053 boinc_begin_critical_section(); 1054 1054 return 1; 1055 1055 } 1056 1056 return 0; … … 1065 1065 update_app_progress(last_checkpoint_cpu_time, last_checkpoint_cpu_time); 1066 1066 } 1067 1067 time_until_checkpoint = (int)aid.checkpoint_period; 1068 in_critical_section = false;1068 boinc_end_critical_section(); 1069 1069 ready_to_checkpoint = false; 1070 1070 1071 1071 return 0; 1072 1072 } 1073 1073 1074 1074 void boinc_begin_critical_section() { 1075 in_critical_section = true;1075 in_critical_section++; 1076 1076 } 1077 1077 1078 1078 void boinc_end_critical_section() { 1079 in_critical_section = false; 1079 in_critical_section--; 1080 //just in case... 1081 if (in_critical_section < 0) { 1082 in_critical_section = 0; 1083 } 1080 1084 } 1081 1085 1082 1086 int boinc_fraction_done(double x) {