Changeset 638927a in mainline
- Timestamp:
- 2010-04-09T11:18:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e43cdac
- Parents:
- faf38b2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ps/ps.c
rfaf38b2 r638927a 191 191 ipl_t ipl; 192 192 ipl = interrupts_disable(); 193 194 printf("LIst threads, size: %llu\n", size);195 193 spinlock_lock(&threads_lock); 196 194 -
uspace/app/ps/ps.c
rfaf38b2 r638927a 97 97 static void list_threads(task_id_t taskid) 98 98 { 99 int thread_count = THREAD_COUNT;99 size_t thread_count = THREAD_COUNT; 100 100 thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t)); 101 int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);101 size_t result = get_task_threads(threads, sizeof(thread_info_t) * thread_count); 102 102 103 103 while (result > thread_count) { … … 112 112 } 113 113 114 int i;114 size_t i; 115 115 printf(" ID State CPU Prio [k]uCycles [k]kcycles Cycle fault\n"); 116 116 for (i = 0; i < result; ++i) { -
uspace/app/top/ps.c
rfaf38b2 r638927a 58 58 }; 59 59 60 unsigned int get_tasks(task_info_t **out_infos)60 size_t get_tasks(task_info_t **out_infos) 61 61 { 62 int task_count = TASK_COUNT;62 size_t task_count = TASK_COUNT; 63 63 task_id_t *tasks = malloc(task_count * sizeof(task_id_t)); 64 int result = get_task_ids(tasks, sizeof(task_id_t) * task_count);64 size_t result = get_task_ids(tasks, sizeof(task_id_t) * task_count); 65 65 66 66 while (result > task_count) { … … 70 70 } 71 71 72 int i;72 size_t i; 73 73 task_info_t *taskinfos = malloc(result * sizeof(task_info_t)); 74 74 for (i = 0; i < result; ++i) { … … 82 82 } 83 83 84 thread_info_t *get_threads(task_id_t taskid)84 size_t get_threads(thread_info_t **thread_infos) 85 85 { 86 int thread_count = THREAD_COUNT;86 size_t thread_count = THREAD_COUNT; 87 87 thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t)); 88 int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);88 size_t result = get_task_threads(threads, sizeof(thread_info_t) * thread_count); 89 89 90 90 while (result > thread_count) { … … 94 94 } 95 95 96 return threads; 96 *thread_infos = threads; 97 return result; 97 98 } 98 99 -
uspace/app/top/ps.h
rfaf38b2 r638927a 39 39 40 40 extern const char *thread_states[]; 41 extern unsigned int get_tasks(task_info_t **out_infos);42 extern thread_info_t *get_threads(task_id_t taskid);41 extern size_t get_tasks(task_info_t **out_infos); 42 extern size_t get_threads(thread_info_t **thread_infos); 43 43 extern unsigned int get_cpu_infos(uspace_cpu_info_t **out_infos); 44 44 -
uspace/app/top/screen.c
rfaf38b2 r638927a 119 119 } 120 120 121 static inline void print_threadstat(data_t *data) 122 { 123 size_t sleeping = 0; 124 size_t running = 0; 125 size_t invalid = 0; 126 size_t other = 0; 127 size_t total = 0; 128 size_t i; 129 for (i = 0; i < data->thread_count; ++i) { 130 ++total; 131 switch (data->thread_infos[i].state) { 132 case Invalid: 133 case Lingering: 134 ++invalid; 135 break; 136 case Running: 137 case Ready: 138 ++running; 139 break; 140 case Sleeping: 141 ++sleeping; 142 break; 143 case Entering: 144 case Exiting: 145 ++other; 146 break; 147 } 148 } 149 printf("Threads: %5u total, %5u running, %5u sleeping, %5u invalid, %5u other", 150 total, running, sleeping, invalid, other); 151 } 152 121 153 static inline void print_cpuinfo(data_t *data) 122 154 { … … 197 229 puts("\n"); 198 230 ++up_rows; 231 print_threadstat(data); 232 puts("\n"); 233 ++up_rows; 199 234 print_cpuinfo(data); 200 235 print_meminfo(data); -
uspace/app/top/top.c
rfaf38b2 r638927a 44 44 #include <load.h> 45 45 #include <ps.h> 46 #include <arch/barrier.h> 46 47 #include "screen.h" 47 48 #include "input.h" … … 82 83 /* Read task ids */ 83 84 target->task_count = get_tasks(&target->taskinfos); 85 86 /* Read all threads */ 87 target->thread_count = get_threads(&target->thread_infos); 84 88 85 89 /* Read cpu infos */ … … 144 148 } 145 149 150 /* Wait until coprocessor finishes its work */ 151 write_barrier(); 152 146 153 /* And free temporary structures */ 147 154 free(ucycles_diff); … … 152 159 { 153 160 free(target->taskinfos); 161 free(target->thread_infos); 154 162 free(target->cpus); 155 163 free(target->cpu_perc); -
uspace/app/top/top.h
rfaf38b2 r638927a 61 61 unsigned long load[3]; 62 62 63 unsigned int task_count;63 size_t task_count; 64 64 task_info_t *taskinfos; 65 65 task_perc_t *task_perc; 66 67 size_t thread_count; 68 thread_info_t *thread_infos; 66 69 67 70 unsigned int cpu_count; -
uspace/lib/c/generic/ps.c
rfaf38b2 r638927a 71 71 * @param size Size of the infos array. 72 72 * 73 * @return 0 on success. 73 * @return Count of written thread_infos. If higher than size, there 74 * was not enough space. 74 75 * 75 76 */ 76 int get_task_threads(thread_info_t *infos, size_t size)77 size_t get_task_threads(thread_info_t *infos, size_t size) 77 78 { 78 79 return __SYSCALL2(SYS_PS_GET_THREADS, (sysarg_t) infos, (sysarg_t) size); -
uspace/lib/c/include/ps.h
rfaf38b2 r638927a 45 45 extern size_t get_task_ids(task_id_t *ids, size_t size); 46 46 extern int get_task_info(task_id_t id, task_info_t *info); 47 extern int get_task_threads(thread_info_t *infos, size_t size);47 extern size_t get_task_threads(thread_info_t *infos, size_t size); 48 48 49 49 #endif
Note:
See TracChangeset
for help on using the changeset viewer.