home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MAILBOX.ZIP / MPTSKEX1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-27  |  2.3 KB  |  81 lines

  1. /****************************************************************************/
  2. /* mptskex1.c  -- EXAMPLE OF MAILBOX MULTITASKING    (IMPLEMENTATION)    */
  3. /* Created:  3/27/88        Release:  0.7        Version:  6/13/88   */
  4. /****************************************************************************
  5. (c) Copyright 1987, 1988 by Michael Benjamin Parker     (USA SS# 557-49-4130)
  6.  
  7. All Rights Reserved unless specified in the following include files: */
  8. #include "mptsk.cpy" /*
  9.  
  10. DO NOT REMOVE OR ALTER THIS NOTICE AND ITS PROVISIONS.
  11. ****************************************************************************/
  12. /* OVERVIEW:
  13. This is simple example program to show how the MPTSK cluster (is supposed
  14. to) work.  In addition to the main task, it starts up two other
  15. tasks.  Each task prints a message and temporarily yields control.
  16.  
  17. WARNING:  This code and/or the mptsk.* code has a bug which causes the
  18. program to occasionally hang on a mptsk_xfer call (specifically in the
  19. mpthd_switch().  It will be debugged further.
  20.  
  21. */
  22. /****************************************************************************/
  23. #include <stdio.h>
  24. #include "mptsk.h"
  25. #define    NDEBUG    1
  26. #include "mpbug.h"
  27.  
  28.  
  29. MPTHDID    mptsk_hellofn(MPTHDID mpthd)
  30. {
  31.     for (EVER) {
  32.         printf("\nHello!");
  33.         mpbug_valp(mptsk_mympscd());
  34.         mptsk_yield();
  35.     }
  36. }
  37.  
  38. MPTHDID    mptsk_goodbyefn(MPTHDID mpthd)
  39. {
  40.     for (EVER) {
  41.         printf("\n\t\t\t\tGoodBye!");
  42.         mptsk_yield();
  43.     }
  44. }
  45.  
  46. void    main() {
  47. mpbug_init(2); {
  48.     MPTHD    mpthd_hello[25];
  49.      MPTSK    mptsk_hello[1];
  50.     MPTHD    mpthd_goodbye[25];
  51.     MPTSK    mptsk_goodbye[1];
  52.     printf("\nmptskex1.c  --  Multitasking Example 1\n");
  53.     mpthd_setup();
  54.     mptsk_setup();
  55.     mpbug_lev();mpbug_valp(mpscd_emergencytasks);
  56.     mpbug_lev();mpbug_valp(mptsk_mympscd());
  57.     mptsk_init(mptsk_hello,mpthd_init(mpthd_hello,25*sizeof(MPTHD),mptsk_hellofn),
  58.             mpscd_toptasks());
  59.     mpbug_valp(mpscd_toptasks());
  60.     mpbug_valp(mptsk_mpscd(mptsk_hello));
  61.     mptsk_init(mptsk_goodbye,mpthd_init(mpthd_goodbye,25*sizeof(MPTHD),
  62.             mptsk_goodbyefn),mpscd_toptasks());
  63.     mpbug_valp(mptsk_mpscd(mptsk_goodbye));
  64.     {
  65.         int    count=    4;
  66.         while (count--) {
  67.             printf("\n\t\tTalk,Talk,Talk");
  68.             mptsk_yield();
  69.         }
  70.     }
  71.     mptsk_dinit(mpscd_toptasks());
  72.     mptsk_dinit(mpscd_toptasks());
  73.     printf("\nBye!\n");
  74. }}
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.