перенос кода Planner

This commit is contained in:
2023-12-03 19:43:41 +03:00
parent b1e51ce599
commit 91331ae441
14 changed files with 980 additions and 776 deletions

View File

@@ -1,18 +1,27 @@
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
#if __cplusplus >= 201703L
#include <filesystem>
#else
#include <unistd.h>
#endif
#include "CompilationSupervisor.h"
#include "RunSupervisor.h"
#include "Global.h"
#include <unistd.h>
#include <signal.h>
//https://ru.wikipedia.org/wiki/%D0%A1%D0%B8%D0%B3%D0%BD%D0%B0%D0%BB_(Unix)
void hdl(int sig)
{
String file_name = "GOT_SIGNAL_AT_"+String(Utils::getAbsoluteTime());
String file_name = "GOT_SIGNAL_AT_"+ String(Utils::getAbsoluteTime());
FILE * res = fopen(file_name.getCharArray(),"w");
fprintf(res,"%d\n", sig);
fclose(res);
}
void set_handlers(){
void set_handlers() {
#ifndef _WIN32
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = hdl;
@@ -73,7 +82,9 @@ void set_handlers(){
sigaction(SIGVTALRM, &act, 0);
sigaction(SIGXCPU, &act, 0);
sigaction(SIGXFSZ, &act, 0);
#endif
}
int main(int argc, char ** argv)
{
//+
@@ -84,14 +95,25 @@ int main(int argc, char ** argv)
maxKernels = atoi(argv[3]);
dvm_drv = String(argv[4]);
//--
freeKernels = maxKernels;
busyKernels= 0;
//--
chdir(packageWorkspace.getCharArray());
freeKernels = maxKernels;
busyKernels= 0;
//--
#if __cplusplus >= 201703L
std::filesystem::current_path(packageWorkspace.getCharArray());
#else
chdir(packageWorkspace.getCharArray());
#endif
userWorkspace.println();
packageWorkspace.println();
printf("%d\n", maxKernels);
#ifndef _WIN32
int pid = getpid();
#else
int pid = _getpid();
#endif
printf("PID=%d\n", pid);
File pidFile("PID", String(pid));
pidFile.Close();
@@ -107,6 +129,6 @@ int main(int argc, char ** argv)
RunSupervisor * runSupervisor = new RunSupervisor(compilationSupervisor);
printf("%ld\n", runSupervisor->getLength());
runSupervisor->print();
runSupervisor->Do();
runSupervisor->DoWithSchedule(maxKernels);
return 0;
}