home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xc212os2.zip / ISODEF / coroutin.def < prev    next >
Text File  |  1994-12-28  |  4KB  |  89 lines

  1. <*+ M2EXTENSIONS *>
  2. DEFINITION MODULE COROUTINES;
  3.  
  4. (* Facilities for coroutines and the handling of interrupts *)
  5.  
  6. IMPORT SYSTEM;
  7.  
  8. TYPE
  9.   COROUTINE; (* Values of this type are created dynamically by NEWCOROUTINE
  10.         and identify the coroutine in subsequent operations *)
  11.   INTERRUPTSOURCE = (* implementation-defined *)
  12.       (i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,
  13.      i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,
  14.      i20,i21,i22,i23,i24,i25,i26,i27,i28,i29,
  15.      i30,i31,i32,i33,i34,i35,i36,i37,i38,i39,
  16.      i40,i41,i42,i43,i44,i45,i46,i47,i48,i49,
  17.      i50,i51,i52,i53,i54,i55,i56,i57,i58,i59,
  18.      i60,i61,i62,i63,i64,i65,i66,i67,i68,i69,
  19.      i70,i71,i72,i73,i74,i75,i76,i77,i78,i79,
  20.      i80,i81,i82,i83,i84,i85,i86,i87,i88,i89,
  21.      i90,i91,i92,i93,i94,i95,i96,i97,i98,i99,
  22.        i100,i101,i102,i103,i104,i105,i106,i107,i108,i109,
  23.      i110,i111,i112,i113,i114,i115,i116,i117,i118,i119,
  24.      i120,i121,i122,i123,i124,i125,i126,i127,i128,i129,
  25.      i130,i131,i132,i133,i134,i135,i136,i137,i138,i139,
  26.      i140,i141,i142,i143,i144,i145,i146,i147,i148,i149,
  27.      i150,i151,i152,i153,i154,i155,i156,i157,i158,i159,
  28.      i160,i161,i162,i163,i164,i165,i166,i167,i168,i169,
  29.      i170,i171,i172,i173,i174,i175,i176,i177,i178,i179,
  30.      i180,i181,i182,i183,i184,i185,i186,i187,i188,i189,
  31.      i190,i191,i192,i193,i194,i195,i196,i197,i198,i199,
  32.        i200,i201,i202,i203,i204,i205,i206,i207,i208,i209,
  33.      i210,i211,i212,i213,i214,i215,i216,i217,i218,i219,
  34.      i220,i221,i222,i223,i224,i225,i226,i227,i228,i229,
  35.      i230,i231,i232,i233,i234,i235,i236,i237,i238,i239,
  36.      i240,i241,i242,i243,i244,i245,i246,i247,i248,i249,
  37.      i250,i251,i252,i253,i254,i255);
  38.  
  39. PROCEDURE NEWCOROUTINE (procBody: PROC; workspace: SYSTEM.ADDRESS; size: CARDINAL;
  40.                         VAR cr: COROUTINE;
  41.                         initProtection:=INTERRUPTIBLE: PROTECTION);
  42.   (* Creates a new coroutine whose body is given by procBody, and returns the identity
  43.      of the coroutine in cr.  workspace is a pointer to the work space allocated to
  44.      the coroutine; size specifies the size of this workspace in terms of SYSTEM.LOC.
  45.      initProtection is an optional parameter that specifies the initial protection
  46.      level of the coroutine.
  47.   *)
  48.  
  49. PROCEDURE TRANSFER (VAR from: COROUTINE; to: COROUTINE);
  50.   (* Returns the identity of the calling coroutine in from, and transfers control to
  51.      the coroutine specified by to.
  52.   *)
  53.  
  54. PROCEDURE IOTRANSFER (VAR from: COROUTINE; to: COROUTINE);
  55.   (* Returns the identity of the calling coroutine in from and transfers control to
  56.      the coroutine specified by to.  On occurrence of an interrupt, associated with the
  57.      caller, control is transferred back to the caller, and the identity of the
  58.      interrupted coroutine is returned in from.  The calling coroutine must be
  59.      associated with a source of interrupts.
  60.   *)
  61.  
  62. PROCEDURE ATTACH (source: INTERRUPTSOURCE);
  63.   (* Associates the specified source of interrupts with the calling coroutine. *)
  64.  
  65. PROCEDURE DETACH (source: INTERRUPTSOURCE);
  66.   (* Dissociates the specified source of interrupts from the calling coroutine. *)
  67.  
  68. PROCEDURE IsATTACHED (source: INTERRUPTSOURCE): BOOLEAN;
  69.   (* Returns TRUE if and only if the specified source of interrupts is currently
  70.      associated with a coroutine; otherwise returns FALSE.
  71.   *)
  72.  
  73. PROCEDURE HANDLER (source: INTERRUPTSOURCE): COROUTINE;
  74.   (* Returns the coroutine, if any, that is associated with the source of interrupts.
  75.      The result is undefined if IsATTACHED(source) = FALSE.
  76.   *)
  77.  
  78. PROCEDURE CURRENT (): COROUTINE;
  79.   (* Returns the identity of the calling coroutine. *)
  80.  
  81. PROCEDURE LISTEN (p: PROTECTION);
  82.   (* Momentarily changes the protection of the calling coroutine to p. *)
  83.  
  84. PROCEDURE PROT (): PROTECTION;
  85.   (* Returns the protection of the calling coroutine. *)
  86.  
  87. END COROUTINES.
  88.  
  89.