Changeset df3c6f02 in mainline for uspace/app
- Timestamp:
- 2011-05-31T22:58:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d362410
- Parents:
- 82582e4 (diff), 4ce90544 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 5 added
- 8 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/Makefile
r82582e4 rdf3c6f02 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = init 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/app/klog/klog.c
r82582e4 rdf3c6f02 44 44 #include <io/klog.h> 45 45 #include <sysinfo.h> 46 #include <malloc.h> 47 #include <fibril_synch.h> 48 #include <adt/list.h> 49 #include <adt/prodcons.h> 46 50 47 51 #define NAME "klog" 48 52 #define LOG_FNAME "/log/klog" 53 54 /* Producer/consumer buffers */ 55 typedef struct { 56 link_t link; 57 size_t length; 58 wchar_t *data; 59 } item_t; 60 61 static prodcons_t pc; 49 62 50 63 /* Pointer to klog area */ … … 52 65 static size_t klog_length; 53 66 54 static FILE *log; 55 56 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) 57 { 67 /* Notification mutex */ 68 static FIBRIL_MUTEX_INITIALIZE(mtx); 69 70 /** Klog producer 71 * 72 * Copies the contents of a character buffer to local 73 * producer/consumer queue. 74 * 75 * @param length Number of characters to copy. 76 * @param data Pointer to the kernel klog buffer. 77 * 78 */ 79 static void producer(size_t length, wchar_t *data) 80 { 81 item_t *item = (item_t *) malloc(sizeof(item_t)); 82 if (item == NULL) 83 return; 84 85 size_t sz = sizeof(wchar_t) * length; 86 wchar_t *buf = (wchar_t *) malloc(sz); 87 if (data == NULL) { 88 free(item); 89 return; 90 } 91 92 memcpy(buf, data, sz); 93 94 link_initialize(&item->link); 95 item->length = length; 96 item->data = buf; 97 prodcons_produce(&pc, &item->link); 98 } 99 100 /** Klog consumer 101 * 102 * Waits in an infinite loop for the character data created by 103 * the producer and outputs them to stdout and optionally into 104 * a file. 105 * 106 * @param data Unused. 107 * 108 * @return Always EOK (unreachable). 109 * 110 */ 111 static int consumer(void *data) 112 { 113 FILE *log = fopen(LOG_FNAME, "a"); 114 if (log == NULL) 115 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME, 116 str_error(errno)); 117 118 while (true) { 119 link_t *link = prodcons_consume(&pc); 120 item_t *item = list_get_instance(link, item_t, link); 121 122 for (size_t i = 0; i < item->length; i++) 123 putchar(item->data[i]); 124 125 if (log != NULL) { 126 for (size_t i = 0; i < item->length; i++) 127 fputc(item->data[i], log); 128 129 fflush(log); 130 fsync(fileno(log)); 131 } 132 133 free(item->data); 134 free(item); 135 } 136 137 fclose(log); 138 return EOK; 139 } 140 141 /** Kernel notification handler 142 * 143 * Receives kernel klog notifications. 144 * 145 * @param callid IPC call ID. 146 * @param call IPC call structure. 147 * 148 */ 149 static void notification_received(ipc_callid_t callid, ipc_call_t *call) 150 { 151 /* 152 * Make sure we process only a single notification 153 * at any time to limit the chance of the consumer 154 * starving. 155 * 156 * Note: Usually the automatic masking of the klog 157 * notifications on the kernel side does the trick 158 * of limiting the chance of accidentally copying 159 * the same data multiple times. However, due to 160 * the non-blocking architecture of klog notifications, 161 * this possibility cannot be generally avoided. 162 */ 163 164 fibril_mutex_lock(&mtx); 165 58 166 size_t klog_start = (size_t) IPC_GET_ARG1(*call); 59 167 size_t klog_len = (size_t) IPC_GET_ARG2(*call); 60 168 size_t klog_stored = (size_t) IPC_GET_ARG3(*call); 61 size_t i; 62 63 for (i = klog_len - klog_stored; i < klog_len; i++) { 64 wchar_t ch = klog[(klog_start + i) % klog_length]; 65 66 putchar(ch); 67 68 if (log != NULL) 69 fputc(ch, log); 70 } 71 72 if (log != NULL) { 73 fflush(log); 74 fsync(fileno(log)); 75 } 169 170 size_t offset = (klog_start + klog_len - klog_stored) % klog_length; 171 172 /* Copy data from the ring buffer */ 173 if (offset + klog_stored >= klog_length) { 174 size_t split = klog_length - offset; 175 176 producer(split, klog + offset); 177 producer(klog_stored - split, klog); 178 } else 179 producer(klog_stored, klog + offset); 180 181 event_unmask(EVENT_KLOG); 182 fibril_mutex_unlock(&mtx); 76 183 } 77 184 … … 111 218 } 112 219 220 prodcons_initialize(&pc); 221 async_set_interrupt_received(notification_received); 113 222 rc = event_subscribe(EVENT_KLOG, 0); 114 223 if (rc != EOK) { … … 118 227 } 119 228 120 log = fopen(LOG_FNAME, "a"); 121 if (log == NULL) 122 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME, 123 str_error(errno)); 124 125 async_set_interrupt_received(interrupt_received); 229 fid_t fid = fibril_create(consumer, NULL); 230 if (!fid) { 231 fprintf(stderr, "%s: Unable to create consumer fibril\n", 232 NAME); 233 return ENOMEM; 234 } 235 236 fibril_add_ready(fid); 237 event_unmask(EVENT_KLOG); 126 238 klog_update(); 239 240 task_retval(0); 127 241 async_manager(); 128 242 -
uspace/app/stats/stats.c
r82582e4 rdf3c6f02 69 69 size_t i; 70 70 for (i = 0; i < count; i++) { 71 uint64_t resmem, virtmem, ucycles, kcycles; 72 char resmem_suffix, virtmem_suffix, usuffix, ksuffix; 73 74 order_suffix(stats_tasks[i].resmem, &resmem, &resmem_suffix); 75 order_suffix(stats_tasks[i].virtmem, &virtmem, &virtmem_suffix); 71 uint64_t resmem; 72 uint64_t virtmem; 73 uint64_t ucycles; 74 uint64_t kcycles; 75 const char *resmem_suffix; 76 const char *virtmem_suffix; 77 char usuffix; 78 char ksuffix; 79 80 bin_order_suffix(stats_tasks[i].resmem, &resmem, &resmem_suffix, true); 81 bin_order_suffix(stats_tasks[i].virtmem, &virtmem, &virtmem_suffix, true); 76 82 order_suffix(stats_tasks[i].ucycles, &ucycles, &usuffix); 77 83 order_suffix(stats_tasks[i].kcycles, &kcycles, &ksuffix); 78 84 79 printf("%-8" PRIu64 " %7zu % 9" PRIu64 "%c %8" PRIu64 "%c"85 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s %6" PRIu64 "%s" 80 86 " %8" PRIu64 "%c %8" PRIu64 "%c %s\n", 81 87 stats_tasks[i].task_id, stats_tasks[i].threads, … … 265 271 /* Threads */ 266 272 if ((off = arg_parse_short_long(argv[i], "-t", "--task=")) != -1) { 267 / * TODO: Support for 64b range */273 // TODO: Support for 64b range 268 274 int tmp; 269 275 int ret = arg_parse_int(argc, argv, &i, &tmp, off); -
uspace/app/tester/Makefile
r82582e4 rdf3c6f02 48 48 ipc/ping_pong.c \ 49 49 loop/loop1.c \ 50 mm/common.c \ 50 51 mm/malloc1.c \ 52 mm/malloc2.c \ 53 mm/malloc3.c \ 51 54 devs/devman1.c \ 52 55 hw/misc/virtchar1.c \ -
uspace/app/tester/mm/malloc1.c
r82582e4 rdf3c6f02 30 30 31 31 #include <stdio.h> 32 #include <unistd.h>33 32 #include <stdlib.h> 34 #include <malloc.h>33 #include "common.h" 35 34 #include "../tester.h" 36 35 … … 45 44 */ 46 45 47 /**48 * sizeof_array49 * @array array to determine the size of50 *51 * Returns the size of @array in array elements.52 */53 #define sizeof_array(array) \54 (sizeof(array) / sizeof((array)[0]))55 56 #define MAX_ALLOC (16 * 1024 * 1024)57 58 /*59 * Subphase control structures: subphase termination conditions,60 * probabilities of individual actions, subphase control structure.61 */62 63 typedef struct {64 unsigned int max_cycles;65 unsigned int no_memory;66 unsigned int no_allocated;67 } sp_term_cond_s;68 69 typedef struct {70 unsigned int alloc;71 unsigned int free;72 } sp_action_prob_s;73 74 typedef struct {75 const char *name;76 sp_term_cond_s cond;77 sp_action_prob_s prob;78 } subphase_s;79 80 81 /*82 * Phase control structures: The minimum and maximum block size that83 * can be allocated during the phase execution, phase control structure.84 */85 86 typedef struct {87 size_t min_block_size;88 size_t max_block_size;89 } ph_alloc_size_s;90 91 typedef struct {92 const char *name;93 ph_alloc_size_s alloc;94 subphase_s *subphases;95 } phase_s;96 97 98 46 /* 99 47 * Subphases are defined separately here. This is for two reasons: … … 101 49 * how many subphases a phase contains. 102 50 */ 103 static subphase_ ssubphases_32B[] = {51 static subphase_t subphases_32B[] = { 104 52 { 105 53 .name = "Allocation", … … 140 88 }; 141 89 142 static subphase_ ssubphases_128K[] = {90 static subphase_t subphases_128K[] = { 143 91 { 144 92 .name = "Allocation", … … 179 127 }; 180 128 181 static subphase_ ssubphases_default[] = {129 static subphase_t subphases_default[] = { 182 130 { 183 131 .name = "Allocation", … … 217 165 } 218 166 }; 219 220 167 221 168 /* 222 169 * Phase definitions. 223 170 */ 224 static phase_ sphases[] = {171 static phase_t phases[] = { 225 172 { 226 173 .name = "32 B memory blocks", … … 257 204 }; 258 205 259 260 /* 261 * Global error flag. The flag is set if an error 262 * is encountered (overlapping blocks, inconsistent 263 * block data, etc.) 264 */ 265 static bool error_flag = false; 266 267 /* 268 * Memory accounting: the amount of allocated memory and the 269 * number and list of allocated blocks. 270 */ 271 static size_t mem_allocated; 272 static size_t mem_blocks_count; 273 274 static LIST_INITIALIZE(mem_blocks); 275 276 typedef struct { 277 /* Address of the start of the block */ 278 void *addr; 279 280 /* Size of the memory block */ 281 size_t size; 282 283 /* link to other blocks */ 284 link_t link; 285 } mem_block_s; 286 287 typedef mem_block_s *mem_block_t; 288 289 290 /** init_mem 291 * 292 * Initializes the memory accounting structures. 293 * 294 */ 295 static void init_mem(void) 206 static void do_subphase(phase_t *phase, subphase_t *subphase) 296 207 { 297 mem_allocated = 0; 298 mem_blocks_count = 0; 299 } 300 301 302 static bool overlap_match(link_t *entry, void *addr, size_t size) 303 { 304 mem_block_t mblk = list_get_instance(entry, mem_block_s, link); 305 306 /* Entry block control structure <mbeg, mend) */ 307 uint8_t *mbeg = (uint8_t *) mblk; 308 uint8_t *mend = (uint8_t *) mblk + sizeof(mem_block_s); 309 310 /* Entry block memory <bbeg, bend) */ 311 uint8_t *bbeg = (uint8_t *) mblk->addr; 312 uint8_t *bend = (uint8_t *) mblk->addr + mblk->size; 313 314 /* Data block <dbeg, dend) */ 315 uint8_t *dbeg = (uint8_t *) addr; 316 uint8_t *dend = (uint8_t *) addr + size; 317 318 /* Check for overlaps */ 319 if (((mbeg >= dbeg) && (mbeg < dend)) || 320 ((mend > dbeg) && (mend <= dend)) || 321 ((bbeg >= dbeg) && (bbeg < dend)) || 322 ((bend > dbeg) && (bend <= dend))) 323 return true; 324 325 return false; 326 } 327 328 329 /** test_overlap 330 * 331 * Test whether a block starting at @addr overlaps with another, previously 332 * allocated memory block or its control structure. 333 * 334 * @param addr Initial address of the block 335 * @param size Size of the block 336 * 337 * @return false if the block does not overlap. 338 * 339 */ 340 static int test_overlap(void *addr, size_t size) 341 { 342 link_t *entry; 343 bool fnd = false; 344 345 for (entry = mem_blocks.next; entry != &mem_blocks; entry = entry->next) { 346 if (overlap_match(entry, addr, size)) { 347 fnd = true; 348 break; 349 } 350 } 351 352 return fnd; 353 } 354 355 356 /** checked_malloc 357 * 358 * Allocate @size bytes of memory and check whether the chunk comes 359 * from the non-mapped memory region and whether the chunk overlaps 360 * with other, previously allocated, chunks. 361 * 362 * @param size Amount of memory to allocate 363 * 364 * @return NULL if the allocation failed. Sets the global error_flag to 365 * true if the allocation succeeded but is illegal. 366 * 367 */ 368 static void *checked_malloc(size_t size) 369 { 370 void *data; 371 372 /* Allocate the chunk of memory */ 373 data = malloc(size); 374 if (data == NULL) 375 return NULL; 376 377 /* Check for overlaps with other chunks */ 378 if (test_overlap(data, size)) { 379 TPRINTF("\nError: Allocated block overlaps with another " 380 "previously allocated block.\n"); 381 error_flag = true; 382 } 383 384 return data; 385 } 386 387 388 /** alloc_block 389 * 390 * Allocate a block of memory of @size bytes and add record about it into 391 * the mem_blocks list. Return a pointer to the block holder structure or 392 * NULL if the allocation failed. 393 * 394 * If the allocation is illegal (e.g. the memory does not come from the 395 * right region or some of the allocated blocks overlap with others), 396 * set the global error_flag. 397 * 398 * @param size Size of the memory block 399 * 400 */ 401 static mem_block_t alloc_block(size_t size) 402 { 403 /* Check for allocation limit */ 404 if (mem_allocated >= MAX_ALLOC) 405 return NULL; 406 407 /* Allocate the block holder */ 408 mem_block_t block = (mem_block_t) checked_malloc(sizeof(mem_block_s)); 409 if (block == NULL) 410 return NULL; 411 412 link_initialize(&block->link); 413 414 /* Allocate the block memory */ 415 block->addr = checked_malloc(size); 416 if (block->addr == NULL) { 417 free(block); 418 return NULL; 419 } 420 421 block->size = size; 422 423 /* Register the allocated block */ 424 list_append(&block->link, &mem_blocks); 425 mem_allocated += size + sizeof(mem_block_s); 426 mem_blocks_count++; 427 428 return block; 429 } 430 431 432 /** free_block 433 * 434 * Free the block of memory and the block control structure allocated by 435 * alloc_block. Set the global error_flag if an error occurs. 436 * 437 * @param block Block control structure 438 * 439 */ 440 static void free_block(mem_block_t block) 441 { 442 /* Unregister the block */ 443 list_remove(&block->link); 444 mem_allocated -= block->size + sizeof(mem_block_s); 445 mem_blocks_count--; 446 447 /* Free the memory */ 448 free(block->addr); 449 free(block); 450 } 451 452 453 /** expected_value 454 * 455 * Compute the expected value of a byte located at @pos in memory 456 * block described by @blk. 457 * 458 * @param blk Memory block control structure 459 * @param pos Position in the memory block data area 460 * 461 */ 462 static inline uint8_t expected_value(mem_block_t blk, uint8_t *pos) 463 { 464 return ((unsigned long) blk ^ (unsigned long) pos) & 0xff; 465 } 466 467 468 /** fill_block 469 * 470 * Fill the memory block controlled by @blk with data. 471 * 472 * @param blk Memory block control structure 473 * 474 */ 475 static void fill_block(mem_block_t blk) 476 { 477 uint8_t *pos; 478 uint8_t *end; 479 480 for (pos = blk->addr, end = pos + blk->size; pos < end; pos++) 481 *pos = expected_value(blk, pos); 482 } 483 484 485 /** check_block 486 * 487 * Check whether the block @blk contains the data it was filled with. 488 * Set global error_flag if an error occurs. 489 * 490 * @param blk Memory block control structure 491 * 492 */ 493 static void check_block(mem_block_t blk) 494 { 495 uint8_t *pos; 496 uint8_t *end; 497 498 for (pos = blk->addr, end = pos + blk->size; pos < end; pos++) { 499 if (*pos != expected_value (blk, pos)) { 500 TPRINTF("\nError: Corrupted content of a data block.\n"); 501 error_flag = true; 502 return; 503 } 504 } 505 } 506 507 508 static link_t *list_get_nth(link_t *list, unsigned int i) 509 { 510 unsigned int cnt = 0; 511 link_t *entry; 512 513 for (entry = list->next; entry != list; entry = entry->next) { 514 if (cnt == i) 515 return entry; 516 517 cnt++; 518 } 519 520 return NULL; 521 } 522 523 524 /** get_random_block 525 * 526 * Select a random memory block from the list of allocated blocks. 527 * 528 * @return Block control structure or NULL if the list is empty. 529 * 530 */ 531 static mem_block_t get_random_block(void) 532 { 533 if (mem_blocks_count == 0) 534 return NULL; 535 536 unsigned int blkidx = rand() % mem_blocks_count; 537 link_t *entry = list_get_nth(&mem_blocks, blkidx); 538 539 if (entry == NULL) { 540 TPRINTF("\nError: Corrupted list of allocated memory blocks.\n"); 541 error_flag = true; 542 } 543 544 return list_get_instance(entry, mem_block_s, link); 545 } 546 547 548 #define RETURN_IF_ERROR \ 549 { \ 550 if (error_flag) \ 551 return; \ 552 } 553 554 555 static void do_subphase(phase_s *phase, subphase_s *subphase) 556 { 557 unsigned int cycles; 558 for (cycles = 0; /* always */; cycles++) { 559 560 if (subphase->cond.max_cycles && 561 cycles >= subphase->cond.max_cycles) { 208 for (unsigned int cycles = 0; /* always */; cycles++) { 209 210 if ((subphase->cond.max_cycles) && 211 (cycles >= subphase->cond.max_cycles)) { 562 212 /* 563 213 * We have performed the required number of … … 572 222 unsigned int rnd = rand() % 100; 573 223 if (rnd < subphase->prob.alloc) { 574 /* Compute a random number lying in interval <min_block_size, max_block_size> */ 224 /* 225 * Compute a random number lying in interval 226 * <min_block_size, max_block_size> 227 */ 575 228 int alloc = phase->alloc.min_block_size + 576 229 (rand() % (phase->alloc.max_block_size - phase->alloc.min_block_size + 1)); 577 230 578 mem_block_t blk = alloc_block(alloc);231 mem_block_t *blk = alloc_block(alloc); 579 232 RETURN_IF_ERROR; 580 233 … … 585 238 break; 586 239 } 587 588 240 } else { 589 241 TPRINTF("A"); 590 242 fill_block(blk); 243 RETURN_IF_ERROR; 591 244 } 592 245 593 246 } else if (rnd < subphase->prob.free) { 594 mem_block_t blk = get_random_block();247 mem_block_t *blk = get_random_block(); 595 248 if (blk == NULL) { 596 249 TPRINTF("F(R)"); … … 599 252 break; 600 253 } 601 602 254 } else { 603 255 TPRINTF("R"); … … 614 266 } 615 267 616 617 static void do_phase(phase_s *phase) 268 static void do_phase(phase_t *phase) 618 269 { 619 unsigned int subno; 620 621 for (subno = 0; subno < 3; subno++) { 622 subphase_s *subphase = & phase->subphases [subno]; 270 for (unsigned int subno = 0; subno < 3; subno++) { 271 subphase_t *subphase = &phase->subphases[subno]; 623 272 624 273 TPRINTF(".. Sub-phase %u (%s)\n", subno + 1, subphase->name); … … 632 281 init_mem(); 633 282 634 unsigned int phaseno;635 for (phaseno = 0; phaseno < sizeof_array(phases);phaseno++) {636 phase_ s*phase = &phases[phaseno];283 for (unsigned int phaseno = 0; phaseno < sizeof_array(phases); 284 phaseno++) { 285 phase_t *phase = &phases[phaseno]; 637 286 638 287 TPRINTF("Entering phase %u (%s)\n", phaseno + 1, phase->name); … … 645 294 } 646 295 296 TPRINTF("Cleaning up.\n"); 297 done_mem(); 647 298 if (error_flag) 648 299 return "Test failed"; -
uspace/app/tester/mm/malloc2.c
r82582e4 rdf3c6f02 1 1 /* 2 * Copyright (c) 20 09 Martin Decky2 * Copyright (c) 2011 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <test.h> 29 #include <stdio.h> 30 #include <unistd.h> 31 #include <stdlib.h> 32 #include <malloc.h> 33 #include "../tester.h" 30 34 31 const char *test_ fpu1(void)35 const char *test_malloc2(void) 32 36 { 37 int cnt = 0; 38 char *p; 39 40 TPRINTF("Provoking the kernel into overcommitting memory to us...\n"); 41 while ((p = malloc(1024 * 1024))) { 42 TPRINTF("%dM ", ++cnt); 43 *p = 'A'; 44 } 45 TPRINTF("\nWas refused more memory as expected.\n"); 46 33 47 return NULL; 34 48 } -
uspace/app/tester/tester.c
r82582e4 rdf3c6f02 62 62 #include "loop/loop1.def" 63 63 #include "mm/malloc1.def" 64 #include "mm/malloc2.def" 65 #include "mm/malloc3.def" 64 66 #include "hw/serial/serial1.def" 65 67 #include "hw/misc/virtchar1.def" -
uspace/app/tester/tester.h
r82582e4 rdf3c6f02 38 38 #include <sys/types.h> 39 39 #include <bool.h> 40 #include <stacktrace.h> 40 41 41 42 #define IPC_TEST_SERVICE 10240 … … 46 47 extern char **test_argv; 47 48 49 /** 50 * sizeof_array 51 * @array array to determine the size of 52 * 53 * Returns the size of @array in array elements. 54 */ 55 #define sizeof_array(array) \ 56 (sizeof(array) / sizeof((array)[0])) 57 48 58 #define TPRINTF(format, ...) \ 49 { \59 do { \ 50 60 if (!test_quiet) { \ 51 fprintf(stderr, format, ##__VA_ARGS__); \61 fprintf(stderr, (format), ##__VA_ARGS__); \ 52 62 } \ 53 } 63 } while (0) 64 65 #define TSTACKTRACE() \ 66 do { \ 67 if (!test_quiet) { \ 68 stacktrace_print(); \ 69 } \ 70 } while (0) 54 71 55 72 typedef const char *(*test_entry_t)(void); … … 78 95 extern const char *test_loop1(void); 79 96 extern const char *test_malloc1(void); 97 extern const char *test_malloc2(void); 98 extern const char *test_malloc3(void); 80 99 extern const char *test_serial1(void); 81 100 extern const char *test_virtchar1(void); -
uspace/app/top/screen.c
r82582e4 rdf3c6f02 254 254 uint64_t used; 255 255 uint64_t free; 256 c hartotal_suffix;257 c harunavail_suffix;258 c harused_suffix;259 c harfree_suffix;260 261 order_suffix(data->physmem->total, &total, &total_suffix);262 order_suffix(data->physmem->unavail, &unavail, &unavail_suffix);263 order_suffix(data->physmem->used, &used, &used_suffix);264 order_suffix(data->physmem->free, &free, &free_suffix);265 266 printf("memory: %" PRIu64 "% c total, %" PRIu64 "%cunavail, %"267 PRIu64 "% c used, %" PRIu64 "%cfree", total, total_suffix,256 const char *total_suffix; 257 const char *unavail_suffix; 258 const char *used_suffix; 259 const char *free_suffix; 260 261 bin_order_suffix(data->physmem->total, &total, &total_suffix, false); 262 bin_order_suffix(data->physmem->unavail, &unavail, &unavail_suffix, false); 263 bin_order_suffix(data->physmem->used, &used, &used_suffix, false); 264 bin_order_suffix(data->physmem->free, &free, &free_suffix, false); 265 266 printf("memory: %" PRIu64 "%s total, %" PRIu64 "%s unavail, %" 267 PRIu64 "%s used, %" PRIu64 "%s free", total, total_suffix, 268 268 unavail, unavail_suffix, used, used_suffix, free, free_suffix); 269 269 screen_newline(); … … 295 295 296 296 uint64_t resmem; 297 c harresmem_suffix;298 order_suffix(task->resmem, &resmem, &resmem_suffix);297 const char *resmem_suffix; 298 bin_order_suffix(task->resmem, &resmem, &resmem_suffix, true); 299 299 300 300 uint64_t virtmem; 301 c harvirtmem_suffix;302 order_suffix(task->virtmem, &virtmem, &virtmem_suffix);303 304 printf("%-8" PRIu64 " %7zu % 9" PRIu64 "%c",301 const char *virtmem_suffix; 302 bin_order_suffix(task->virtmem, &virtmem, &virtmem_suffix, true); 303 304 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s ", 305 305 task->task_id, task->threads, resmem, resmem_suffix); 306 306 print_percent(perc->resmem, 2); 307 printf(" % 8" PRIu64 "%c", virtmem, virtmem_suffix);307 printf(" %6" PRIu64 "%s ", virtmem, virtmem_suffix); 308 308 print_percent(perc->virtmem, 2); 309 309 puts(" ");
Note:
See TracChangeset
for help on using the changeset viewer.