Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: kwoolridge on June 01, 2017, 03:01:27 PM
-
I would like to walk the task/process list to determine all the currently running tasks/processes. However, I do not see any library function that will get me the
start of the list.
Does anyone know how I can accomplish this?
-
There is no OS function for that. You have to traverse the system lists yourself, which is considered a hack.
Here is an example:
#include <exec/execbase.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <clib/alib_protos.h>
#include <string.h>
void copy_node (struct List *list,struct Node *oldnode)
{
char *oldname = oldnode->ln_Name ? oldnode->ln_Name : "";
struct Node *newnode = AllocVec (sizeof(struct Node) + strlen(oldname) + 1,MEMF_ANY);
if (newnode)
{
newnode->ln_Type = oldnode->ln_Type;
newnode->ln_Pri = oldnode->ln_Pri;
newnode->ln_Name = (STRPTR)(newnode + 1);
strcpy (newnode->ln_Name,oldname);
AddTail (list,newnode);
}
}
void free_nodes (struct List *list)
{
struct Node *node;
while (node = RemTail (list))
FreeVec (node);
}
void get_task_list (struct List *ready,struct List *wait)
{
struct Node *node,*next;
Forbid();
for (node = SysBase->TaskReady.lh_Head; next = node->ln_Succ; node = next)
copy_node (ready,node);
for (node = SysBase->TaskWait.lh_Head; next = node->ln_Succ; node = next)
copy_node (wait,node);
Permit();
}
int main (void)
{
struct List ready,wait;
struct Node *node,*next;
NewList (&ready);
NewList (&wait);
get_task_list (&ready,&wait);
for (node = ready.lh_Head; next = node->ln_Succ; node = next)
Printf ("ready: Pri = %4ld; Name = \"%s\"\n",node->ln_Pri,node->ln_Name);
for (node = wait.lh_Head; next = node->ln_Succ; node = next)
Printf ("waiting: Pri = %4ld; Name = \"%s\"\n",node->ln_Pri,node->ln_Name);
free_nodes (&wait);
free_nodes (&ready);
return (RETURN_OK);
}
-
http://aminet.net/package/util/moni/Scout_os3
?
-
Thank you for your example. I compiled it okay. However, when I attempt to link it, the linker (blink from SAS C) complains about an undefined symbol __XCOVF. I am not very familiar with C/C++ so I am not sure about this. Can you explain this symbol, please?
-
I've never seen that. Symbols beginning with __ are compiler-specific. I am not familiar with SAS C, probably you didn't install it right.
Try VBCC or Dice C, they are both free and more modern.
-
Thank you for your example. I compiled it okay. However, when I attempt to link it, the linker (blink from SAS C) complains about an undefined symbol __XCOVF. I am not very familiar with C/C++ so I am not sure about this. Can you explain this symbol, please?
Wait a minute - are we talking about Lattice C ("BLink") or SAS C? In the latter case, the linker should be "SLink".
One way or another: The error message means "You forgot to link against sc.lib", which is the SAS/C compiler link library which includes this symbol. You probably also need to link with LIB:c.o. See the manual that comes with the compiler.
XCOVF is the stack-extension check which will be called in the head of each function if you compile with automatic stack extension enabled. My edition of SAS/C even includes its source.
-
I would like to walk the task/process list to determine all the currently running tasks/processes. However, I do not see any library function that will get me the
start of the list.
Does anyone know how I can accomplish this?
Scout is very nice "Task Manager" as Foul recomended to you.
-
Thank you all! I got the program above working.