|
Lines 41-46
Link Here
|
| 41 |
#include <unistd.h> |
41 |
#include <unistd.h> |
| 42 |
#include <fcntl.h> |
42 |
#include <fcntl.h> |
| 43 |
|
43 |
|
|
|
44 |
#include <algorithm> |
| 45 |
|
| 44 |
// Network devices |
46 |
// Network devices |
| 45 |
#include <sys/types.h> |
47 |
#include <sys/types.h> |
| 46 |
#include <ifaddrs.h> |
48 |
#include <ifaddrs.h> |
|
Lines 132-138
Link Here
|
| 132 |
} |
134 |
} |
| 133 |
#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2) || defined(WITH_NETWORK_MANAGER_BACKEND) |
135 |
#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2) || defined(WITH_NETWORK_MANAGER_BACKEND) |
| 134 |
|
136 |
|
| 135 |
TDEHardwareDevices::TDEHardwareDevices() { |
137 |
TDEHardwareDevices::TDEHardwareDevices() : hwdevicePrc(NULL) { |
| 136 |
// Initialize members |
138 |
// Initialize members |
| 137 |
pci_id_map = 0; |
139 |
pci_id_map = 0; |
| 138 |
usb_id_map = 0; |
140 |
usb_id_map = 0; |
|
Lines 479-484
Link Here
|
| 479 |
// Detect what changed between the old cpu information and the new information, |
481 |
// Detect what changed between the old cpu information and the new information, |
| 480 |
// and emit appropriate events |
482 |
// and emit appropriate events |
| 481 |
|
483 |
|
|
|
484 |
timespec timeStart, timeCur; |
| 485 |
clock_gettime(CLOCK_MONOTONIC, &timeStart); |
| 486 |
|
| 482 |
#ifdef CPUPROFILING |
487 |
#ifdef CPUPROFILING |
| 483 |
timespec time1, time2, time3; |
488 |
timespec time1, time2, time3; |
| 484 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); |
489 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); |
|
Lines 872-883
Link Here
|
| 872 |
printf("TDEHardwareDevices::processModifiedCPUs() : end at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
877 |
printf("TDEHardwareDevices::processModifiedCPUs() : end at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 873 |
printf("TDEHardwareDevices::processModifiedCPUs() : total time: %u\n", diff(time3,time2).tv_nsec); |
878 |
printf("TDEHardwareDevices::processModifiedCPUs() : total time: %u\n", diff(time3,time2).tv_nsec); |
| 874 |
#endif |
879 |
#endif |
|
|
880 |
|
| 881 |
clock_gettime(CLOCK_MONOTONIC, &timeCur); |
| 882 |
//Stretching the execution period at 10% from the consumed time and not lesser for 500 ms |
| 883 |
m_cpuWatchTimer->start( std::max(500, int((((1000000000ll*timeCur.tv_sec+timeCur.tv_nsec)-(1000000000ll*timeStart.tv_sec+timeStart.tv_nsec))*9)/1000000)), FALSE ); |
| 875 |
} |
884 |
} |
| 876 |
|
885 |
|
| 877 |
void TDEHardwareDevices::processStatelessDevices() { |
886 |
void TDEHardwareDevices::processStatelessDevices() { |
| 878 |
// Some devices do not emit changed signals |
887 |
// Some devices do not emit changed signals |
| 879 |
// So far, network cards and sensors need to be polled |
888 |
// So far, network cards and sensors need to be polled |
| 880 |
TDEGenericDevice *hwdevice; |
|
|
| 881 |
|
889 |
|
| 882 |
#ifdef STATELESSPROFILING |
890 |
#ifdef STATELESSPROFILING |
| 883 |
timespec time1, time2, time3; |
891 |
timespec time1, time2, time3; |
|
Lines 886-904
Link Here
|
| 886 |
time3 = time1; |
894 |
time3 = time1; |
| 887 |
#endif |
895 |
#endif |
| 888 |
|
896 |
|
|
|
897 |
timespec timeStart, timeCur; |
| 898 |
clock_gettime(CLOCK_MONOTONIC, &timeStart); |
| 899 |
timeCur = timeStart; |
| 900 |
|
| 889 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
901 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
| 890 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
902 |
if(!hwdevicePrc) { |
| 891 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
903 |
m_deviceListPrc = listAllPhysicalDevices(); |
| 892 |
if ((hwdevice->type() == TDEGenericDeviceType::RootSystem) || (hwdevice->type() == TDEGenericDeviceType::Network) || (hwdevice->type() == TDEGenericDeviceType::OtherSensor) || (hwdevice->type() == TDEGenericDeviceType::Event) || (hwdevice->type() == TDEGenericDeviceType::Battery) || (hwdevice->type() == TDEGenericDeviceType::PowerSupply)) { |
904 |
hwdevicePrc = m_deviceListPrc.first(); |
| 893 |
rescanDeviceInformation(hwdevice, false); |
905 |
} |
| 894 |
emit hardwareUpdated(hwdevice); |
906 |
while( hwdevicePrc && ((1000000000ll*timeCur.tv_sec+timeCur.tv_nsec)-(1000000000ll*timeStart.tv_sec+timeStart.tv_nsec)) < 100000000 ) { //Not more for 100 ms |
| 895 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
907 |
if ((hwdevicePrc->type() == TDEGenericDeviceType::RootSystem) || (hwdevicePrc->type() == TDEGenericDeviceType::Network) || (hwdevicePrc->type() == TDEGenericDeviceType::OtherSensor) || (hwdevicePrc->type() == TDEGenericDeviceType::Event) || (hwdevicePrc->type() == TDEGenericDeviceType::Battery) || (hwdevicePrc->type() == TDEGenericDeviceType::PowerSupply)) { |
|
|
908 |
rescanDeviceInformation(hwdevicePrc, false); |
| 909 |
emit hardwareUpdated(hwdevicePrc); |
| 910 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevicePrc->uniqueID()); |
| 911 |
|
| 896 |
#ifdef STATELESSPROFILING |
912 |
#ifdef STATELESSPROFILING |
| 897 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
913 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 898 |
printf("TDEHardwareDevices::processStatelessDevices() : '%s' finished at %u [%u]\n", (hwdevice->name()).ascii(), time2.tv_nsec, diff(time1,time2).tv_nsec); |
914 |
printf("TDEHardwareDevices::processStatelessDevices() : '%s' finished at %u [%u]\n", (hwdevicePrc->name()).ascii(), time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 899 |
time1 = time2; |
915 |
time1 = time2; |
| 900 |
#endif |
916 |
#endif |
| 901 |
} |
917 |
} |
|
|
918 |
|
| 919 |
hwdevicePrc = m_deviceListPrc.next(); |
| 920 |
clock_gettime(CLOCK_MONOTONIC, &timeCur); |
| 902 |
} |
921 |
} |
| 903 |
|
922 |
|
| 904 |
#ifdef STATELESSPROFILING |
923 |
#ifdef STATELESSPROFILING |