00001 /* 00002 * rk_util.h 00003 * 00004 * Copyright (c) 2003 The University of Utah and the Flux Group. 00005 * All rights reserved. 00006 * 00007 * This file is licensed under the terms of the GNU Public License. 00008 * See the file "license.terms" for restrictions on redistribution 00009 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00010 */ 00011 00012 /** 00013 * @file rk_util.h 00014 * 00015 * Header file for utility functions related to the TimeSys resource kernel. 00016 */ 00017 00018 #ifndef _rk_util_h 00019 #define _rk_util_h 00020 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 /* 00026 * A structure used to hold the results of a rk_resource_set_get_usage call. 00027 * 00028 * proc_count - The number of processes in the resource set at the time of 00029 * sampling. 00030 * cpu_usage - The total CPU usage, in microseconds, for all of the processes 00031 * in the set. 00032 */ 00033 typedef struct rk_resource_set_usage { 00034 unsigned int proc_count; 00035 unsigned long long cpu_usage; 00036 } *rk_resource_set_usage_t; 00037 00038 /** 00039 * Search for a resource set by name and return the first one encountered. 00040 * 00041 * @param name The resource set name to search for. 00042 * @return A valid resource set pointer if the name was found, otherwise, 00043 * NULL_RESOURCE_SET. 00044 */ 00045 rk_resource_set_t rk_resource_set_get_by_name(const char *name); 00046 00047 /** 00048 * Compute the total resource usage for all the processes in a resource set. 00049 * Currently, this is implemented by stepping through all of the processes 00050 * attached to the resource set and pulling the usage information from 00051 * '/proc/@<pid@>/stat'. Unfortunately, the standard kernel does not provide 00052 * high-resolution data in the 'stat' file, so the file in the 'patch' 00053 * directory before this function can be used. 00054 * 00055 * @sa rk_util/patch/tslinux-3.1-procstat.patch 00056 * 00057 * @param rs The resource set to compute the resource usage for. 00058 * @param rsu An allocated rk_resource_set_stat_t object where the results 00059 * should be placed. 00060 * @return Zero on success, otherwise, an errno value. 00061 */ 00062 int rk_resource_set_get_usage(rk_resource_set_t rs, 00063 rk_resource_set_usage_t rsu); 00064 00065 #ifdef __cplusplus 00066 } 00067 #endif 00068 00069 #endif