git-svn-id: svn://db.shs.com.ru/pip@519 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -63,7 +63,6 @@
|
||||
# include <termios.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <linux/serial.h>
|
||||
# ifndef B50
|
||||
# define B50 0000001
|
||||
# endif
|
||||
@@ -113,6 +112,9 @@
|
||||
#ifndef CRTSCTS
|
||||
# define CRTSCTS 020000000000
|
||||
#endif
|
||||
#if defined(LINUX)
|
||||
# include <linux/serial.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*! \class PISerial
|
||||
@@ -828,7 +830,7 @@ void PISerial::optionsChanged() {
|
||||
|
||||
void PISerial::threadedReadBufferSizeChanged() {
|
||||
if (!isOpened()) return;
|
||||
#ifndef WINDOWS
|
||||
#if defined(LINUX)
|
||||
serial_struct ss;
|
||||
ioctl(fd, TIOCGSERIAL, &ss);
|
||||
//piCoutObj << "b" << ss.xmit_fifo_size;
|
||||
|
||||
@@ -27,11 +27,20 @@
|
||||
# include <psapi.h>
|
||||
# include <tlhelp32.h>
|
||||
#endif
|
||||
#ifdef MAC_OS
|
||||
# include <sys/proc_info.h>
|
||||
# include <libproc.h>
|
||||
#endif
|
||||
|
||||
|
||||
PRIVATE_DEFINITION_START(PISystemMonitor)
|
||||
#ifndef WINDOWS
|
||||
llong cpu_u_cur, cpu_u_prev, cpu_s_cur, cpu_s_prev;
|
||||
# ifdef MAC_OS
|
||||
PISystemTime
|
||||
# else
|
||||
llong
|
||||
# endif
|
||||
cpu_u_cur, cpu_u_prev, cpu_s_cur, cpu_s_prev;
|
||||
PIString proc_dir;
|
||||
PIFile file, filem;
|
||||
#else
|
||||
@@ -77,7 +86,9 @@ bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
||||
stop();
|
||||
self_ = false;
|
||||
pID_ = pID;
|
||||
cycle = -1;
|
||||
#ifndef WINDOWS
|
||||
# ifndef MAC_OS
|
||||
PRIVATE->proc_dir = PIStringAscii("/proc/") + PIString::fromNumber(pID_) + PIStringAscii("/");
|
||||
PRIVATE->file. open(PRIVATE->proc_dir + "stat", PIIODevice::ReadOnly);
|
||||
PRIVATE->filem.open(PRIVATE->proc_dir + "statm", PIIODevice::ReadOnly);
|
||||
@@ -85,7 +96,7 @@ bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
||||
piCoutObj << "Can`t find process with ID = " << pID_ << "!";
|
||||
return false;
|
||||
}
|
||||
cycle = -1;
|
||||
# endif
|
||||
#else
|
||||
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
|
||||
if (PRIVATE->hProc == 0) {
|
||||
@@ -125,6 +136,12 @@ void PISystemMonitor::stop() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAC_OS
|
||||
PISystemTime uint64toST(uint64_t v) {
|
||||
return PISystemTime(((uint*)&(v))[1], ((uint*)&(v))[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PISystemMonitor::run() {
|
||||
cur_tm.clear();
|
||||
tbid.clear();
|
||||
@@ -136,7 +153,29 @@ void PISystemMonitor::run() {
|
||||
tbid[t->tid()] = t->name();
|
||||
pitc->unlock();
|
||||
//piCout << tbid.keys().toType<uint>();
|
||||
stat.ID = pID_;
|
||||
#ifndef WINDOWS
|
||||
# ifdef MAC_OS
|
||||
rusage_info_current ru;
|
||||
proc_pid_rusage(pID_, RUSAGE_INFO_CURRENT, (rusage_info_t*)&ru);
|
||||
//piCout << PISystemTime(((uint*)&(ru.ri_user_time))[1], ((uint*)&(ru.ri_user_time))[0]);
|
||||
if (cycle < 0) {
|
||||
PRIVATE->cpu_u_prev = PRIVATE->cpu_u_cur = uint64toST(ru.ri_user_time);
|
||||
PRIVATE->cpu_s_prev = PRIVATE->cpu_s_cur = uint64toST(ru.ri_system_time);
|
||||
}
|
||||
cycle++;
|
||||
//if (cycle >= 4) {
|
||||
PRIVATE->cpu_u_prev = PRIVATE->cpu_u_cur;
|
||||
PRIVATE->cpu_s_prev = PRIVATE->cpu_s_cur;
|
||||
PRIVATE->cpu_u_cur = uint64toST(ru.ri_user_time);
|
||||
PRIVATE->cpu_s_cur = uint64toST(ru.ri_system_time);
|
||||
stat.cpu_load_system = 100.f * (PRIVATE->cpu_s_cur - PRIVATE->cpu_s_prev).toMilliseconds() / delay_;
|
||||
stat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_;
|
||||
//stat.cpu_load_system /= cpu_count;
|
||||
//stat.cpu_load_user /= cpu_count;
|
||||
cycle = 0;
|
||||
//piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_;
|
||||
# else
|
||||
PRIVATE->file.seekToBegin();
|
||||
PIString str(PRIVATE->file.readAll(true));
|
||||
int si = str.find('(') + 1, fi = 0, cc = 1;
|
||||
@@ -194,8 +233,8 @@ void PISystemMonitor::run() {
|
||||
continue;
|
||||
gatherThread(i.name().toInt());
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
stat.ID = pID_;
|
||||
// HMODULE hMod;
|
||||
// DWORD cbNeeded;
|
||||
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
||||
@@ -249,7 +288,7 @@ void PISystemMonitor::run() {
|
||||
}
|
||||
PRIVATE->tm.reset();
|
||||
#endif
|
||||
|
||||
|
||||
stat.cpu_load_system = piClampf(stat.cpu_load_system, 0.f, 100.f);
|
||||
stat.cpu_load_user = piClampf(stat.cpu_load_user, 0.f, 100.f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user