Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 62550dce in mainline


Ignore:
Timestamp:
2010-04-01T21:31:25Z (12 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master
Children:
dd6c71c
Parents:
79edc36
Message:

ps -c echoes info about CPU's
cpu count is accessible through sysinfo("cpu.count")

Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r79edc36 r62550dce  
    231231        generic/src/sysinfo/sysinfo.c \
    232232        generic/src/ps/ps.c \
     233        generic/src/ps/cpu.c \
    233234        generic/src/ps/load.c \
    234235        generic/src/ps/uptime.c
  • kernel/generic/include/ps/load.h

    r79edc36 r62550dce  
    3333 */
    3434
    35 #ifndef KERN_LOAD_H_
    36 #define KERN_LOAD_H_
     35#ifndef KERN_PS_LOAD_H_
     36#define KERN_PS_LOAD_H_
    3737
    3838extern void get_avenrun(unsigned long *loads, int shift);
  • kernel/generic/include/ps/ps.h

    r79edc36 r62550dce  
    3333 */
    3434
    35 #ifndef KERN_PS_H_
    36 #define KERN_PS_H_
     35#ifndef KERN_PS_PS_H_
     36#define KERN_PS_PS_H_
    3737
    3838#include <ps/taskinfo.h>
     39#include <ps/cpuinfo.h>
    3940
    4041extern size_t sys_ps_get_tasks(task_id_t *uspace_ids, size_t size);
    4142extern int sys_ps_get_task_info(task_id_t *uspace_id, task_info_t *uspace_info);
    4243extern int sys_ps_get_threads(task_id_t *uspace_id, thread_info_t *uspace_infos, size_t size);
     44extern int sys_ps_get_cpu_info(uspace_cpu_info_t *uspace_cpu);
    4345
    4446#endif
  • kernel/generic/include/ps/uptime.h

    r79edc36 r62550dce  
    3333 */
    3434
    35 #ifndef KERN_UPTIME_H_
    36 #define KERN_UPTIME_H_
     35#ifndef KERN_PS_UPTIME_H_
     36#define KERN_PS_UPTIME_H_
    3737
    3838extern int sys_ps_get_uptime(uint64_t *user_load);
  • kernel/generic/include/syscall/syscall.h

    r79edc36 r62550dce  
    8888        SYS_DEBUG_DISABLE_CONSOLE,
    8989
     90        SYS_PS_GET_CPU_INFO,
    9091        SYS_PS_GET_TASKS,
    9192        SYS_PS_GET_TASK_INFO,
  • kernel/generic/src/cpu/cpu.c

    r79edc36 r62550dce  
    4848#include <adt/list.h>
    4949#include <print.h>
     50#include <sysinfo/sysinfo.h>
    5051
    5152cpu_t *cpus;
     
    9697        cpu_identify();
    9798        cpu_arch_init();
     99
     100        sysinfo_set_item_val("cpu.count", NULL, config.cpu_count);
    98101}
    99102
  • kernel/generic/src/proc/scheduler.c

    r79edc36 r62550dce  
    202202                 */
    203203
     204                 spinlock_lock(&CPU->lock);
    204205                 CPU->idle = true;
     206                 spinlock_unlock(&CPU->lock);
    205207                 cpu_sleep();
    206208                 goto loop;
  • kernel/generic/src/syscall/syscall.c

    r79edc36 r62550dce  
    170170
    171171        /* Ps calls */
     172        (syshandler_t) sys_ps_get_cpu_info,
    172173        (syshandler_t) sys_ps_get_tasks,
    173174        (syshandler_t) sys_ps_get_task_info,
  • uspace/app/ps/ps.c

    r79edc36 r62550dce  
    4343#include <malloc.h>
    4444#include <load.h>
     45#include <sysinfo.h>
    4546
    4647#include "func.h"
     
    141142}
    142143
     144static void echo_cpus(void)
     145{
     146        size_t cpu_count = sysinfo_value("cpu.count");
     147        printf("Found %u cpu's:\n", cpu_count);
     148        uspace_cpu_info_t *cpus = malloc(cpu_count * sizeof(uspace_cpu_info_t));
     149        get_cpu_info(cpus);
     150        size_t i;
     151        for (i = 0; i < cpu_count; ++i) {
     152                printf("%2u (%4u Mhz): Busy ticks: %8llu, Idle ticks: %8llu\n", cpus[i].id,
     153                                (size_t)cpus[i].frequency_mhz, cpus[i].busy_ticks, cpus[i].idle_ticks);
     154        }
     155}
     156
    143157static void usage()
    144158{
    145         printf("Usage: ps [-t pid -l]\n");
     159        printf("Usage: ps [-t pid|-l|-c]\n");
    146160}
    147161
     
    169183                        }
    170184                        echo_load();
     185                } else if (str_cmp(*argv, "-c") == 0) {
     186                        --argc; ++argv;
     187                        if (argc != 0) {
     188                                printf("Bad argument count!\n");
     189                                usage();
     190                                exit(1);
     191                        }
     192                        echo_cpus();
    171193                } else {
    172194                        printf("Unknown argument %s!\n", *argv);
  • uspace/lib/c/Makefile

    r79edc36 r62550dce  
    9292        generic/stacktrace.c \
    9393        generic/ps.c \
     94        generic/cpu.c \
    9495        generic/load.c \
    9596        generic/uptime.c
  • uspace/lib/c/include/ps.h

    r79edc36 r62550dce  
    3838#include <task.h>
    3939#include <kernel/ps/taskinfo.h>
     40#include <kernel/ps/cpuinfo.h>
    4041
     42extern int get_cpu_info(uspace_cpu_info_t *cpus);
    4143extern size_t get_task_ids(task_id_t *ids, size_t size);
    4244extern int get_task_info(task_id_t id, task_info_t *info);
Note: See TracChangeset for help on using the changeset viewer.