Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

rk_util.c File Reference


Detailed Description

Implementation of the functions in rk_util.h.

Definition in file rk_util.c.

Include dependency graph for rk_util.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MAX_RK_SETS   128
#define MAX_PID_COUNT   128

Functions

rk_resource_set_t rk_resource_set_get_by_name (const char *name)
 Search for a resource set by name and return the first one encountered.
int rk_resource_set_proc_compare (const void *a, const void *b)
 Function for comparing two rk_resource_set_proc objects.
int rk_resource_set_proc_cache_search (rk_resource_set_proc_cache_t pc, pid_t pid)
 Search for a particular process ID in a process cache.
int rk_resource_set_proc_cache_add (rk_resource_set_proc_cache_t pc, pid_t pid)
 Add an element to a process cache.
unsigned long long rk_resource_set_proc_cache_intersect (rk_resource_set_proc_cache_t pc, pid_t *procs, size_t procs_length)
 Intersect the process cache array with a list of the currently active process IDs.
int rk_resource_set_get_usage (rk_resource_set_t rs, rk_resource_set_usage_t rsu_inout, rk_resource_set_proc_cache_t pc_inout)
 Compute the total resource usage for all the processes in a resource set.
void rk_resource_set_proc_cache_release (rk_resource_set_proc_cache_t pc)
 Release any resources stored in the given process cache.


Function Documentation

rk_resource_set_t rk_resource_set_get_by_name const char *  name  ) 
 

Search for a resource set by name and return the first one encountered.

Parameters:
name The resource set name to search for.
Returns:
A valid resource set pointer if the name was found, otherwise, NULL_RESOURCE_SET.

Definition at line 52 of file rk_util.c.

References require, RK_NAME_LEN, rk_resource_set_get_name(), rk_resource_set_t, and rk_resource_sets_get_list().

Referenced by RKTask::BeginCPUScheduling(), main(), paGetAdvocate(), rktProcessOptions(), and rts_grab_schedulable().

Here is the call graph for this function:

int rk_resource_set_get_usage rk_resource_set_t  rs,
rk_resource_set_usage_t  rsu_inout,
rk_resource_set_proc_cache_t  pc_inout
 

Compute the total resource usage for all the processes in a resource set.

Currently, this is implemented by stepping through all of the processes attached to the resource set and pulling the usage information from "/proc/<pid>/stat". Unfortunately, the standard kernel does not provide high-resolution data in the "stat" file, so the file in the "patch" directory must be applied to the kernel before this function can be used.

See also:
rk_util/patch/tslinux-3.1-procstat.patch
Parameters:
rs The resource set to compute the resource usage for.
rsu_inout An allocated rk_resource_set_stat_t object where the results should be placed.
pc_inout The process cache object where data can be stored and reused in future calls to this function.
Returns:
Zero on success, otherwise, an errno value.

Definition at line 244 of file rk_util.c.

References ensure, rk_resource_set_get_proclist(), rk_resource_set_proc_cache_add(), rk_resource_set_proc_cache_intersect(), rk_resource_set_proc_cache_search(), and rk_resource_set_t.

Referenced by main(), paGetAdvocate(), RKObserverAdvocate::run(), sigalrm(), and test_get_usage().

Here is the call graph for this function:

int rk_resource_set_proc_cache_add rk_resource_set_proc_cache_t  pc,
pid_t  pid
[static]
 

Add an element to a process cache.

Parameters:
pc The process cache to add an element to.
pid The process ID to add.
Returns:
The index in the process cache array where the new element can be found.

Definition at line 161 of file rk_util.c.

References ensure, require, rk_resource_set_proc_cache_search(), and rk_resource_set_proc_compare().

Referenced by rk_resource_set_get_usage().

Here is the call graph for this function:

unsigned long long rk_resource_set_proc_cache_intersect rk_resource_set_proc_cache_t  pc,
pid_t *  procs,
size_t  procs_length
[static]
 

Intersect the process cache array with a list of the currently active process IDs.

Parameters:
pc The process cache to intersect.
procs The list process IDs to intersect with the process cache.
procs_length The length of the "procs" array.

Definition at line 207 of file rk_util.c.

References require.

Referenced by rk_resource_set_get_usage().

void rk_resource_set_proc_cache_release rk_resource_set_proc_cache_t  pc  ) 
 

Release any resources stored in the given process cache.

Parameters:
pc The process cache whose contents should be released.

Definition at line 411 of file rk_util.c.

References require.

Referenced by main(), and RKObserverAdvocate::run().

int rk_resource_set_proc_cache_search rk_resource_set_proc_cache_t  pc,
pid_t  pid
[static]
 

Search for a particular process ID in a process cache.

Parameters:
pc The process cache to search.
pid The process ID to search for.
Returns:
The index in the process cache array where the process ID was found or -1 if the process does not exist in the array.

Definition at line 117 of file rk_util.c.

References ensure, and require.

Referenced by rk_resource_set_get_usage(), and rk_resource_set_proc_cache_add().

int rk_resource_set_proc_compare const void *  a,
const void *  b
[static]
 

Function for comparing two rk_resource_set_proc objects.

Required for quicksort.

Parameters:
a The left hand side of the comparison.
b The right hand side of the comparison.
Returns:
Zero if "a" and "b" are equal, -1 if "a" is less than "b", and 1 if "a" is greater than "b".

Definition at line 85 of file rk_util.c.

References ensure, and require.

Referenced by rk_resource_set_proc_cache_add().


Generated on Fri Oct 22 07:50:48 2004 for CPU Broker by  doxygen 1.3.9.1