Changeset e1b6742 in mainline for uspace/lib/c/generic/stats.c
- Timestamp:
- 2010-04-18T12:17:11Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e535eeb
- Parents:
- bbda5ab
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/stats.c
rbbda5ab re1b6742 43 43 #define SYSINFO_STATS_MAX_PATH 64 44 44 45 /** Thread states 46 * 47 */ 48 static const char *thread_states[] = { 49 "Invalid", 50 "Running", 51 "Sleeping", 52 "Ready", 53 "Entering", 54 "Exiting", 55 "Lingering" 56 }; 57 45 58 /** Get CPUs statistics 46 59 * … … 125 138 126 139 return stats_task; 140 } 141 142 /** Get thread IDs 143 * 144 * @param count Number of IDs returned. 145 * 146 * @return Array of IDs (thread_id_t). 147 * If non-NULL then it should be eventually freed 148 * by free(). 149 * 150 */ 151 thread_id_t *stats_get_threads(size_t *count) 152 { 153 size_t size = 0; 154 thread_id_t *ids = 155 (thread_id_t *) sysinfo_get_data("system.threads", &size); 156 157 assert((size % sizeof(thread_id_t)) == 0); 158 159 *count = size / sizeof(thread_id_t); 160 return ids; 161 } 162 163 /** Get single thread statistics 164 * 165 * @param thread_id Thread ID we are interested in. 166 * 167 * @return Pointer to the stats_thread_t structure. 168 * If non-NULL then it should be eventually freed 169 * by free(). 170 * 171 */ 172 stats_thread_t *stats_get_thread(thread_id_t thread_id) 173 { 174 char name[SYSINFO_STATS_MAX_PATH]; 175 snprintf(name, SYSINFO_STATS_MAX_PATH, "system.threads.%" PRIu64, thread_id); 176 177 size_t size = 0; 178 stats_thread_t *stats_thread = 179 (stats_thread_t *) sysinfo_get_data(name, &size); 180 181 assert((size == sizeof(stats_thread_t)) || (size == 0)); 182 183 return stats_thread; 127 184 } 128 185 … … 188 245 } 189 246 247 const char *thread_get_state(state_t state) 248 { 249 if (state <= Lingering) 250 return thread_states[state]; 251 252 return thread_states[Invalid]; 253 } 254 190 255 /** @} 191 256 */
Note:
See TracChangeset
for help on using the changeset viewer.