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