source: Sophya/trunk/ArchTOIPipe/Kernel/toimanager.cc@ 1687

Last change on this file since 1687 was 1687, checked in by aubourg, 24 years ago

restauration procsample, pb cvs

File size: 3.2 KB
RevLine 
[1365]1#include "toimanager.h"
2#include <limits.h>
3#include <pthread.h>
[1410]4#include <iostream.h>
[1365]5
[1684]6#ifndef MAXINT
7#define MAXINT 2147483647
8#endif
9
[1365]10TOIManager::TOIManager() {
11 reqBegin = 0;
[1684]12 reqEnd = MAXINT;
[1365]13}
14
15TOIManager* TOIManager::instance = NULL;
16
17TOIManager* TOIManager::getManager() {
18 if (instance == NULL) instance = new TOIManager();
19 return instance;
20}
21
[1684]22void TOIManager::setRequestedSample(int begin, int end) {
[1365]23 reqBegin = begin;
24 reqEnd = end;
25}
26
[1684]27int TOIManager::getRequestedBegin() {
[1365]28 return reqBegin;
29}
30
[1684]31int TOIManager::getRequestedEnd() {
[1365]32 return reqEnd;
33}
34
35void TOIManager::addThread(pthread_t* t) {
36 // cout << "adding thread " << t << endl;
37 threads.push_back(t);
38}
39
40void TOIManager::joinAll() {
41 for (vector<pthread_t*>::iterator i = threads.begin();
42 i != threads.end(); i++) {
43 pthread_t* pth = *i;
44 cout << "joining thread " << pth << endl;
45 pthread_join(*pth, NULL);
46 cout << "thread joined " << pth << endl;
47 }
48}
[1687]49
50
51// -----------------------------------------------------------------
52// Classe pour affichage de l'avancement des TOIProcessors
53// Reza 08/2001
54// -----------------------------------------------------------------
55
56RzProcSampleCounter::RzProcSampleCounter()
57{
58 _msg = "SampleCounter/Info";
59 _rate = 50;
60}
61
62RzProcSampleCounter::~RzProcSampleCounter()
63{
64}
65
66long RzProcSampleCounter::PrintStats()
67{
68 int istart = 0;
69 int iend = 0;
70 long dns_print = 1000;
71 int dns_print_fac = _rate;
72 int nbmax_dns_print = 2;
73
74 TOIManager* mgr = TOIManager::getManager();
75
76 istart = mgr->getRequestedBegin();
77 iend = mgr->getRequestedEnd();
78
79 dns_print = (iend-istart)/dns_print_fac;
80 if (dns_print < 1000) dns_print = ((iend-istart) < 1000) ? (iend-istart) : 1000;
81 if (dns_print < 1) dns_print = 1;
82 nbmax_dns_print = (iend-istart)/dns_print;
83
84 cout << "RzProcSampleCounter::PrintStats() InfoMessage=" << _msg
85 << "\n ... " << _msg << " istart="
86 << istart << " iend= " << iend << " dns_print= " << dns_print
87 << " nbmax_dns_print= " << nbmax_dns_print << endl;
88 // ------------------- Impression continu de stat ------------------------
89 long nb_dns_print = 0;
90 int nb_sleep = 0;
91 long last_sample_count = 0;
92 long processed_samples = 0;
93 long total_sample_count = dns_print*nbmax_dns_print;
94 bool alldone = false;
95 while (!alldone) {
96 processed_samples = ProcessedSampleCount();
97 if ( (processed_samples-last_sample_count > dns_print) ||
98 (processed_samples > total_sample_count-10) ) {
99 last_sample_count = processed_samples;
100 if (nb_dns_print == 0) cout << "\n";
101 nb_dns_print++;
102 cout << ">>> " << _msg << ": ProcessedSampleCount()= " << last_sample_count
103 << " Frac done = " << processed_samples*100/total_sample_count << " %" << endl;
104 if (last_sample_count > total_sample_count-10) alldone = true;
105 nb_sleep = 0;
106 }
107 else if ((nb_sleep+1)%5 == 0)
108 cout << "> " << _msg << ": ProcSamples()= " << processed_samples
109 << " Done = " << " %" << processed_samples*100/total_sample_count
110 << " NbSleep(1) = " << nb_sleep << endl;
111
112 sleep(1); nb_sleep++;
113 }
114
115 // -----------------------------------------------------------------------
116
117 return last_sample_count;
118
119}
Note: See TracBrowser for help on using the repository browser.