no message

This commit is contained in:
2025-03-13 22:52:44 +03:00
parent cb7360ae86
commit c7626e877e
9 changed files with 22 additions and 110 deletions

View File

@@ -233,7 +233,7 @@ public:
if (checkKilled()) {
printf("killed\n");
while (activeTasks) {
while (busyKernels) {
printf("waiting for activeTasks %lu\n", activeTasks);
checkTasksFinish(activeTaskSet, toDel, activeTasks, done, busyKernels, buf);
Utils::Sleep(5);
@@ -289,9 +289,7 @@ public:
activeTasks--;
done += task->getKernels();
busyKernels -= task->getKernels();
#if DEB
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
#endif
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
//copy after end of while
//task->copyResults(pathRes);

View File

@@ -9,7 +9,7 @@
#include "Process_r.h"
Process_r task; //задача
char* coup_de_grace=NULL;
char* coup_de_grace=NULL; //команда добивания.
void hdl_abort_by_user(int sig)
{
@@ -38,96 +38,43 @@ void set_handlers(){
}
//argv[0] - имя программы
//argv[0] - время
//argv[1] путь к драйверу dvm
//argv[2] f/c(компиляция) или run(запуск)
//argv[3] имя программы
//argv[4] .. argv [argc-1] либо флаги компиляции, либо измерения решетки по одному
int main(int argc, char ** argv){
int i;
time_t time1;
time_t time2;
// for (i=0; i<argc; ++i){
// printf(("argv["+String_::ToString(i)+"] = '%s'\n").string,argv[i]);
// }
// printf("\n");
char ** args = new char* [argc] ;
char ** args = new char* [argc];
int maxtime = atoi(argv[0]);
coup_de_grace =argv[1];
/*
printf("\nmaxtime = %d\n",maxtime);
printf("\ncoup_de_grace = %'s'\n",coup_de_grace);
printf("dvm_drv = %'s'\n",argv[2]);
*/
for ( i=2; i<argc; ++i)
args [i-2] = argv[i];
args[argc-2] = NULL;
args[argc-1] = NULL;
/*
for (i=0; i<argc; ++i){
printf("args %d = '%s'\n",i,args[i]);
}
*/
#if 1
//------------
int pid = getpid();
task.Start();
//потомок - задача
if (task.pid ==0 )
execvp (argv[2],args);
time1 = time((time_t *)0);
int s;
double total_time = 0.;
int timer_pid = fork();
if (timer_pid ==0){
sleep(maxtime);
FILE * killed = fopen("TIMEOUT","w");
fprintf(killed,"task was killed by timer\n");
fclose(killed);
kill(pid,SIGINT);
exit(0);
}
set_handlers();
waitpid(task.pid,&s,WUNTRACED);
kill(timer_pid,SIGKILL);
time2 = time((time_t *)0);
total_time = difftime(time2, time1);
FILE * tt = fopen("total_time","w");
fprintf(tt,"%.5lf",total_time);
fclose(tt);
@@ -140,8 +87,6 @@ int main(int argc, char ** argv){
if ((coup_de_grace!=NULL)&&strlen(coup_de_grace)!=0)
system(coup_de_grace);
killpg(0, SIGKILL);
#endif
return 0;
}

View File

@@ -18,57 +18,23 @@
int main(int argc, char ** argv){
try {
int i;
// for (i=0; i<argc; ++i){
// printf(("argv["+String_::ToString(i)+"] = '%s'\n").string,argv[i]);
// }
#if 1
char ** args = new char* [argc] ;
//argv[1] путь к исполнителю
int i;
char ** args = new char* [argc];
for ( i=2; i<argc; ++i)
args [i-2] = argv[i];
// for (i=0; i<argc; ++i){
// printf(("args["+String_::ToString(i)+"] = '%s'\n").string,args[i]);
// }
args[argc-1] = NULL;
// printf("parent pid = %d\n",getpid());
setpgid(0,0);
int pid = fork();
if (pid == 0)
execvp( argv[1],args);
else {
// setpgid(pid, 0);
printf("%d\n",pid);}
#endif
if (pid == 0)
execvp( argv[1],args);
return 0;
}
catch (const char * exception){
// printf("Exception!\n");
FILE * ExceptionLog = fopen ( "Exception.txt", "w" );
fprintf(ExceptionLog,exception);
fclose(ExceptionLog);
}
}

View File

@@ -1 +1 @@
17
18