Changeset 1b2216 in git for Singular/LIB/general.lib
- Timestamp:
- Apr 12, 2013, 12:31:32 PM (11 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- ed9df0b6876dfc271e3fbd41a8cd35c8572a80f8
- Parents:
- 80f146cd522414ce52432c92dfa9773f1a0952d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/general.lib
r80f146c r1b2216 931 931 kill watchdog_rneu; 932 932 } 933 // If we do not have MP-links, watchdog cannot be used 934 if (system("with","MP")) 933 if ( i > 0 ) 935 934 { 936 if ( i > 0 ) 935 int j=10; 936 int k=999999; 937 // fork, get the pid of the child and send it the command 938 link l_fork="ssi:fork"; 939 open(l_fork); 940 execute("write(l_fork,quote(" + cmd + "));"); 941 942 943 // sleep in small, but growing intervals for appr. 1 second 944 while(j < k) 937 945 { 938 int j=10; 939 int k=999999; 940 // fork, get the pid of the child and send it the command 941 link l_fork="MPtcp:fork"; 942 open(l_fork); 943 write(l_fork,quote(system("pid"))); 944 int pid=read(l_fork); 945 execute("write(l_fork,quote(" + cmd + "));"); 946 947 948 // sleep in small, but growing intervals for appr. 1 second 949 while(j < k) 950 { 951 if (status(l_fork, "read", "ready", j)) {break;} 952 j = j + j; 953 } 946 if (status(l_fork, "read", "ready", j)) {break;} 947 j = j + j; 948 } 954 949 955 950 // sleep in intervals of one second 956 j = 1; 957 if (!status(l_fork,"read","ready")) 958 { 959 while (j < i) 951 j = 1; 952 if (!status(l_fork,"read","ready")) 953 { 954 while (j < i) 955 { 956 if (status(l_fork, "read", "ready", k)) {break;} 957 j = j + 1; 958 } 959 } 960 // check, whether we have a result, and return it 961 if (status(l_fork, "read", "ready")) 962 { 963 def result = read(l_fork); 964 if (nameof(basering)!=rname) 965 { 966 def watchdog_rneu=basering; 967 setring rsave; 968 if (!defined(result)) 960 969 { 961 if (status(l_fork, "read", "ready", k)) {break;} 962 j = j + 1; 970 def result=fetch(watchdog_rneu,result); 963 971 } 964 972 } 965 // check, whether we have a result, and return it 966 if (status(l_fork, "read", "ready")) 967 { 968 def result = read(l_fork); 969 if (nameof(basering)!=rname) 970 { 971 def watchdog_rneu=basering; 972 setring rsave; 973 if (!defined(result)) 974 { 975 def result=fetch(watchdog_rneu,result); 976 } 977 } 978 if(defined(watchdog_interrupt)) 979 { 980 kill watchdog_interrupt; 981 } 982 close(l_fork); 983 } 984 else 985 { 986 string result="Killed"; 987 if(!defined(watchdog_interrupt)) 988 { 989 int watchdog_interrupt=1; 990 export watchdog_interrupt; 991 } 992 close(l_fork); 993 j = system("sh","kill " + string(pid)); 994 } 995 return(result); 973 if(defined(watchdog_interrupt)) 974 { 975 kill watchdog_interrupt; 976 } 977 close(l_fork); 996 978 } 997 979 else 998 980 { 999 ERROR("First argument of watchdog has to be a positive integer."); 1000 } 981 string result="Killed"; 982 if(!defined(watchdog_interrupt)) 983 { 984 int watchdog_interrupt=1; 985 export watchdog_interrupt; 986 } 987 close(l_fork); 988 } 989 return(result); 1001 990 } 1002 991 else 1003 992 { 1004 ERROR(" MP-support is not enabled in this version of Singular.");993 ERROR("First argument of watchdog has to be a positive integer."); 1005 994 } 1006 995 } … … 1141 1130 if (size(#) > 0) 1142 1131 { 1143 if ( system("with", "MP"))1132 if ((typeof(#[1]) == "int")&&(#[1])) 1144 1133 { 1145 if ((typeof(#[1]) == "int")&&(#[1])) 1146 { 1147 int wait = #[1]; 1148 int j = 10; 1149 1150 string bs = nameof(basering); 1151 link l_fork = "MPtcp:fork"; 1152 open(l_fork); 1153 write(l_fork, quote(system("pid"))); 1154 int pid = read(l_fork); 1155 write(l_fork, quote(timeFactorize(eval(i)))); 1156 1157 // sleep in small intervalls for appr. one second 1158 if (wait > 0) 1134 int wait = #[1]; 1135 int j = 10; 1136 1137 string bs = nameof(basering); 1138 link l_fork = "ssi:fork"; 1139 open(l_fork); 1140 write(l_fork, quote(timeFactorize(eval(i)))); 1141 1142 // sleep in small intervalls for appr. one second 1143 if (wait > 0) 1144 { 1145 while(j < 1000000) 1159 1146 { 1160 while(j < 1000000) 1161 { 1162 if (status(l_fork, "read", "ready", j)) {break;} 1163 j = j + j; 1164 } 1147 if (status(l_fork, "read", "ready", j)) {break;} 1148 j = j + j; 1165 1149 } 1166 1167 // sleep in intervalls of one second from now on 1168 j = 1; 1169 while (j < wait) 1150 } 1151 1152 // sleep in intervalls of one second from now on 1153 j = 1; 1154 while (j < wait) 1155 { 1156 if (status(l_fork, "read", "ready", 1000000)) {break;} 1157 j = j + 1; 1158 } 1159 1160 if (status(l_fork, "read", "ready")) 1161 { 1162 def result = read(l_fork); 1163 if (bs != nameof(basering)) 1170 1164 { 1171 if (status(l_fork, "read", "ready", 1000000)) {break;} 1172 j = j + 1; 1165 def PP = basering; 1166 setring P; 1167 def result = imap(PP, result); 1168 kill PP; 1173 1169 } 1174 1175 if (status(l_fork, "read", "ready")) 1176 { 1177 def result = read(l_fork); 1178 if (bs != nameof(basering)) 1179 { 1180 def PP = basering; 1181 setring P; 1182 def result = imap(PP, result); 1183 kill PP; 1184 } 1185 kill l_fork; 1186 } 1187 else 1188 { 1189 list result; 1190 intvec v=1,1; 1191 result[1]=list(1,i); 1192 result[2]=v; 1193 j = system("sh", "kill " + string(pid)); 1194 } 1195 return (result); 1196 } 1170 close(l_fork); 1171 } 1172 else 1173 { 1174 list result; 1175 intvec v=1,1; 1176 result[1]=list(1,i); 1177 result[2]=v; 1178 close(l_fork); 1179 } 1180 return (result); 1197 1181 } 1198 1182 } … … 1218 1202 if (size(#) > 0) 1219 1203 { 1220 if ( system("with", "MP"))1204 if ((typeof(#[1]) == "int")&&(#[1])) 1221 1205 { 1222 i f ((typeof(#[1]) == "int")&&(#[1]))1223 {1224 int wait = #[1]; 1225 int j = 10;1226 1227 string bs = nameof(basering);1228 link l_fork = "MPtcp:fork";1229 open(l_fork);1230 write(l_fork, quote(system("pid")));1231 int pid = read(l_fork); 1232 write(l_fork, quote(timeStd(eval(i))));1233 1234 // sleep in small intervalls for appr. one second1235 if (wait >0)1206 int wait = #[1]; 1207 int j = 10; 1208 1209 string bs = nameof(basering); 1210 link l_fork = "ssi:fork"; 1211 open(l_fork); 1212 write(l_fork, quote(system("pid"))); 1213 int pid = read(l_fork); 1214 write(l_fork, quote(timeStd(eval(i)))); 1215 1216 // sleep in small intervalls for appr. one second 1217 if (wait > 0) 1218 { 1219 while(j < 1000000) 1236 1220 { 1237 while(j < 1000000) 1238 { 1239 if (status(l_fork, "read", "ready", j)) {break;} 1240 j = j + j; 1241 } 1221 if (status(l_fork, "read", "ready", j)) {break;} 1222 j = j + j; 1242 1223 } 1243 j = 1; 1244 while (j < wait) 1224 } 1225 j = 1; 1226 while (j < wait) 1227 { 1228 if (status(l_fork, "read", "ready", 1000000)) {break;} 1229 j = j + 1; 1230 } 1231 if (status(l_fork, "read", "ready")) 1232 { 1233 def result = read(l_fork); 1234 if (bs != nameof(basering)) 1245 1235 { 1246 if (status(l_fork, "read", "ready", 1000000)) {break;} 1247 j = j + 1; 1236 def PP = basering; 1237 setring P; 1238 def result = imap(PP, result); 1239 kill PP; 1248 1240 } 1249 if (status(l_fork, "read", "ready")) 1250 { 1251 def result = read(l_fork); 1252 if (bs != nameof(basering)) 1253 { 1254 def PP = basering; 1255 setring P; 1256 def result = imap(PP, result); 1257 kill PP; 1258 } 1259 kill l_fork; 1260 } 1261 else 1262 { 1263 ideal result=i; 1264 j = system("sh", "kill " + string(pid)); 1265 } 1266 return (result); 1267 } 1241 close(l_fork); 1242 } 1243 else 1244 { 1245 ideal result=i; 1246 close(l_fork); 1247 } 1248 return (result); 1268 1249 } 1269 1250 }
Note: See TracChangeset
for help on using the changeset viewer.