Changeset 8eec3c8 in mainline for uspace


Ignore:
Timestamp:
2010-06-10T14:24:50Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c0f13d2
Parents:
1113c9e
Message:

merge basic exception accounting (this is the last piece missing from the original "measure" branch by Stanislav Kozina)

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/screen.c

    r1113c9e r8eec3c8  
    325325}
    326326
     327static inline void print_exc_head(void)
     328{
     329        screen_style_inverted();
     330        printf("  ID                     Desc    Count   Cycles");
     331        screen_newline();
     332        screen_style_normal();
     333}
     334
     335static inline void print_exc(data_t *data)
     336{
     337        ipcarg_t cols;
     338        ipcarg_t rows;
     339        screen_get_size(&cols, &rows);
     340       
     341        ipcarg_t col;
     342        ipcarg_t row;
     343        screen_get_pos(&col, &row);
     344       
     345        size_t i;
     346        for (i = 0; (i < data->exceptions_count) && (row < rows); i++, row++) {
     347                uint64_t cycles;
     348                char suffix;
     349               
     350                order_suffix(data->exceptions[i].cycles, &cycles, &suffix);
     351                printf("%8u %20s %8" PRIu64 " %8" PRIu64 "%c",
     352                     data->exceptions[i].id, data->exceptions[i].desc,
     353                     data->exceptions[i].count, cycles, suffix);
     354               
     355                screen_newline();
     356        }
     357       
     358        while (row < rows) {
     359                screen_newline();
     360                row++;
     361        }
     362}
     363
    327364void print_data(data_t *data)
    328365{
     
    338375        screen_newline();
    339376       
    340         if (operation_type == OP_IPC) {
     377        switch (operation_type) {
     378        case OP_TASKS:
     379                print_task_head();
     380                print_tasks(data);
     381                break;
     382        case OP_IPC:
    341383                print_ipc_head();
    342384                print_ipc(data);
    343         } else {
    344                 print_task_head();
    345                 print_tasks(data);
     385                break;
     386        case OP_EXC:
     387                print_exc_head();
     388                print_exc(data);
     389                break;
    346390        }
    347391       
  • uspace/app/top/top.c

    r1113c9e r8eec3c8  
    115115                return "Cannot get threads";
    116116       
     117        target->exceptions = stats_get_exceptions(&(target->exceptions_count));
     118        if (target->exceptions == NULL)
     119                return "Cannot get exceptions";
     120       
    117121        /* Get physical memory */
    118122        target->physmem = stats_get_physmem();
     
    231235        if (target->threads != NULL)
    232236                free(target->threads);
     237       
     238        if (target->exceptions != NULL)
     239                free(target->exceptions);
    233240       
    234241        if (target->physmem != NULL)
     
    285292                                operation_type = OP_TASKS;
    286293                                break;
     294                        case 'e':
     295                                print_warning("Showing exception statistics");
     296                                operation_type = OP_EXC;
     297                                break;
    287298                        default:
    288299                                print_warning("Unknown command: %c", c);
  • uspace/app/top/top.h

    r1113c9e r8eec3c8  
    4646#define OP_TASKS  1
    4747#define OP_IPC    2
     48#define OP_EXC    3
    4849
    4950extern int operation_type;
     
    8990        stats_thread_t *threads;
    9091       
     92        size_t exceptions_count;
     93        stats_exc_t *exceptions;
     94       
    9195        stats_physmem_t *physmem;
    9296} data_t;
  • uspace/lib/c/generic/stats.c

    r1113c9e r8eec3c8  
    184184}
    185185
     186/** Get exception statistics.
     187 *
     188 * @param count Number of records returned.
     189 *
     190 * @return Array of stats_exc_t structures.
     191 *         If non-NULL then it should be eventually freed
     192 *         by free().
     193 *
     194 */
     195stats_exc_t *stats_get_exceptions(size_t *count)
     196{
     197        size_t size = 0;
     198        stats_exc_t *stats_exceptions =
     199            (stats_exc_t *) sysinfo_get_data("system.exceptions", &size);
     200       
     201        assert((size % sizeof(stats_exc_t)) == 0);
     202       
     203        *count = size / sizeof(stats_exc_t);
     204        return stats_exceptions;
     205}
     206
     207/** Get single exception statistics
     208 *
     209 * @param excn Exception number we are interested in.
     210 *
     211 * @return Pointer to the stats_exc_t structure.
     212 *         If non-NULL then it should be eventually freed
     213 *         by free().
     214 *
     215 */
     216stats_exc_t *stats_get_exception(unsigned int excn)
     217{
     218        char name[SYSINFO_STATS_MAX_PATH];
     219        snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptionss.%u", excn);
     220       
     221        size_t size = 0;
     222        stats_exc_t *stats_exception =
     223            (stats_exc_t *) sysinfo_get_data(name, &size);
     224       
     225        assert((size == sizeof(stats_exc_t)) || (size == 0));
     226       
     227        return stats_exception;
     228}
     229
    186230/** Get system load
    187231 *
  • uspace/lib/c/include/stats.h

    r1113c9e r8eec3c8  
    5353extern stats_thread_t *stats_get_thread(thread_id_t);
    5454
     55extern stats_exc_t *stats_get_exceptions(size_t *);
     56extern stats_exc_t *stats_get_exception(unsigned int);
     57
    5558extern void stats_print_load_fragment(load_t, unsigned int);
    5659extern const char *thread_get_state(state_t);
Note: See TracChangeset for help on using the changeset viewer.