Changeset 80bfb601 in mainline for uspace


Ignore:
Timestamp:
2010-04-18T09:57:19Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d869398
Parents:
fce3536
Message:

improve sysinfo and stats documentation (no change in functionality)

Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/stats.c

    rfce3536 r80bfb601  
    4343#define SYSINFO_STATS_MAX_PATH  64
    4444
     45/** Get CPUs statistics
     46 *
     47 * @param count Number of records returned.
     48 *
     49 * @return Array of stats_cpu_t structures.
     50 *         If non-NULL then it should be eventually freed
     51 *         by free().
     52 *
     53 */
    4554stats_cpu_t *get_stats_cpus(size_t *count)
    4655{
     
    5564}
    5665
     66/** Get physical memory statistics
     67 *
     68 *
     69 * @return Pointer to the stats_physmem_t structure.
     70 *         If non-NULL then it should be eventually freed
     71 *         by free().
     72 *
     73 */
    5774stats_physmem_t *get_stats_physmem(void)
    5875{
     
    6683}
    6784
     85/** Get task IDs
     86 *
     87 * @param count Number of IDs returned.
     88 *
     89 * @return Array of IDs (task_id_t).
     90 *         If non-NULL then it should be eventually freed
     91 *         by free().
     92 *
     93 */
    6894task_id_t *get_stats_tasks(size_t *count)
    6995{
     
    78104}
    79105
     106/** Get single task statistics
     107 *
     108 * @param task_id Task ID we are interested in.
     109 *
     110 * @return Pointer to the stats_task_t structure.
     111 *         If non-NULL then it should be eventually freed
     112 *         by free().
     113 *
     114 */
    80115stats_task_t *get_stats_task(task_id_t task_id)
    81116{
     
    92127}
    93128
     129/** Get system load
     130 *
     131 * @param count Number of load records returned.
     132 *
     133 * @return Array of load records (load_t).
     134 *         If non-NULL then it should be eventually freed
     135 *         by free().
     136 *
     137 */
    94138load_t *get_stats_load(size_t *count)
    95139{
     
    104148}
    105149
     150/** Get system uptime
     151 *
     152 * @return System uptime (in seconds).
     153 *
     154 */
    106155sysarg_t get_stats_uptime(void)
    107156{
     
    113162}
    114163
     164/** Print load fixed-point value
     165 *
     166 * Print the load record fixed-point value in decimal
     167 * representation on stdout.
     168 *
     169 * @param upper      Load record.
     170 * @param dec_length Number of decimal digits to print.
     171 *
     172 */
    115173void print_load_fragment(load_t upper, unsigned int dec_length)
    116174{
  • uspace/lib/c/generic/sysinfo.c

    rfce3536 r80bfb601  
    4040#include <bool.h>
    4141
     42/** Get sysinfo item type
     43 *
     44 * @param path Sysinfo path.
     45 *
     46 * @return Sysinfo item type.
     47 *
     48 */
    4249sysinfo_item_tag_t sysinfo_get_tag(const char *path)
    4350{
     
    4653}
    4754
     55/** Get sysinfo numerical value
     56 *
     57 * @param path  Sysinfo path.
     58 * @param value Pointer to store the numerical value to.
     59 *
     60 * @return EOK if the value was successfully read and
     61 *         is of SYSINFO_VAL_VAL type.
     62 *
     63 */
    4864int sysinfo_get_value(const char *path, sysarg_t *value)
    4965{
     
    5268}
    5369
     70/** Get sysinfo binary data size
     71 *
     72 * @param path  Sysinfo path.
     73 * @param value Pointer to store the binary data size.
     74 *
     75 * @return EOK if the value was successfully read and
     76 *         is of SYSINFO_VAL_DATA type.
     77 *
     78 */
    5479static int sysinfo_get_data_size(const char *path, size_t *size)
    5580{
     
    5883}
    5984
     85/** Get sysinfo binary data
     86 *
     87 * @param path  Sysinfo path.
     88 * @param value Pointer to store the binary data size.
     89 *
     90 * @return Binary data read from sysinfo or NULL if the
     91 *         sysinfo item value type is not binary data.
     92 *         The returned non-NULL pointer should be
     93 *         freed by free().
     94 *
     95 */
    6096void *sysinfo_get_data(const char *path, size_t *size)
    6197{
     98        /* The binary data size might change during time.
     99           Unfortunatelly we cannot allocate the buffer
     100           and transfer the data as a single atomic operation.
     101       
     102           Let's hope that the number of iterations is bounded
     103           in common cases. */
     104       
    62105        while (true) {
     106                /* Get the binary data size */
    63107                int ret = sysinfo_get_data_size(path, size);
    64                 if (ret != EOK)
     108                if (ret != EOK) {
     109                        /* Not binary data item */
    65110                        return NULL;
     111                }
    66112               
    67113                void *data = malloc(*size);
     
    69115                        return NULL;
    70116               
     117                /* Get the data */
    71118                ret = __SYSCALL4(SYS_SYSINFO_GET_DATA, (sysarg_t) path,
    72119                    (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size);
     
    74121                        return data;
    75122               
     123                /* Dispose the buffer */
    76124                free(data);
    77125               
    78                 if (ret != ENOMEM)
     126                if (ret != ENOMEM) {
     127                        /* The failure to get the data was not caused
     128                           by wrong buffer size */
    79129                        return NULL;
     130                }
    80131        }
    81132}
  • uspace/lib/c/include/sysinfo.h

    rfce3536 r80bfb601  
    3838#include <libc.h>
    3939
     40/** Sysinfo value types
     41 *
     42 */
    4043typedef enum {
    4144        SYSINFO_VAL_UNDEFINED = 0,
Note: See TracChangeset for help on using the changeset viewer.