My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Macros | Functions | Variables
stats.h File Reference

Functions for the sending and receiving of statistics between ctrl and runtime. More...

#include "unused_def.h"
#include "stat_ids.h"
#include <time.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  timed_stat
 Holds a single timestamped value. More...
 
struct  stat_sample_hdr
 Header for a single stat sample for a single item. More...
 
struct  stat_sample
 A single stat sample for a single item. More...
 
struct  stat_type_label
 Structure to hold both the stat ID and the string describing it. More...
 

Macros

#define REPORTED_MSU_STAT_TYPES
 
#define REPORTED_THREAD_STAT_TYPES
 
#define REPORTED_STAT_TYPES
 
#define N_REPORTED_STAT_TYPES   sizeof(reported_stat_types) / sizeof(*reported_stat_types)
 Number of reported stat types. More...
 
#define N_REPORTED_MSU_STAT_TYPES   sizeof(reported_msu_stat_types) / sizeof(*reported_msu_stat_types)
 
#define N_REPORTED_THREAD_STAT_TYPES   sizeof(reported_thread_stat_types) / sizeof(*reported_thread_stat_types)
 
#define MAX_STAT_ITEM_ID   4192
 Maxmimum identifier that can be assigned to a stat item. More...
 
#define STAT_SAMPLE_SIZE   5
 Number of statistics sampled in each send from runtime to controller. More...
 
#define STAT_SAMPLE_PERIOD_MS   500
 How often samples are sent from runtime to controller. More...
 

Functions

int is_thread_stat (enum stat_id id)
 
int is_msu_stat (enum stat_id id)
 
void free_stat_samples (struct stat_sample *samples, int n_samples)
 Frees a set of stat samples. More...
 
struct stat_sampleinit_stat_samples (int max_stats, int n_samples)
 Initilizes n sets of samples of statistics, each of which contains max_stats points. More...
 
int deserialize_stat_samples (void *buffer, size_t buff_len, struct stat_sample *samples, int n_samples)
 Deserializes from the provided buffer into the samples structure. More...
 
ssize_t serialize_stat_samples (struct stat_sample *samples, int n_samples, void *buffer, size_t buff_len)
 Serializes from the provided samples into the buffer More...
 
size_t serialized_stat_sample_size (struct stat_sample *sample, int n_samples)
 Determines the size needed to hold the serialized version of sample. More...
 

Variables

static struct stat_type_label reported_stat_types []
 Static structure so the reported stat types can be referenced as an array. More...
 
static struct stat_type_label reported_msu_stat_types []
 
static struct stat_type_label reported_thread_stat_types []
 

Detailed Description

Functions for the sending and receiving of statistics between ctrl and runtime.

Definition in file stats.h.

Macro Definition Documentation

#define MAX_STAT_ITEM_ID   4192

Maxmimum identifier that can be assigned to a stat item.

Definition at line 126 of file stats.h.

#define N_REPORTED_MSU_STAT_TYPES   sizeof(reported_msu_stat_types) / sizeof(*reported_msu_stat_types)

Definition at line 114 of file stats.h.

#define N_REPORTED_STAT_TYPES   sizeof(reported_stat_types) / sizeof(*reported_stat_types)

Number of reported stat types.

Definition at line 109 of file stats.h.

#define N_REPORTED_THREAD_STAT_TYPES   sizeof(reported_thread_stat_types) / sizeof(*reported_thread_stat_types)

Definition at line 120 of file stats.h.

#define REPORTED_MSU_STAT_TYPES
Value:
{MSU_QUEUE_LEN, "QUEUE_LEN"}, \
{MSU_ITEMS_PROCESSED, "ITEMS_PROCESSED"}, \
{MSU_MEM_ALLOC, "MEMORY_ALLOCATED"}, \
{MSU_NUM_STATES, "NUM_STATES"}, \
{MSU_EXEC_TIME, "EXEC_TIME"}, \
{MSU_IDLE_TIME, "IDLE_TIME"}, \
{MSU_ERROR_CNT, "ERROR_COUNT"}, \
{MSU_UCPUTIME, "MSU_USER_TIME"}, \
{MSU_SCPUTIME, "MSU_KERNEL_TIME"}, \
{MSU_MINFLT, "MSU_MINOR_FAULTS"}, \
{MSU_MAJFLT, "MSU_MAJOR_FAULTS"}, \
{MSU_VCSW, "MSU_VOL_CTX_SW"}, \
{MSU_IVCSW, "MSU_INVOL_CTX_SW"}

Definition at line 68 of file stats.h.

#define REPORTED_STAT_TYPES
Value:
#define REPORTED_THREAD_STAT_TYPES
Definition: stats.h:85
#define REPORTED_MSU_STAT_TYPES
Definition: stats.h:68

Definition at line 96 of file stats.h.

#define REPORTED_THREAD_STAT_TYPES
Value:
{THREAD_UCPUTIME, "USER_TIME"}, \
{THREAD_SCPUTIME, "KERNAL_TIME"}, \
{THREAD_MAXRSS, "MAX_RSS"}, \
{THREAD_MINFLT, "MINOR_FAULTS"}, \
{THREAD_MAJFLT, "MAJOR_FAULTS"}, \
{THREAD_VCSW, "VOL_CTX_SW"}, \
{THREAD_IVCSW, "INVOL_CTX_SW"}

Definition at line 85 of file stats.h.

#define STAT_SAMPLE_PERIOD_MS   500

How often samples are sent from runtime to controller.

Definition at line 132 of file stats.h.

#define STAT_SAMPLE_SIZE   5

Number of statistics sampled in each send from runtime to controller.

Definition at line 129 of file stats.h.

Function Documentation

int deserialize_stat_samples ( void *  buffer,
size_t  buff_len,
struct stat_sample samples,
int  n_samples 
)

Deserializes from the provided buffer into the samples structure.

Parameters
bufferThe buffer to deserialize
buff_lenThe size of the serialized buffer
samplesThe structure into which to deserialize
n_samplesThe number of items allocated in samples
Returns
0 on success, -1 on error

Definition at line 176 of file stats.c.

void free_stat_samples ( struct stat_sample samples,
int  n_samples 
)

Frees a set of stat samples.

Definition at line 71 of file stats.c.

struct stat_sample* init_stat_samples ( int  max_stats,
int  n_samples 
)

Initilizes n sets of samples of statistics, each of which contains max_stats points.

Returns
allocated structure on success, NULL on error

Definition at line 80 of file stats.c.

int is_msu_stat ( enum stat_id  id)

Definition at line 49 of file stats.c.

int is_thread_stat ( enum stat_id  id)

Definition at line 40 of file stats.c.

ssize_t serialize_stat_samples ( struct stat_sample samples,
int  n_samples,
void *  buffer,
size_t  buff_len 
)

Serializes from the provided samples into the buffer

Parameters
samplesThe samples to deserialize
n_samplessize of samples
bufferThe buffer into which to serialize
buff_lenThe size of the allocated buffer
Returns
0 on success, -1 on error (if buffer is too small)

Definition at line 122 of file stats.c.

size_t serialized_stat_sample_size ( struct stat_sample sample,
int  n_samples 
)

Determines the size needed to hold the serialized version of sample.

Parameters
sampleThe sample to serialize
n_samplesThe number of elements in sample
Returns
size needed

Definition at line 96 of file stats.c.

Variable Documentation

struct stat_type_label reported_msu_stat_types[]
static
Initial value:
= {
{MSU_QUEUE_LEN, "QUEUE_LEN"}, {MSU_ITEMS_PROCESSED, "ITEMS_PROCESSED"}, {MSU_MEM_ALLOC, "MEMORY_ALLOCATED"}, {MSU_NUM_STATES, "NUM_STATES"}, {MSU_EXEC_TIME, "EXEC_TIME"}, {MSU_IDLE_TIME, "IDLE_TIME"}, {MSU_ERROR_CNT, "ERROR_COUNT"}, {MSU_UCPUTIME, "MSU_USER_TIME"}, {MSU_SCPUTIME, "MSU_KERNEL_TIME"}, {MSU_MINFLT, "MSU_MINOR_FAULTS"}, {MSU_MAJFLT, "MSU_MAJOR_FAULTS"}, {MSU_VCSW, "MSU_VOL_CTX_SW"}, {MSU_IVCSW, "MSU_INVOL_CTX_SW"}
}

Definition at line 111 of file stats.h.

struct stat_type_label reported_stat_types[]
static
Initial value:
= {
{MSU_QUEUE_LEN, "QUEUE_LEN"}, {MSU_ITEMS_PROCESSED, "ITEMS_PROCESSED"}, {MSU_MEM_ALLOC, "MEMORY_ALLOCATED"}, {MSU_NUM_STATES, "NUM_STATES"}, {MSU_EXEC_TIME, "EXEC_TIME"}, {MSU_IDLE_TIME, "IDLE_TIME"}, {MSU_ERROR_CNT, "ERROR_COUNT"}, {MSU_UCPUTIME, "MSU_USER_TIME"}, {MSU_SCPUTIME, "MSU_KERNEL_TIME"}, {MSU_MINFLT, "MSU_MINOR_FAULTS"}, {MSU_MAJFLT, "MSU_MAJOR_FAULTS"}, {MSU_VCSW, "MSU_VOL_CTX_SW"}, {MSU_IVCSW, "MSU_INVOL_CTX_SW"} , {THREAD_UCPUTIME, "USER_TIME"}, {THREAD_SCPUTIME, "KERNAL_TIME"}, {THREAD_MAXRSS, "MAX_RSS"}, {THREAD_MINFLT, "MINOR_FAULTS"}, {THREAD_MAJFLT, "MAJOR_FAULTS"}, {THREAD_VCSW, "VOL_CTX_SW"}, {THREAD_IVCSW, "INVOL_CTX_SW"}
}

Static structure so the reported stat types can be referenced as an array.

Definition at line 105 of file stats.h.

struct stat_type_label reported_thread_stat_types[]
static
Initial value:
= {
{THREAD_UCPUTIME, "USER_TIME"}, {THREAD_SCPUTIME, "KERNAL_TIME"}, {THREAD_MAXRSS, "MAX_RSS"}, {THREAD_MINFLT, "MINOR_FAULTS"}, {THREAD_MAJFLT, "MAJOR_FAULTS"}, {THREAD_VCSW, "VOL_CTX_SW"}, {THREAD_IVCSW, "INVOL_CTX_SW"}
}

Definition at line 117 of file stats.h.