home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / exec / tasks / tasklist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  2.7 KB  |  76 lines

  1. ;/* tasklist.c - Execute me to compile me with Lattice 5.04
  2. LC -b1 -cfistq -v -y -j73 tasklist.c
  3. Blink FROM LIB:c.o,tasklist.o TO tasklist LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /* TaskList.c - lists tasks in system
  8.  *
  9.  * Copyright (c) 1990 Commodore-Amiga, Inc.
  10.  *
  11.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  12.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  13.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  14.  * information on the correct usage of the techniques and operating system
  15.  * functions presented in this example.  The source and executable code of
  16.  * this example may only be distributed in free electronic form, via bulletin
  17.  * board or as part of a fully non-commercial and freely redistributable
  18.  * diskette.  Both the source and executable code (including comments) must
  19.  * be included, without modification, in any copy.  This example may not be
  20.  * published in printed form or distributed with any commercial product.
  21.  * However, the programming techniques and support routines set forth in
  22.  * this example may be used in the development of original executable
  23.  * software products for Commodore Amiga computers.
  24.  * All other rights reserved.
  25.  * This example is provided "as-is" and is subject to change; no warranties
  26.  * are made.  All use is at your own risk.  No liability or responsibility
  27.  * is assumed.
  28.  */
  29.  
  30. #include "exec/types.h"
  31. #include "exec/execbase.h"
  32. #include "exec/tasks.h"
  33. #ifdef LATTICE
  34. #include <proto/all.h>
  35. #include <stdlib.h>
  36. #include <stdio.h>
  37. int CXBRK(void) { return(0); }        /* Disable Lattice CTRL/C handling */
  38. int chkabort(void) { return(0); }    /* really */
  39. #endif
  40.  
  41. #define ARRAYSIZE 128L
  42. extern struct ExecBase *SysBase;
  43.  
  44. void main(int argc,char **argv)
  45.     {
  46.     struct Task *task;
  47.     LONG count=0, i=0, readi=0;
  48.     char *names[ARRAYSIZE];
  49.  
  50.     Disable();
  51.     for ( task = (struct Task *)SysBase->TaskWait.lh_Head;
  52.           (NULL != task->tc_Node.ln_Succ) && (count < ARRAYSIZE);
  53.           task = (struct Task *)task->tc_Node.ln_Succ)
  54.         {
  55.         names[count++] = task->tc_Node.ln_Name;
  56.         }
  57.     readi=count;
  58.     for ( task = (struct Task *)SysBase->TaskReady.lh_Head;
  59.           (NULL != task->tc_Node.ln_Succ) && (count < ARRAYSIZE);
  60.           task = (struct Task *)task->tc_Node.ln_Succ)
  61.         {
  62.         names[count++] = task->tc_Node.ln_Name;
  63.         }
  64.     Enable();
  65.  
  66.     if (count == ARRAYSIZE) names[count-1]="error: array overflow"; 
  67.  
  68.     printf("WAITING Tasks:\n");
  69.     for (i = 0; i < count; i++)
  70.         {
  71.         if(i==readi)  printf("READY tasks:\n");
  72.         printf(" %s\n", names[i]);
  73.         }
  74.     printf("THIS Task:\n %s\n",SysBase->ThisTask->tc_Node.ln_Name);
  75.     }
  76.