info about shared memory, calls, events and log files.

This commit is contained in:
2026-03-27 00:15:23 +01:00
parent 8357960a6b
commit 8349b65a83
17 changed files with 205 additions and 78 deletions

View File

@@ -11,8 +11,8 @@ typedef struct __shm_item__ {
ShmPlace next;
ShmPlace prev;
size_t size;
int size;
int alloc_size;
} ShmItem;
@@ -69,6 +69,40 @@ public:
return _mem + place;
}
public:
void info(int &usage, int &free_depth, int &free_size, int &item_depth, int &item_size, double &usage_factor) {
enterCritical();
usage = *_used;
auto count = [this](ShmPlace *l, int &depth, int &size, double &factor) {
depth = 0;
size = 0;
int alloc_size = 0;
ShmPlace p = *l;
while (p != SHM_NULL) {
//p -= sizeof(ShmItem);
ShmItem *i;
ref(p, &i);
size += i->size;
alloc_size += i->alloc_size;
depth += 1;
p = i->next;
}
if (size > 0) {
factor = (static_cast<double>(alloc_size) / static_cast<double>(size));
} else {
factor = 1.0;
}
};
double x;
count(_free_list, free_depth, free_size, x);
count(_first, item_depth, item_size, usage_factor);
leaveCritical();
}
public:
int alloc(size_t bytes) {
enterCritical();
@@ -104,6 +138,7 @@ public:
first_i->prev = p_i;
}
i->prev = SHM_NULL;
i->alloc_size = bytes;
*_first = p_i;
place = p_i + sizeof(ShmItem);
@@ -118,6 +153,7 @@ public:
*_used = u;
i->prev = SHM_NULL;
i->size = bytes;
i->alloc_size = bytes;
i->next = *_first;
if (*_first != SHM_NULL) {
ShmItem *first_i;
@@ -574,6 +610,11 @@ void *Shm::ref(int place)
return _shm_api->ref(place);
}
void Shm::info(int &usage, int &free_depth, int &free_size, int &item_depth, int &item_size, double &usage_factor)
{
_shm_api->info(usage, free_depth, free_size, item_depth, item_size, usage_factor);
}
void Shm::lock()
{
_shm_api->enterCritical();