summaryrefslogtreecommitdiff
path: root/apps/debug_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r--apps/debug_menu.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 60f405ae50..bda5a5c4f0 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -80,13 +80,27 @@ extern char ata_device;
80extern int ata_io_address; 80extern int ata_io_address;
81extern struct core_entry cores[NUM_CORES]; 81extern struct core_entry cores[NUM_CORES];
82 82
83char thread_status_char(int status)
84{
85 switch (status)
86 {
87 case STATE_RUNNING : return 'R';
88 case STATE_BLOCKED : return 'B';
89 case STATE_SLEEPING : return 'S';
90 case STATE_BLOCKED_W_TMO: return 'T';
91 }
92
93 return '?';
94}
83#ifdef HAVE_LCD_BITMAP 95#ifdef HAVE_LCD_BITMAP
84/* Test code!!! */ 96/* Test code!!! */
85bool dbg_os(void) 97bool dbg_os(void)
86{ 98{
99 struct thread_entry *thread;
87 char buf[32]; 100 char buf[32];
88 int i; 101 int i;
89 int usage; 102 int usage;
103 int status;
90#if NUM_CORES > 1 104#if NUM_CORES > 1
91 unsigned int core; 105 unsigned int core;
92 int line; 106 int line;
@@ -98,24 +112,54 @@ bool dbg_os(void)
98 112
99 while(1) 113 while(1)
100 { 114 {
115#if 0 /* Enable to simulate UI lag. */
116 int _x;
117 for (_x = 0; _x < 1000000L; _x++) ;
118#endif
101#if NUM_CORES > 1 119#if NUM_CORES > 1
102 lcd_puts(0, 0, "Core and stack usage:"); 120 lcd_puts(0, 0, "Core and stack usage:");
103 line = 0; 121 line = 0;
104 for(core = 0; core < NUM_CORES; core++) 122 for(core = 0; core < NUM_CORES; core++)
105 { 123 {
106 for(i = 0; i < num_threads[core]; i++) 124 for(i = 0; i < MAXTHREADS; i++)
107 { 125 {
108 usage = thread_stack_usage_on_core(core, i); 126 thread = &cores[core].threads[i];
109 snprintf(buf, 32, "(%d) %s: %d%%", core, thread_name[core][i], usage); 127 if (thread->name == NULL)
128 continue;
129
130 usage = thread_stack_usage(thread);
131 status = thread_get_status(thread);
132
133 snprintf(buf, 32, "(%d) %c%c %d %s: %d%%", core,
134 (status == STATE_RUNNING) ? '*' : ' ',
135 thread_status_char(status),
136 cores[CURRENT_CORE].threads[i].priority,
137 cores[core].threads[i].name, usage);
110 lcd_puts(0, ++line, buf); 138 lcd_puts(0, ++line, buf);
111 } 139 }
112 } 140 }
113#else 141#else
114 lcd_puts(0, 0, "Stack usage:"); 142 lcd_puts(0, 0, "Stack usage:");
115 for(i = 0; i < cores[CURRENT_CORE].num_threads;i++) 143 for(i = 0; i < MAXTHREADS; i++)
116 { 144 {
117 usage = thread_stack_usage(i); 145 thread = &cores[CURRENT_CORE].threads[i];
118 snprintf(buf, 32, "%s: %d%%", cores[CURRENT_CORE].threads[i].name, usage); 146 if (thread->name == NULL)
147 continue;
148
149 usage = thread_stack_usage(thread);
150 status = thread_get_status(thread);
151# ifdef HAVE_PRIORITY_SCHEDULING
152 snprintf(buf, 32, "%c%c %d %s: %d%%",
153 (status == STATE_RUNNING) ? '*' : ' ',
154 thread_status_char(status),
155 cores[CURRENT_CORE].threads[i].priority,
156 cores[CURRENT_CORE].threads[i].name, usage);
157# else
158 snprintf(buf, 32, "%c%c %s: %d%%",
159 (status == STATE_RUNNING) ? '*' : ' ',
160 (status == STATE_BLOCKED) ? 'B' : ' ',
161 cores[CURRENT_CORE].threads[i].name, usage);
162# endif
119 lcd_puts(0, 1+i, buf); 163 lcd_puts(0, 1+i, buf);
120 } 164 }
121#endif 165#endif