home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / mach / thread_info.h < prev    next >
Text File  |  1992-07-29  |  4KB  |  122 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1989 Carnegie-Mellon University
  4.  * Copyright (c) 1988 Carnegie-Mellon University
  5.  * Copyright (c) 1987 Carnegie-Mellon University
  6.  * All rights reserved.  The CMU software License Agreement specifies
  7.  * the terms and conditions for use and redistribution.
  8.  */
  9. /*
  10.  * HISTORY
  11.  * $Log:    thread_info.h,v $
  12.  * Revision 2.6  89/10/11  14:41:37  dlb
  13.  *     Add scheduling information.
  14.  *     [89/05/18            dlb]
  15.  * 
  16.  * Revision 2.5  89/03/09  20:24:12  rpd
  17.  *     More cleanup.
  18.  * 
  19.  * Revision 2.4  89/02/25  18:41:18  gm0w
  20.  *     Changes for cleanup.
  21.  * 
  22.  *  4-Mar-88  David Black (dlb) at Carnegie-Mellon University
  23.  *    Added TH_USAGE_SCALE for cpu_usage field.
  24.  *
  25.  * 15-Jan-88  David Golub (dbg) at Carnegie-Mellon University
  26.  *    Changed to generic interface (variable-length array) to allow
  27.  *    for expansion.  Renamed to thread_info.
  28.  *
  29.  *  1-Jun-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  30.  *    Created.
  31.  *
  32.  */
  33. /*
  34.  *    File:    mach/thread_info
  35.  *
  36.  *    Thread information structure and definitions.
  37.  *
  38.  *    The defintions in this file are exported to the user.  The kernel
  39.  *    will translate its internal data structures to these structures
  40.  *    as appropriate.
  41.  *
  42.  */
  43.  
  44. #ifndef    _MACH_THREAD_INFO_H_
  45. #define _MACH_THREAD_INFO_H_
  46.  
  47. #import <mach/policy.h>
  48. #import <mach/time_value.h>
  49.  
  50. /*
  51.  *    Generic information structure to allow for expansion.
  52.  */
  53. typedef    int    *thread_info_t;        /* varying array of int */
  54.  
  55. #define THREAD_INFO_MAX        (1024)    /* maximum array size */
  56. typedef    int    thread_info_data_t[THREAD_INFO_MAX];
  57.  
  58. /*
  59.  *    Currently defined information.
  60.  */
  61. #define THREAD_BASIC_INFO    1        /* basic information */
  62.  
  63. struct thread_basic_info {
  64.     time_value_t    user_time;    /* user run time */
  65.     time_value_t    system_time;    /* system run time */
  66.     int        cpu_usage;    /* scaled cpu usage percentage */
  67.     int        base_priority;    /* base scheduling priority */
  68.     int        cur_priority;    /* current scheduling priority */!21t        run_state;    /* run state (see below) */
  69.     int        flags;        /* various flags (see below) */
  70.     int        suspend_count;    /* suspend count for thread */
  71.     long        sleep_time;    /* number of seconds that thread
  72.                        has been sleeping */
  73. };
  74.  
  75. typedef struct thread_basic_info    thread_basic_info_data_t;
  76. typedef struct thread_basic_info    *thread_basic_info_t;
  77. #define THREAD_BASIC_INFO_COUNT    \
  78.         (sizeof(thread_basic_info_data_t) / sizeof(int))
  79.  
  80. /*
  81.  *    Scale factor for usage field.
  82.  */
  83.  
  84. #define TH_USAGE_SCALE    1000
  85.  
  86. /*
  87.  *    Thread run states (state field).
  88.  */
  89.  
  90. #define TH_STATE_RUNNING    1    /* thread is running normally */
  91. #define TH_STATE_STOPPED    2    /* thread is stopped */
  92. #define TH_STATE_WAITING    3    /* thread is waiting normally */
  93. #define TH_STATE_UNINTERRUPTIBLE 4    /* thread is in an uninterruptible
  94.                        wait */
  95. #define TH_STATE_HALTED        5    /* thread is halted at a
  96.                        clean point */
  97.  
  98. /*
  99.  *    Thread flags (flags field).
  100.  */
  101. #define TH_FLAGS_SWAPPED    0x1    /* thread is swapped out */
  102. #define TH_FLAGS_IDLE        0x2    /* thread is an idle thread */
  103.  
  104. #define THREAD_SCHED_INFO    2
  105.  
  106. struct thread_sched_info {
  107.     int        policy;        /* scheduling policy */
  108.     int        data;        /* associated data */
  109.     int        base_priority;    /* base priority */
  110.     int        max_priority;   /* max priority */
  111.     int        cur_priority;    /* current priority */
  112.     boolean_t    depressed;    /* depressed ? */
  113.     int        depress_priority; /* priority depressed from */
  114. };
  115.  
  116. typedef struct thread_sched_info    thread_sched_info_data_t;
  117. typedef struct thread_sched_info    *thread_sched_info_t;
  118. #define    THREAD_SCHED_INFO_COUNT    \
  119.         (sizeof(thread_sched_info_data_t) / sizeof(int))
  120.  
  121. #endif    _MACH_THREAD_INFO_H_
  122.