pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Typedefs | Functions
pmm_load.h File Reference

Load data structures. More...

#include <pthread.h>

Go to the source code of this file.

Data Structures

struct  pmm_loadhistory
struct  pmm_load

Typedefs

typedef struct pmm_loadhistory PMM_Loadhistory
typedef struct pmm_load PMM_Load

Functions

struct pmm_loadnew_load ()
struct pmm_loadhistorynew_loadhistory ()
int init_loadhistory (struct pmm_loadhistory *h, int size)
void add_load (struct pmm_loadhistory *h, struct pmm_load *l)
int check_loadhistory (struct pmm_loadhistory *h)
void print_loadhistory (const char *output, struct pmm_loadhistory *h)
void print_load (const char *output, struct pmm_load *l)

Detailed Description

Load data structures.

Data structures representing the load and load history of a system

Definition in file pmm_load.h.

Typedef Documentation

typedef struct pmm_load PMM_Load

this is a record of system load

this is a circular array of load history, size determined at run time

Function Documentation

void add_load ( struct pmm_loadhistory h,
struct pmm_load l 
)

This function copies the structure l into the load history structure which is a circular array.

Parameters
hpointer to the load history structure
lpointer to the load to be copied into the next free/expired element of the circular array

Definition at line 120 of file pmm_load.c.

int check_loadhistory ( struct pmm_loadhistory h)

Do some sanity checking on the load history structure

Parameters
hpointer to load history
Returns
1 if load history passes check, 0 if it fails

Definition at line 160 of file pmm_load.c.

int init_loadhistory ( struct pmm_loadhistory h,
int  size 
)

Function initialises the array and indexes that are used to store the load history (in a circular type array)

Parameters
hpointer to a load history structure
sizesize of the circular array
Returns
0 on success, -1 on failure

TODO check that history is not already allocated, free in this case first

Definition at line 90 of file pmm_load.c.

struct pmm_load* new_load ( )
read

initialized a new load observation structure

Returns
pointer to an allocated and intialized load structure

Definition at line 191 of file pmm_load.c.

struct pmm_loadhistory* new_loadhistory ( )
read

Allocates and initialises memory for a new load history structure. This is a circular array arrangement with pointers to the beginning and end. Iteration over the array is done using the modulus operator to wrap the physically beginning and end addresses.

note for a given size we must keep size+1 elements in the array. Thus we store two different sizes. 'size' refers to the number of accessible elements in the circular array. 'size_mod' refers to actual allocated elements in the array and is only to be used when iterating through the accessible elements using i+1size_mod. 'size_mod' will always be the accessible size 'size' + 1

Returns
pointer to a new loadhistory structure or NULL on failure

Definition at line 50 of file pmm_load.c.

void print_load ( const char *  output,
struct pmm_load l 
)

prints a single load observation

Parameters
outputoutput stream to print to
lpointer to load structure to print

Definition at line 233 of file pmm_load.c.

void print_loadhistory ( const char *  output,
struct pmm_loadhistory h 
)

prints a load history sequence

Parameters
outputoutput stream to print to
hpointer to the load history

Definition at line 211 of file pmm_load.c.