/* * WHO * by George Musser Jr. * 16 November 1986 * * 21 January 1987 - added task id, CLI process numbers * * Lists tasks on the Ready and Wait queues. * */ #include #include #include #include #include #define MAX_NODES 60 /* Number of tasks we can list */ #define NAME_LEN 40 /* Number of characters in task names */ extern struct ExecBase *SysBase; extern int Enable_Abort; main() { void Disable(); void PrintList(struct List *,char *); Enable_Abort = 1; /* First, get Ready list */ /* Disable first, so that SysBase->TaskReady is valid */ Disable(); PrintList (&SysBase->TaskReady,"Ready"); /* Now get Wait list */ Disable(); PrintList (&SysBase->TaskWait,"Waiting"); } /* * PrintList() * * Prints the names, pointers, priorities, and types of items in a list. * */ void PrintList (header,label) struct List *header; /* List header */ char *label; /* Textual label for list */ { void strncpy(char *,char *,int); void Enable(); void printf(); struct Node *node; /* Points to list nodes */ char name[MAX_NODES][NAME_LEN]; /* Node name */ struct Node *id[MAX_NODES]; /* Node pointer */ BYTE pri[MAX_NODES]; /* Node priority */ UBYTE type[MAX_NODES]; /* Node type */ LONG num[MAX_NODES]; /* CLI number */ int i,j; /* Loop counters */ for (node = header->lh_Head, i = 0; /* Scan through list, */ node->ln_Succ && i <= MAX_NODES; /* gathering info */ node = node->ln_Succ, i++) { strncpy (name[i],node->ln_Name,NAME_LEN); id[i] = node; pri[i] = node->ln_Pri; type[i] = node->ln_Type; if (node->ln_Type == NT_PROCESS) num[i] = ((struct Process *)node)->pr_TaskNum; else num[i] = 0L; } Enable(); printf ("%s...\n",label); /* Now display info */ for (j = 0; j < i; j++) { printf ("\"%s\", id %lx, pri %d, ",name[j],id[j],pri[j]); switch (type[j]) { case NT_TASK : printf ("task.\n"); break; case NT_PROCESS : if (num[j]) printf ("CLI process %d.\n",num[j]); else printf ("process.\n"); break; default : printf ("type %d.\n",type[j]); } } }