|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2004 David Decotigny 002 003 This program is free software; you can redistribute it and/or 004 modify it under the terms of the GNU General Public License 005 as published by the Free Software Foundation; either version 2 006 of the License, or (at your option) any later version. 007 008 This program is distributed in the hope that it will be useful, 009 but WITHOUT ANY WARRANTY; without even the implied warranty of 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 011 GNU General Public License for more details. 012 013 You should have received a copy of the GNU General Public License 014 along with this program; if not, write to the Free Software 015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 016 USA. 017 */ 018 #ifndef _SOS_CPULOAD_H_ 019 #define _SOS_CPULOAD_H_ 020 021 #include <sos/errno.h> 022 #include <sos/types.h> 023 #include <sos/time.h> 024 025 026 /** 027 * @file calcload.h 028 * 029 * Management of the CPU load in the system. For three intervals 030 * (1min, 5min, 15min), we maintain the user/kernel loads (ie number 031 * of threads in user/kernel mode ready or running) and the 032 * user/kernel CPU occupation ratio. 033 */ 034 035 036 /** 037 * Reinitialize the calcload subsystem. Must be called after the time 038 * subsystem has been initialized 039 */ 040 sos_ret_t sos_load_subsystem_setup(void); 041 042 043 /** 044 * Get the current USER load for each of the intervals. Definition: 045 * the USER load is the mean number of threads in USER mode which are 046 * ready or running over the period. 047 * 048 * @return the current USER load * SOS_LOAD_DISPLAY_MULTIPLICATION_FACTOR 049 */ 050 void sos_load_get_uload(sos_ui32_t * load_1mn, 051 sos_ui32_t * load_5mn, 052 sos_ui32_t * load_15mn); 053 054 055 /** 056 * Get the current KERNEL load for each of the intervals. Definition: 057 * the KERNEL load is the mean number of threads in KERNEL mode which are 058 * ready or running over the period. 059 * 060 * @note The load of the IDLE thread is removed from this computation ! 061 * 062 * @return the current KERNEL load * SOS_LOAD_DISPLAY_MULTIPLICATION_FACTOR 063 */ 064 void sos_load_get_sload(sos_ui32_t * load_1mn, 065 sos_ui32_t * load_5mn, 066 sos_ui32_t * load_15mn); 067 068 069 /** 070 * Get the current User CPU occupation ratio 071 * 072 * @return the current User/Kernel CPU occupation ratio 073 * * SOS_LOAD_DISPLAY_MULTIPLICATION_FACTOR 074 */ 075 void sos_load_get_uratio(sos_ui32_t * load_1mn, 076 sos_ui32_t * load_5mn, 077 sos_ui32_t * load_15mn); 078 079 080 /** 081 * Get the current Kernel CPU occupation ratio 082 * 083 * @note The load of the IDLE thread is NOT removed from this computation ! 084 * 085 * @return the current User/Kernel CPU occupation ratio 086 * * SOS_LOAD_DISPLAY_MULTIPLICATION_FACTOR 087 */ 088 void sos_load_get_sratio(sos_ui32_t * load_1mn, 089 sos_ui32_t * load_5mn, 090 sos_ui32_t * load_15mn); 091 092 093 /** 094 * Generate the "dest" string with the string corresponding to 095 * load_value / SOS_LOAD_DISPLAY_MULTIPLICATION_FACTOR with decimal 096 * digits 097 */ 098 void sos_load_to_string(char dest[11], sos_ui32_t load_value); 099 100 101 /* ****************************************************** 102 * Restricted function. Used only by sched.c/time.c 103 */ 104 105 106 /** 107 * Restricted callback called from the scheduler subsystem to update 108 * the load parameters. 109 * 110 * @note This is RESTRICTED function to be used by time.c 111 */ 112 sos_ret_t sos_load_do_timer_tick(sos_bool_t cur_is_user, 113 sos_ui32_t nb_user_ready, 114 sos_ui32_t nb_kernel_ready); 115 116 117 #endif /* _SOS_CPULOAD_H_ */
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |