From 6ed00870abd566d7267d2436c2693f5a281cda2f Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 8 Aug 2014 06:33:51 -0400 Subject: Base scheduler queues off linked lists and do cleanup/consolidation Abstracts threading from itself a bit, changes the way its queues are handled and does type hiding for that as well. Do alot here due to already required major brain surgery. Threads may now be on a run queue and a wait queue simultaneously so that the expired timer only has to wake the thread but not remove it from the wait queue which simplifies the implicit wake handling. List formats change for wait queues-- doubly-linked, not circular. Timeout queue is now singly-linked. The run queue is still circular as before. Adds a better thread slot allocator that may keep the slot marked as used regardless of the thread state. Assists in dumping special tasks that switch_thread was tasked to perform (blocking tasks). Deletes alot of code yet surprisingly, gets larger than expected. Well, I'm not not minding that for the time being-- omlettes and break a few eggs and all that. Change-Id: I0834d7bb16b2aecb2f63b58886eeda6ae4f29d59 --- apps/debug_menu.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'apps/debug_menu.c') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a11cff9350..61698f5025 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -151,25 +151,21 @@ static const char* threads_getname(int selected_item, void *data, selected_item -= NUM_CORES; #endif + const char *fmtstr = "%2d: ---"; + struct thread_debug_info threadinfo; - if (thread_get_debug_info(selected_item, &threadinfo) <= 0) + if (thread_get_debug_info(selected_item, &threadinfo) > 0) { - snprintf(buffer, buffer_len, "%2d: ---", selected_item); - return buffer; + fmtstr = "%2d:" IF_COP(" (%d)") " %s" IF_PRIO(" %d %d") + IFN_SDL(" %2d%%") " %s"; } - snprintf(buffer, buffer_len, - "%2d: " IF_COP("(%d) ") "%s " IF_PRIO("%d %d ") "%2d%% %s", + snprintf(buffer, buffer_len, fmtstr, selected_item, -#if NUM_CORES > 1 - threadinfo.core, -#endif + IF_COP(threadinfo.core,) threadinfo.statusstr, -#ifdef HAVE_PRIORITY_SCHEDULING - threadinfo.base_priority, - threadinfo.current_priority, -#endif - threadinfo.stack_usage, + IF_PRIO(threadinfo.base_priority, threadinfo.current_priority,) + IFN_SDL(threadinfo.stack_usage,) threadinfo.name); return buffer; @@ -187,16 +183,9 @@ static bool dbg_os(void) { struct simplelist_info info; simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", -#if NUM_CORES == 1 - MAXTHREADS, -#else - MAXTHREADS+NUM_CORES, -#endif - NULL); -#ifndef ROCKBOX_HAS_LOGF + MAXTHREADS IF_COP( + NUM_CORES ), NULL); info.hide_selection = true; info.scroll_all = true; -#endif info.action_callback = dbg_threads_action_callback; info.get_name = threads_getname; return simplelist_show_list(&info); -- cgit v1.2.3