home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / multitask / READ.ME < prev    next >
Encoding:
Text File  |  1996-12-24  |  2.7 KB  |  94 lines

  1. Copyright (c) 1993 SAS Institute, Cary, NC USA
  2. All Rights Reserved
  3.  
  4. This example demonstrates how to create a multitasking
  5. program, and how to use CPR to debug it. 
  6.  
  7. The example program starts a new process that executes
  8. in the same code hunk as the parent process. This is the
  9. simplest type of multitasking program to debug, because
  10. CPR has all the debugging information for both tasks when
  11. the parent process starts.
  12.  
  13. Another type of multitasking situtation is demonstrated in 
  14. the "example_device" example. In that example, a driver program
  15. calls OpenDevice(), which loads the device, and starts a new task
  16. running in a seperate code hunk from the original program.
  17.  
  18.  
  19. This example contains an Enforcer Hit in one function that
  20. will be executed as the child process. Listed below are 
  21. instructions for finding the hit.
  22.  
  23. To compile the example, double click on the Build Icon.
  24.  
  25. Example 1. How to find an Enforcer hit in a child process.
  26.  
  27. 1) Start Enforcer. You need a machine with an MMU to run enforcer.
  28.    If you don't have an MMU, move to Example 2.
  29.  
  30. 2) Start CPR in the TEST program.
  31.      cpr test
  32.  
  33. 3) Turn on catching new tasks.
  34.      opt catch on
  35.      
  36. 4) Run the program. CPR will stop at the Enforcer Hit.
  37.      go
  38.      
  39. 5) CPR should have stopped in the function process1(). You
  40.    can now list the processes under CPR's control.
  41.      tasks
  42.      
  43. 6) Turn off catching of new tasks. The next line does an Open()
  44.    on CON: which starts a new task. You don't want CPR to catch
  45.    that task. 
  46.      opt catch off
  47.      
  48. 7) Now let the program run to completion.
  49.      go
  50.  
  51.  
  52. Note: Putting harmless enforcer hits (like the one in this example)
  53.       in your program is a good trick to aid in debugging 
  54.       multitasking programs.
  55.  
  56.  
  57. Example 2. How to debug a child process.
  58.  
  59. 1) Start CPR in the TEST program.
  60.      cpr test
  61.  
  62. 2) Turn on catching new tasks.
  63.      opt catch on
  64.      
  65. 3) Set a breakpoint at the function that will be executed
  66.    as part of the child process.
  67.      break process1
  68.  
  69. 4) Run the program. CPR will stop at the Enforcer Hit.
  70.      go
  71.      
  72. 5) CPR should have stopped in the function process1(). You
  73.    can now list the processes under CPR's control.
  74.      tasks
  75.      
  76. 6) Turn off catching of new tasks. The next line does an Open()
  77.    on CON: which starts a new task. You don't want CPR to catch
  78.    that task. 
  79.      opt catch off
  80.      
  81. 7) Now let the program run to completion.
  82.      go
  83.      
  84.  
  85. Other Hints.
  86.  
  87. Whenever you do a GO, all tasks under CPR's control are run. Whenever
  88. any task hits a breakpoint or enforcer hit, all tasks are suspended.
  89.  
  90. You can switch between tasks with the OPT TASK command. If you switch
  91. to a task and you don't seem to have debugging information, most likely
  92. the task is in an OS routine (probably Wait()).
  93.  
  94.