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
This commit is contained in:
Michael Sevakis 2014-08-08 06:33:51 -04:00
parent eb63d8b4a2
commit 6ed00870ab
20 changed files with 1550 additions and 2057 deletions

View file

@ -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);