home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* mptskex1.c -- EXAMPLE OF MAILBOX MULTITASKING (IMPLEMENTATION) */
- /* Created: 3/27/88 Release: 0.7 Version: 6/13/88 */
- /****************************************************************************
- (c) Copyright 1987, 1988 by Michael Benjamin Parker (USA SS# 557-49-4130)
-
- All Rights Reserved unless specified in the following include files: */
- #include "mptsk.cpy" /*
-
- DO NOT REMOVE OR ALTER THIS NOTICE AND ITS PROVISIONS.
- ****************************************************************************/
- /* OVERVIEW:
- This is simple example program to show how the MPTSK cluster (is supposed
- to) work. In addition to the main task, it starts up two other
- tasks. Each task prints a message and temporarily yields control.
-
- WARNING: This code and/or the mptsk.* code has a bug which causes the
- program to occasionally hang on a mptsk_xfer call (specifically in the
- mpthd_switch(). It will be debugged further.
-
- */
- /****************************************************************************/
- #include <stdio.h>
- #include "mptsk.h"
- #define NDEBUG 1
- #include "mpbug.h"
-
-
- MPTHDID mptsk_hellofn(MPTHDID mpthd)
- {
- for (EVER) {
- printf("\nHello!");
- mpbug_valp(mptsk_mympscd());
- mptsk_yield();
- }
- }
-
- MPTHDID mptsk_goodbyefn(MPTHDID mpthd)
- {
- for (EVER) {
- printf("\n\t\t\t\tGoodBye!");
- mptsk_yield();
- }
- }
-
- void main() {
- mpbug_init(2); {
- MPTHD mpthd_hello[25];
- MPTSK mptsk_hello[1];
- MPTHD mpthd_goodbye[25];
- MPTSK mptsk_goodbye[1];
- printf("\nmptskex1.c -- Multitasking Example 1\n");
- mpthd_setup();
- mptsk_setup();
- mpbug_lev();mpbug_valp(mpscd_emergencytasks);
- mpbug_lev();mpbug_valp(mptsk_mympscd());
- mptsk_init(mptsk_hello,mpthd_init(mpthd_hello,25*sizeof(MPTHD),mptsk_hellofn),
- mpscd_toptasks());
- mpbug_valp(mpscd_toptasks());
- mpbug_valp(mptsk_mpscd(mptsk_hello));
- mptsk_init(mptsk_goodbye,mpthd_init(mpthd_goodbye,25*sizeof(MPTHD),
- mptsk_goodbyefn),mpscd_toptasks());
- mpbug_valp(mptsk_mpscd(mptsk_goodbye));
- {
- int count= 4;
- while (count--) {
- printf("\n\t\tTalk,Talk,Talk");
- mptsk_yield();
- }
- }
- mptsk_dinit(mpscd_toptasks());
- mptsk_dinit(mpscd_toptasks());
- printf("\nBye!\n");
- }}
-
-
-
-
-
-