Welcome, Guest. Please login or register.

Author Topic: Start of task/process list  (Read 2598 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline kwoolridgeTopic starter

  • Newbie
  • *
  • Join Date: Sep 2007
  • Posts: 8
    • Show only replies by kwoolridge
Start of task/process list
« 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?
 

Offline Thomas

Re: Start of task/process list
« Reply #1 on: June 01, 2017, 04:21:35 PM »
There is no OS function for that. You have to traverse the system lists yourself, which is considered a hack.

Here is an example:

Code: [Select]

#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 : &quot;&quot;;
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 (&quot;ready:   Pri = %4ld; Name = \&quot;%s\&quot;\n&quot;,node->ln_Pri,node->ln_Name);
for (node = wait.lh_Head; next = node->ln_Succ; node = next)
Printf (&quot;waiting: Pri = %4ld; Name = \&quot;%s\&quot;\n&quot;,node->ln_Pri,node->ln_Name);

free_nodes (&wait);
free_nodes (&ready);

return (RETURN_OK);
}

Offline Foul

  • Jr. Member
  • **
  • Join Date: Mar 2010
  • Posts: 77
    • Show only replies by Foul
    • http://www.jamma.fr
Re: Start of task/process list
« Reply #2 on: June 01, 2017, 05:04:46 PM »
 

Offline kwoolridgeTopic starter

  • Newbie
  • *
  • Join Date: Sep 2007
  • Posts: 8
    • Show only replies by kwoolridge
Re: Start of task/process list
« Reply #3 on: June 02, 2017, 08:01:06 PM »
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?
 

Offline Thomas

Re: Start of task/process list
« Reply #4 on: June 02, 2017, 11:39:41 PM »
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.

guest11527

  • Guest
Re: Start of task/process list
« Reply #5 on: June 03, 2017, 09:10:39 AM »
Quote from: kwoolridge;826599
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.
 

Offline Drummerboy

  • Hero Member
  • *****
  • Join Date: Jul 2003
  • Posts: 512
    • Show only replies by Drummerboy
Re: Start of task/process list
« Reply #6 on: June 04, 2017, 04:34:31 AM »
Quote from: kwoolridge;826560
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.
Amiga 1000, 500, 600, 2000, 1200, 4000...

C= VIC 20 / 64 /SX64/ 128

Atari 600XL (SIC Cartdridge)
Atari 800XL (SIO2SD unit)

Jay Miner`s Atari 2600 - Wood front -

\\"Amiga, this Computer have a Own Live\\"--\\"Silence When the Drums are Talking\\".... DrummerBoy
 

Offline kwoolridgeTopic starter

  • Newbie
  • *
  • Join Date: Sep 2007
  • Posts: 8
    • Show only replies by kwoolridge
Re: Start of task/process list
« Reply #7 on: June 04, 2017, 12:49:59 PM »
Thank you all!  I got the program above working.