mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0021690: "cpulimit" command does not implemented on Win32 platform
This commit is contained in:
parent
3928aec6c9
commit
47cbc555c8
@ -58,6 +58,7 @@ static clock_t MDTV_CPU_CURRENT; // cpu time already used at last
|
|||||||
|
|
||||||
#include <Draw_Chronometer.hxx>
|
#include <Draw_Chronometer.hxx>
|
||||||
#include <OSD_MAllocHook.hxx>
|
#include <OSD_MAllocHook.hxx>
|
||||||
|
#include <OSD_Chronometer.hxx>
|
||||||
|
|
||||||
#if defined (__hpux) || defined ( HPUX )
|
#if defined (__hpux) || defined ( HPUX )
|
||||||
#define RLIM_INFINITY 0x7fffffff
|
#define RLIM_INFINITY 0x7fffffff
|
||||||
@ -208,6 +209,31 @@ static Standard_Integer Draw_wait(Draw_Interpretor& , Standard_Integer n, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : cpulimit
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
#ifdef WNT
|
||||||
|
static unsigned int __stdcall CpuFunc (void * param)
|
||||||
|
{
|
||||||
|
clock_t aCurrent;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
Sleep (5);
|
||||||
|
Standard_Real anUserSeconds, aSystemSeconds;
|
||||||
|
OSD_Chronometer::GetProcessCPU (anUserSeconds, aSystemSeconds);
|
||||||
|
aCurrent = clock_t(anUserSeconds + aSystemSeconds);
|
||||||
|
|
||||||
|
if ((aCurrent - MDTV_CPU_CURRENT) >= MDTV_CPU_LIMIT)
|
||||||
|
{
|
||||||
|
printf ("CpuFunc : Fin sur Cpu Limit \n");
|
||||||
|
ExitProcess (2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
{
|
{
|
||||||
@ -226,25 +252,27 @@ static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
//WNT
|
//WNT
|
||||||
static int first=1;
|
static int aFirst = 1;
|
||||||
/*
|
|
||||||
unsigned int __stdcall CpuFunc(void * );
|
|
||||||
unsigned ThreadID;
|
|
||||||
|
|
||||||
if (n <= 1) MDTV_CPU_LIMIT = RLIM_INFINITY;
|
unsigned int __stdcall CpuFunc (void *);
|
||||||
else {
|
unsigned aThreadID;
|
||||||
|
|
||||||
MDTV_CPU_LIMIT = atoi(a[1]);
|
|
||||||
MDTV_CPU_CURRENT = clock()/1000;
|
|
||||||
|
|
||||||
if (first) // Launch the thread only at the 1st call.
|
if (n <= 1)
|
||||||
{
|
MDTV_CPU_LIMIT = RLIM_INFINITY;
|
||||||
first=0 ;
|
else
|
||||||
_beginthreadex(NULL,0,CpuFunc,NULL,0,&ThreadID);
|
{
|
||||||
}
|
MDTV_CPU_LIMIT = atoi (a[1]);
|
||||||
|
Standard_Real anUserSeconds, aSystemSeconds;
|
||||||
|
OSD_Chronometer::GetProcessCPU (anUserSeconds, aSystemSeconds);
|
||||||
|
MDTV_CPU_CURRENT = clock_t(anUserSeconds + aSystemSeconds);
|
||||||
|
|
||||||
|
if (aFirst) // Launch the thread only at the 1st call.
|
||||||
|
{
|
||||||
|
aFirst = 0;
|
||||||
|
_beginthreadex (NULL, 0, CpuFunc, NULL, 0, &aThreadID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1 +0,0 @@
|
|||||||
cpulimit.pc
|
|
@ -36,25 +36,6 @@
|
|||||||
|
|
||||||
static int dejadraw = 0;
|
static int dejadraw = 0;
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : cpulimit (WNT)
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
#ifdef WNT
|
|
||||||
#include "cpulimit.pc"
|
|
||||||
|
|
||||||
static Standard_Integer cpulimit_draw(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
|
||||||
{
|
|
||||||
if (n < 2) { di<<"Give a value"<<"\n"; return 1; }
|
|
||||||
int nn = atoi(a[1]);
|
|
||||||
di<<"LIMIT ELASPED TIME = "<<nn<<" seconds"<<"\n";
|
|
||||||
limitelapsed(nn);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#72 rln 09.03.99 Packaging of SWDRAW
|
//#72 rln 09.03.99 Packaging of SWDRAW
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -210,10 +191,6 @@ void SWDRAW::Init (Draw_Interpretor& theCommands)
|
|||||||
SWDRAW_ShapeProcess::InitCommands (theCommands);
|
SWDRAW_ShapeProcess::InitCommands (theCommands);
|
||||||
SWDRAW_ShapeProcessAPI::InitCommands (theCommands);
|
SWDRAW_ShapeProcessAPI::InitCommands (theCommands);
|
||||||
|
|
||||||
#ifdef WNT
|
|
||||||
theCommands.Add("limitelapsed", "nn seconds",__FILE__, cpulimit_draw, "essai");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// locations
|
// locations
|
||||||
theCommands.Add("LocSet", "a [b [c]]: set loc b->a; use no args to get help",__FILE__,LocSet,"essai");
|
theCommands.Add("LocSet", "a [b [c]]: set loc b->a; use no args to get help",__FILE__,LocSet,"essai");
|
||||||
theCommands.Add("LocDump", "a: dump location of a",__FILE__,LocDump,"essai");
|
theCommands.Add("LocDump", "a: dump location of a",__FILE__,LocDump,"essai");
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
#ifdef WNT
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winbase.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
static clock_t MDTV_CPU_LIMIT; // Cpu_limit in Sec.
|
|
||||||
static clock_t MDTV_CPU_CURRENT; // cpu time already used at last
|
|
||||||
// cpulimit call. (sec.)
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned int __stdcall CpuFunc(void * param) {
|
|
||||||
|
|
||||||
clock_t current;
|
|
||||||
|
|
||||||
while ( 1 ) {
|
|
||||||
Sleep(5);
|
|
||||||
|
|
||||||
current = clock()/1000;
|
|
||||||
if ((current-MDTV_CPU_CURRENT) >= MDTV_CPU_LIMIT ){
|
|
||||||
|
|
||||||
printf("CpuFunc : Fin sur Cpu Limit \n");
|
|
||||||
ExitProcess(2);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//static Standard_Integer cpulimit(Draw_Interpretor& DI, Standard_Integer n, char** a)
|
|
||||||
void limitelapsed(int n ) {
|
|
||||||
|
|
||||||
static int first=1;
|
|
||||||
|
|
||||||
unsigned int __stdcall CpuFunc(void * );
|
|
||||||
|
|
||||||
unsigned ThreadID;
|
|
||||||
|
|
||||||
MDTV_CPU_LIMIT = n;
|
|
||||||
MDTV_CPU_CURRENT = clock()/1000;
|
|
||||||
|
|
||||||
|
|
||||||
if (first) { // Lancer le thread au 1er appel seulement.
|
|
||||||
first=0;
|
|
||||||
_beginthreadex(
|
|
||||||
|
|
||||||
NULL, // no security attributes
|
|
||||||
0, // use default stack size
|
|
||||||
CpuFunc, // thread function
|
|
||||||
NULL, // argument to thread function
|
|
||||||
0, // use default creation flags
|
|
||||||
&ThreadID); // returns the thread identifier
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user