From 88af2bfcea67d650a85ce8d0e152934c6dcc241c Mon Sep 17 00:00:00 2001 From: RichardBarry Date: Sun, 11 Jan 2009 13:04:03 +0000 Subject: [PATCH] Updated threads.js for Rowley Crossworks - thanks Glen B. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@604 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/ARM7_LPC2138_Rowley/threads.js | 89 ++++++++++++----------------- 1 file changed, 38 insertions(+), 51 deletions(-) diff --git a/Demo/ARM7_LPC2138_Rowley/threads.js b/Demo/ARM7_LPC2138_Rowley/threads.js index a790baf78..3c23f1b23 100644 --- a/Demo/ARM7_LPC2138_Rowley/threads.js +++ b/Demo/ARM7_LPC2138_Rowley/threads.js @@ -3,14 +3,8 @@ function decode_stack(sp) var i; var a = new Array(); - var current_task; - - current_task = Debug.evaluate("pxCurrentTCB"); - - if( current_task == 0 ) - return; - sp += 4; /* skip stored ulCriticalNesting */ + a[16] = Debug.evaluate("*(unsigned long*)" + sp); for (i = 0; i <= 15; i++) @@ -24,42 +18,44 @@ function decode_stack(sp) function add_task(task, state) { - var tcb, task_name; - - var current_task; + var tcb, task_name, current_task, regs; current_task = Debug.evaluate("pxCurrentTCB"); - - if( current_task == 0 ) - return; - tcb = Debug.evaluate("*(tskTCB *)" + task); + task_name = Debug.evaluate("(char*)&(*(tskTCB *)" + task + ").pcTaskName[0]"); - Threads.add("#" + tcb.uxTCBNumber + " \"" + task_name + "\"", tcb.uxPriority, state, decode_stack(tcb.pxTopOfStack)); -} + task_name = "#" + tcb.uxTCBNumber + " \"" + task_name + "\""; -function add_list(list, state, current_task) -{ - var i, index, item, end; - var current_task; + if (task == current_task) + { + state = "executing"; + regs = []; + } + else + { + regs = decode_stack(tcb.pxTopOfStack); + } - current_task = Debug.evaluate("pxCurrentTCB"); + Threads.add(task_name, tcb.uxPriority, state, regs); +} - if( current_task == 0 ) - return; +function add_list(list, state) +{ + var i, index, item, task; - if (list.uxNumberOfItems) + if (list && list.uxNumberOfItems>0) { - index = list.pxIndex; - end = list.xListEnd; + index = list.xListEnd.pxNext; + for (i = 0; i < list.uxNumberOfItems; i++) { item = Debug.evaluate("*(xListItem *)" + index); - if (index != end) - { - task = item.pvOwner; - if (task) add_task(task, (task == current_task) ? "executing" : state); - } + + task = item ? item.pvOwner : 0; + + if (task) + add_task(task, state); + index = item.pxNext; } } @@ -67,52 +63,43 @@ function add_list(list, state, current_task) function update() { - var i, current_task, list, lists, max_priority; + var i, list, lists, max_priority; Threads.clear(); - current_task = Debug.evaluate("pxCurrentTCB"); - - if( current_task == 0 ) + if( Debug.evaluate("pxCurrentTCB") == 0 ) return; - Threads.newqueue("Ready"); - lists = Debug.evaluate("pxReadyTasksLists"); - if (lists) - { - max_priority = Debug.evaluate("uxTopUsedPriority"); - max_priority = Debug.evaluate("*(long *)" + max_priority); + max_priority = Debug.evaluate("uxTopUsedPriority"); - for (i = 0; i <= max_priority; i++) - { - list = Debug.evaluate("((xList*)" + lists + ")[" + (max_priority - i) + "]"); - add_list(list, "ready", current_task); - } + Threads.newqueue("Ready"); + for (i = max_priority; i >= 0; i--) + { + list = Debug.evaluate("pxReadyTasksLists[" + i + "]"); + add_list(list, "ready"); } Threads.newqueue("Blocked"); - list = Debug.evaluate("pxDelayedTaskList"); if (list) { - list = Debug.evaluate("**(xList **)" + list); + list = Debug.evaluate("*(xList *)" + list); add_list(list, "blocked"); } list = Debug.evaluate("pxOverflowDelayedTaskList"); if (list) { - list = Debug.evaluate("**(xList **)" + list); + list = Debug.evaluate("*(xList *)" + list); add_list(list, "blocked"); } Threads.newqueue("Suspended"); - list = Debug.evaluate("xSuspendedTaskList"); if (list) { - list = Debug.evaluate("*(xList *)" + list); add_list(list, "suspended"); } + } -- 2.39.5