home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / os2v1.zip / ART1.TXT next >
Text File  |  1994-03-26  |  12KB  |  242 lines

  1. System Monitoring in Multitasking Environments 
  2.  
  3. By Dave Wallenberg
  4. ══════════════════════════════════════════════
  5.  
  6. The focus of this article is to discuss the value of monitoring system 
  7. activities in the multitasking and multithreading environment as it 
  8. pertains to such operating systems such as OS/2, UNIX, and NT.
  9.  
  10.  
  11. OS/2, UNIX, and NT are multitasking and multithreading operating systems.  
  12. This means that more than one task can be performed at a time.  Not only 
  13. does this imply that the user can work on more than one thing at a time, 
  14. but the operating system itself takes advantage of this as well and has 
  15. several processes executing in the background.  These processes are typi-
  16. cally hidden from the user.
  17.  
  18. Where there can be numerous activities, there can be several resources and 
  19. devices being used simultaneously.  This adds a level of complexity that 
  20. today's user needs to be aware of.  The user may need to be aware of or 
  21. desire the ability to monitor:
  22.  
  23.      CPU usage to identify and resolve performance bottlenecks.  This can 
  24.      be invaluable when trying to understand why and when your system runs 
  25.      slow and the ability to identify what processes cause the degradation.
  26.      
  27.      With memory utilization and how much memory is currently in use, one 
  28.      can gain insight into system tuning.  The more components that are 
  29.      simultaneously active, the more memory is demanded until excess swap-
  30.      ping occurs.
  31.      
  32.      Swap utilization to identify excess and frequent swap activity when 
  33.      memory is over committed.  This can be a good identifier for needing 
  34.      more memory.  When physical memory is exceeded based on the programs 
  35.      simultaneously running and their memory requirements, the operating 
  36.      system responds by temporarily "moving" pieces (4KB pages) of less 
  37.      active memory out to disk.  These chunks of memory are brought back 
  38.      into memory when the memory is referenced.  A Swap monitor can provide 
  39.      insight into excess swapping.
  40.      
  41.      Program performance can enable the user to assess the impact of run-
  42.      ning program(s).  Today's diverse software and multimedia craze re-
  43.      quires the high performance of at least a i486 based or equivalent 
  44.      processor to keep up with CPU and memory intensive applications.  The 
  45.      ability to examine the CPU usage of a program can help identify de-
  46.      manding programs and perhaps ill-behaved programs.  Program monitoring 
  47.      can also offer the ability to see the number programs active and what 
  48.      state each program is in.
  49.      
  50.      Disk space utilization is often desirable to monitor.  How many people 
  51.      out there have more disk space than they know what to do with.  Most 
  52.      people are always "tight" on disk space.  As you are downloading a large 
  53.      file, or excess Swapping occurs, the ability to quickly view your disk 
  54.      space constraints can be very valuable.
  55.      
  56.      Status of print spooler and print queue(s) is another valuable item to 
  57.      monitor.  Particularly when the computer can print to LAN printers, 
  58.      receive and send fax documents, and more.
  59.      
  60.      The current date, time, disk drives online and available, and more.
  61.      
  62.  
  63. The three most important things in a computer have never changed.  They 
  64. remain, and in the following sequence, are:
  65.  
  66.      1.  The speed of the processor(s)
  67.      2.  The amount, speed, and location of physical memory
  68.      3.  The amount and speed of external storage disk
  69.  
  70.  
  71. Program and CPU Monitoring:
  72. ───────────────────────────
  73.  
  74. The multitasking and multithreading environment of OS/2 allows numerous 
  75. activities to execute simultaneously.  Although each process executing 
  76. appears to be sharing the same CPU concurrently, the processes are actually 
  77. being individual time-slices from the OS/2 Scheduler in what is called a 
  78. Priority driven Round-Robin algorithm.  This means the scheduler factors 
  79. into the time-slice algorithm (amongst other items such as I/O vs CPU bound 
  80. and Min/Max time-slice milliseconds) the priority of each thread within a 
  81. process.  The information that the operating system maintains and collects 
  82. per process and each thread within the process is stored in the Process 
  83. Tables.  These tables are memory resident data structures that only the 
  84. operating system can access OS/2 provides an (undocumented) API that allows 
  85. access to the Process Table information. With this, the monitoring software 
  86. can summarize and report the statistics in a meaningful presentation.  Some 
  87. of the data that can be monitored and presented to the user is:
  88.  
  89.      Number of processes and threads that are running
  90.      
  91.      The priority and state of the thread in a process
  92.      
  93.      The amount of CPU time each thread of a process has received
  94.      
  95.      Which CPU each thread is attached to in the SMP (Symmetric Multi-
  96.      Processing) version
  97.      
  98.      and more...
  99.  
  100.  
  101. These items form the basis for monitoring programs executing, how they are 
  102. executing, and what amount of CPU each is consuming.  This information, if 
  103. presented intuitively, can be useful to any audience.  Whether the user be a 
  104. novice or a software engineer, this real-time summary provides insight.  It 
  105. can be used as resolving overall system performance or performance right down 
  106. to the thread level.  For example, when the system appears to be "hung" or 
  107. sluggish, a simple system-wide CPU monitor can inform the user as to the 
  108. extent of unresponsiveness.  The ability to then "zoom" into a birds-eye 
  109. view of all programs running and examine the CPU utilization per processes, 
  110. usually will identify the culprit program.
  111.  
  112. Without this insight, you're at a complete loss as to what happened.  The 
  113. CPU monitor is typically the first monitor tool to obtain and rather simple 
  114. to develop.  But the Process Monitor is difficult to develop and depends 
  115. solely on the ability to "get at" the Process Table information of the opera-
  116. ting system.  The Process Table(s) structure is operating system specific and 
  117. requires a strong understanding of the structure layout.  Most new operating 
  118. systems provide this raw data for applications in the form of an API. OS/2 
  119. provides much of the data to the monitoring application via an API called 
  120. DosQProcStatus.
  121.  
  122. At it's best, the monitoring tool may provide an Early Warning mechanism.  
  123. This ability would warn the user when certain thresholds have been exceeded.  
  124. Such as abnormal and excessive CPU usage may indicate a runaway situation. 
  125. Before this condition brings the entire system to its knees, the user can 
  126. have he opportunity to not only terminate the ill-behaved culprit, but more 
  127. importantly, determine the cause.  Early Warning mechanisms are seen most 
  128. often in real-time mission-critical systems.
  129.  
  130.  
  131. Memory Monitor:
  132. ───────────────
  133.  
  134. The real-time memory monitor is valuable in providing the user with insight 
  135. into the amount of memory that is currently in use and memory that is idle 
  136. and subject to being swapped-out.
  137.  
  138. In a virtual memory model such as OS/2, the amount of actual free memory is 
  139. very difficult to determine and usually calculates into an approximation.  
  140. The virtual memory model simply looks at available memory as physical memory 
  141. installed plus disk space available.  So free memory can be two different 
  142. things; Actual free physical memory, or total virtual memory.  Actual free 
  143. memory is most often desired to monitor.
  144.  
  145. Tracking free physical memory, along with swap activity, enables you to 
  146. determine whether you have enough memory to meet your demands.  This is pri-
  147. marily an issue of cost.  Although, some may interpret it as an issue of 
  148. "pain".  What is your "threshold of pain" while you wait for the system to 
  149. swap out memory pages to free up room for your next program?
  150.  
  151.  
  152. Disk and Swap Monitoring:
  153. ─────────────────────────
  154.  
  155. Swapping is very much related to the amount of physical memory available.  
  156. At some point in the tuning process you determine your "threshold of pain".  
  157. RAM costs money, but swapping is inevitable - and normal.  Unless your appli-
  158. cation is of a time-critical nature and can not afford ANY swap time.
  159.  
  160. The ability to monitor the frequency and degree of swapping can be the only 
  161. thing you need in order to tune a system.  With this alone, you can do a per-
  162. formance tune-up on a given system.  Or at least identify if more memory is 
  163. needed and how much.
  164.  
  165.  
  166. Monitor Logging:
  167. ────────────────
  168.  
  169. Only surface analysis tuning can be accomplished without the ability to re-
  170. cord the monitoring activities.  Periodic and continuous logging are a must 
  171. for the monitoring tool.
  172.  
  173. After logging activity for a given amount of time, you have captured a sample 
  174. set of statistics.  This raw data can be summarized and produce minimum, 
  175. maximum, and average performance reports over different time intervals.  Per-
  176. haps peak periods.
  177.  
  178. It is important that a time-stamp is placed in the log (preferably down to a 
  179. hundredth of a second).  This facilitates even the most stressful situations 
  180. such as real-time monitoring.
  181.  
  182.  
  183. Monitor Caveats:
  184. ────────────────
  185.  
  186. The monitoring software can not cause overhead.  To accomplish many of the 
  187. monitoring tasks discussed in this article, the monitoring software is 
  188. required to periodically sample the device or system resource.  Obviously, 
  189. the more often samplings occur, the more system resources are used by the 
  190. monitoring software.  The ideal monitoring software:
  191.  
  192.      Is designed to run ALL the time and causes absolutely no interruptions.  
  193.      Realizing that the PC workstation is used by the user and the typical 
  194.      user uses the keyboard, keyboard and video delays caused by the monitor-
  195.      ing software means that the monitoring software is using too much CPU to
  196.      accomplish its job.
  197.  
  198.      Is designed to handle a stand-alone environment as well as being capable 
  199.      of monitoring resources in a intensive real-time environment as well.
  200.      
  201.      Is designed to be aware of LAN connectivity.
  202.      
  203.      Is designed to allow adjustable sampling rates for each resource to be 
  204.      monitored.
  205.      
  206.      Sampling each resource should be staggered to avoid sampling ALL 
  207.      resources at the same time.  This can also be accomplished by the user 
  208.      by adjusting the frequency of sampling.
  209.                
  210.      Exercises multithreading capabilities of the operating system so 
  211.      resource intensive tasks can execute at idle priorities.
  212.      
  213.      Is self-contained and integrated.
  214.      
  215.      Contains a logging mechanism.  This is very important for unattended 
  216.      operations.  Once again, and easy to overlook, is how the logging is 
  217.      accomplished and should cause no extra overhead.
  218.  
  219. Run one CPU monitor at a time.  Attempting to run multiple CPU monitors at 
  220. the same time defeats the purpose and causes each monitor to absorb the 
  221. other's CPU load.
  222.  
  223. Depending on how robust and feature rich the monitoring software is, the 
  224. software may not be able to guarantee 100% compatibility with future versions 
  225. of the operating system.  Due to the nature of monitoring and the uniqueness 
  226. of the application, most monitoring software requires slight modification per 
  227. operating system release.  Contact the vendor before you migrate to a new 
  228. release of the operating system.  The monitoring software is not usually 
  229. affected by minor OS upgrade versions.
  230.  
  231.  
  232.  
  233. About the Author:
  234. ─────────────────
  235.  
  236. Mr. Wallenberg is a senior consultant with Computer Sciences Corporation and 
  237. specializes in OS/2 and UNIX based systems programming.  Independently he 
  238. develops OS/2 and UNIX system monitoring tools.  His latest creation is PM 
  239. Patrol for OS/2 which provides much of the items discussed in this article.  
  240. Mr. Wallenberg can be contacted via CompuServe (72702,2320) or the Internet 
  241. (72702.2320@CompuServe.COM).
  242.