Changeset 04c418d in mainline for uspace/app
- Timestamp:
- 2011-05-17T07:58:39Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7d521e24
- Parents:
- e913cc9 (diff), 3375bd4 (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:
-
- 2 added
- 8 edited
-
init/Makefile (modified) (1 diff)
-
klog/klog.c (modified) (4 diffs)
-
stats/stats.c (modified) (1 diff)
-
tester/Makefile (modified) (1 diff)
-
tester/mm/malloc2.c (added)
-
tester/mm/malloc2.def (added)
-
tester/tester.c (modified) (1 diff)
-
tester/tester.h (modified) (1 diff)
-
top/screen.c (modified) (2 diffs)
-
vuhid/device.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/Makefile
re913cc9 r04c418d 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = init 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/app/klog/klog.c
re913cc9 r04c418d 44 44 #include <io/klog.h> 45 45 #include <sysinfo.h> 46 #include <malloc.h> 46 47 #include <fibril_synch.h> 48 #include <adt/list.h> 49 #include <adt/prodcons.h> 47 50 48 51 #define NAME "klog" 49 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; 50 62 51 63 /* Pointer to klog area */ … … 53 65 static size_t klog_length; 54 66 55 static FILE *log; 56 57 /* Serialize the output a bit. This will not avoid messed-up log completely 58 but chances for are pretty high (experimentally confirmed). */ 59 static FIBRIL_MUTEX_INITIALIZE(log_mutex); 60 61 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) 62 { 63 fibril_mutex_lock(&log_mutex); 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); 64 165 65 166 size_t klog_start = (size_t) IPC_GET_ARG1(*call); 66 167 size_t klog_len = (size_t) IPC_GET_ARG2(*call); 67 168 size_t klog_stored = (size_t) IPC_GET_ARG3(*call); 68 size_t i; 69 70 for (i = klog_len - klog_stored; i < klog_len; i++) { 71 wchar_t ch = klog[(klog_start + i) % klog_length]; 72 73 putchar(ch); 74 75 if (log != NULL) 76 fputc(ch, log); 77 } 78 79 if (log != NULL) { 80 fflush(log); 81 fsync(fileno(log)); 82 } 83 84 fibril_mutex_unlock(&log_mutex); 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); 85 183 } 86 184 … … 120 218 } 121 219 220 prodcons_initialize(&pc); 221 async_set_interrupt_received(notification_received); 122 222 rc = event_subscribe(EVENT_KLOG, 0); 123 223 if (rc != EOK) { … … 127 227 } 128 228 129 /* 130 * Mode "a" would be definitively much better here, but it is 131 * not well supported by the FAT driver. 132 */ 133 log = fopen(LOG_FNAME, "w"); 134 if (log == NULL) 135 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME, 136 str_error(errno)); 137 138 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); 139 238 klog_update(); 239 240 task_retval(0); 140 241 async_manager(); 141 242 -
uspace/app/stats/stats.c
re913cc9 r04c418d 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, -
uspace/app/tester/Makefile
re913cc9 r04c418d 49 49 loop/loop1.c \ 50 50 mm/malloc1.c \ 51 mm/malloc2.c \ 51 52 mm/mapping1.c \ 52 53 devs/devman1.c \ -
uspace/app/tester/tester.c
re913cc9 r04c418d 62 62 #include "loop/loop1.def" 63 63 #include "mm/malloc1.def" 64 #include "mm/malloc2.def" 64 65 #include "mm/mapping1.def" 65 66 #include "hw/serial/serial1.def" -
uspace/app/tester/tester.h
re913cc9 r04c418d 78 78 extern const char *test_loop1(void); 79 79 extern const char *test_malloc1(void); 80 extern const char *test_malloc2(void); 80 81 extern const char *test_mapping1(void); 81 82 extern const char *test_serial1(void); -
uspace/app/top/screen.c
re913cc9 r04c418d 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(" "); -
uspace/app/vuhid/device.c
re913cc9 r04c418d 36 36 #include "virthid.h" 37 37 #include <errno.h> 38 #include <stdio.h> 38 39 #include <str.h> 39 40 #include <assert.h>
Note:
See TracChangeset
for help on using the changeset viewer.
