parent
1a94338389
commit
80d89c20fd
|
@ -82,14 +82,16 @@ struct Trace_subject_registry
|
||||||
|
|
||||||
bool _reconstruct_trace_connection = false;
|
bool _reconstruct_trace_connection = false;
|
||||||
|
|
||||||
|
template <typename FN>
|
||||||
unsigned update_subjects(Genode::Pd_session &pd,
|
unsigned update_subjects(Genode::Pd_session &pd,
|
||||||
Genode::Trace::Connection &trace)
|
Genode::Trace::Connection &trace,
|
||||||
|
FN const &fn)
|
||||||
{
|
{
|
||||||
Genode::Ram_quota ram_quota;
|
Genode::Ram_quota ram_quota;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
return trace.subjects(_subjects, MAX_SUBJECTS);
|
return trace.for_each_subject_info(fn);
|
||||||
} catch (Genode::Out_of_ram) {
|
} catch (Genode::Out_of_ram) {
|
||||||
trace.upgrade_ram(4096);
|
trace.upgrade_ram(4096);
|
||||||
}
|
}
|
||||||
|
@ -107,17 +109,7 @@ struct Trace_subject_registry
|
||||||
void update(Genode::Pd_session &pd, Genode::Trace::Connection &trace,
|
void update(Genode::Pd_session &pd, Genode::Trace::Connection &trace,
|
||||||
Genode::Allocator &alloc)
|
Genode::Allocator &alloc)
|
||||||
{
|
{
|
||||||
unsigned const num_subjects = update_subjects(pd, trace);
|
update_subjects(pd, trace, [&](Genode::Trace::Subject_id const &id, Genode::Trace::Subject_info const &info) {
|
||||||
|
|
||||||
if (num_subjects == MAX_SUBJECTS)
|
|
||||||
Genode::error("Not enough memory for all threads - "
|
|
||||||
"calculated utilization is not sane nor "
|
|
||||||
"complete !", num_subjects);
|
|
||||||
|
|
||||||
/* add and update existing entries */
|
|
||||||
for (unsigned i = 0; i < num_subjects; i++) {
|
|
||||||
|
|
||||||
Genode::Trace::Subject_id const id = _subjects[i];
|
|
||||||
|
|
||||||
Entry *e = _lookup(id);
|
Entry *e = _lookup(id);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
|
@ -125,7 +117,7 @@ struct Trace_subject_registry
|
||||||
_entries.insert(e);
|
_entries.insert(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
e->update(trace.subject_info(id));
|
e->update(info);
|
||||||
|
|
||||||
/* remove dead threads which did not run in the last period */
|
/* remove dead threads which did not run in the last period */
|
||||||
if (e->info.state() == Genode::Trace::Subject_info::DEAD &&
|
if (e->info.state() == Genode::Trace::Subject_info::DEAD &&
|
||||||
|
@ -135,7 +127,7 @@ struct Trace_subject_registry
|
||||||
_entries.remove(e);
|
_entries.remove(e);
|
||||||
Genode::destroy(alloc, e);
|
Genode::destroy(alloc, e);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (_reconstruct_trace_connection)
|
if (_reconstruct_trace_connection)
|
||||||
throw Genode::Out_of_ram();
|
throw Genode::Out_of_ram();
|
||||||
|
|
Loading…
Reference in New Issue