home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 1.ddi / SUPP.LIF / CRPORT.PLM < prev    next >
Encoding:
Text File  |  1992-07-06  |  5.0 KB  |  137 lines

  1. $title('crport - create a port and attach a buffer pool to it')
  2. $compact
  3. crport: DO;
  4.  
  5. $include(:rmx:inc/rmxplm.ext)
  6. $include(:rmx:inc/error.lit)
  7. $include(dcom.lit)
  8. $include(err.ext)
  9.  
  10. DECLARE
  11.  
  12.         NOEXCEPT   LITERALLY   '0';       /* no exception handling by system */
  13.  
  14. $eject
  15. $subtitle('create$buf$pool')
  16. /********************************************************************
  17.  *
  18.  *     PROC NAME: create$buf$pool    
  19.  *
  20.  *     DESCRIPTION: Create a buffer pool with the attributes passed by the caller.
  21.  *                  Create an initial number of 1K  buffers and release them to the 
  22.  *                  buffer pool.  Return a token for the buffer pool to the caller.  
  23.  *
  24.  *     CALL: buf$pool$tok = create$buf$pool(max_bufs, init_num_bufs,
  25.  *                                                     attrs, status_ptr);    
  26.  *     INPUTS:      max_bufs - maximum number of buffers for buffer pool
  27.  *                init_num_bufs - initial number of buffers for buffer
  28.  *                pool.
  29.  *                attrs - buffer pool creation attributes
  30.  *                status_ptr - points to a status word
  31.  *
  32.  *     RETURNS:  buf$pool$tok - token for newly created buffer pool
  33.  *
  34.  *********************************************************************/
  35.  
  36. create$buf$pool: PROCEDURE(max_bufs, init_num_bufs, attrs, status_ptr) TOKEN PUBLIC;
  37.  
  38.     DECLARE            /* Parameters */
  39.  
  40.         max_bufs        WORD,       /* maximum number of buffers in buffer pool */
  41.         init_num_bufs   WORD,       /* initial number of buffers in pool */
  42.         attrs           WORD,       /* buffer pool creation attributes */
  43.         status_ptr      POINTER;    /* exception pointer */
  44.                      
  45.     DECLARE            /* Local Variables */
  46.  
  47.         status      BASED status_ptr WORD ,
  48.         buf_pool                     TOKEN,  /* buffer pool complete with buffers */
  49.         buf_tok                      TOKEN,  /* buffer token */
  50.         i                            WORD;   /* local index */
  51.  
  52.     DECLARE            /* Literals */
  53.  
  54.         BUFSIZE     LITERALLY   '1026',     /* buffer size - must be at least 
  55.                                                (max_num_chain_elements * 8) + 2 */    
  56.         BFLAGS      LITERALLY   '010B';     /* single buffer, don't release */
  57.  
  58.     buf_pool = rq$create$buffer$pool(max_bufs, attrs, status_ptr);
  59.     CALL error$check(10, status);
  60.     DO i = 1 to init_num_bufs;
  61.         buf_tok = rq$create$segment(BUFSIZE, status_ptr);
  62.         CALL error$check(20, status);
  63.         CALL rq$release$buffer(buf_pool, buf_tok, BFLAGS, status_ptr);
  64.         CALL error$check(30, status);
  65.     END;
  66.     RETURN buf_pool;
  67.  
  68. END create$buf$pool;
  69.  
  70. $eject
  71. $subtitle('get$dport')
  72. /********************************************************************
  73.  *
  74.  *     PROC NAME: get$dport    
  75.  *
  76.  *     DESCRIPTION: This procedure creates a port for data transport service.
  77.  *                  A buffer pool is created and attached to the port.
  78.  *                  A token for the newly created port and buffer pool are
  79.  *                  returned to the caller.
  80.  *
  81.  *     CALL: dport$tok = get$dport(port_num,buf_pool_ptr, b_attrs,
  82.  *                          status_ptr) 
  83.  *
  84.  *     INPUTS:   port_num - port number assigned to newly created port
  85.  *               b_attrs - buffer pool creation attributes
  86.  *               status_ptr - points to status word                
  87.  *     OUTPUTS:  buf_pool_ptr - points to buffer pool token attached to
  88.  *                           the newly created port
  89.  *     RETURNS:  dport$tok - token to newly created port
  90.  *              
  91.  *********************************************************************/
  92.  
  93. get$dport: PROCEDURE(port_num, buf_pool_ptr,b_attrs, status_ptr) TOKEN PUBLIC;
  94.  
  95.     DECLARE        /* Parameters */
  96.  
  97.         port_num        WORD,            /* port id for new port */
  98.         buf_pool_ptr    POINTER,         /* points to buffer pool */
  99.         b_attrs         WORD,            /* buffer pool creation attributes */
  100.         status_ptr      POINTER;    
  101.  
  102.     DECLARE        /* Literals */
  103.  
  104.         NUM_TRANS   LITERALLY   '10',    /* max number outstanding trans at port */
  105.         DATACOM     LITERALLY   '2',     /* indicates data com port */
  106.         PFLAGS      LITERALLY   '0',     /* fifo, fragmentation flags */
  107.         MAXBUFS     LITERALLY   '30',    /* maximum # buffers in pool */
  108.         INITBUFS    LITERALLY   '10';    /* initial number of buffers */
  109.             
  110.     DECLARE        /* locals */
  111.  
  112.         bpool BASED buf_pool_ptr TOKEN,    
  113.         port_t                   TOKEN,       /* local port */
  114.         bufpool_t                TOKEN,       /* buffer pool with initial alloc of buffers */     
  115.         port_info                port_info_s,
  116.         loc_status               WORD,        /* local status word */
  117.         status  BASED status_ptr WORD;                                                
  118.  
  119.                 /* Begin get$dport */
  120.  
  121.         port_info.port_id = port_num;
  122.         port_info.type = DATACOM;
  123.         port_info.reserved = 0;
  124.         port_info.flags = PFLAGS;    
  125.         port_t = rq$create$port(NUM_TRANS, @port_info, status_ptr);
  126.         CALL error$check(40, status);
  127.         bufpool_t = create$buf$pool(MAXBUFS, INITBUFS, b_attrs, status_ptr);
  128.         CALL error$check(50, status);
  129.         bpool = bufpool_t;    
  130.         CALL rq$attach$buffer$pool(bufpool_t, port_t, status_ptr);    
  131.         CALL error$check(60, status);
  132.         RETURN port_t;
  133.  
  134. END get$dport;    
  135.  
  136. END crport;
  137.