/* BEGINNING OF:  mrds_space_allocate.incl.pl1   * * * * * * * * * * * * * * */

/* HISTORY:

   Created by:  Thanh Nguyen      01/15/85

 */


mrds_space_allocate:   proc (mrds_area_ptr, requested_word_size) returns (ptr);

/* This function "allocates" the requested space in the temporary segment, if
   the segment is "mrds area".  The space of allocation will not be free.  If 
   the area is full, this function returns a null pointer.  And the user has to
   call mrds_area_initialize to reset the temporary segment back to the 
   beginning.  So, we never have the overflow on the area and the CPU 
   processing time for this allocation is low.  If the segment is not a
   "mrds area", this function does a standard PL/I allocate.
 */

          dcl     mrds_area_ptr           ptr;       /* ptr to the temporary segment. (INPUT) */
          dcl     requested_word_size     fixed bin (35); /* number of words to be allocated. (INPUT) */

          dcl     actual_allocated_size   fixed bin (35); /* number of words to be allocated, rounded up to a 0 + mod 2 quantity. */
	dcl     MRDS_AREA               char (8) init ("MRDSAREA");
          dcl     (mod, null, ptr)        builtin;

          dcl     1 mrds_area             based (mrds_area_ptr),
		2 area_id             char (8),
		2 offset_to_free_word fixed bin (35), /* offset to the next free word in temp seg.  */
		2 length_free_space   fixed bin (35); /* length of remaining free space in temp seg.*/

	dcl     p_work_area             area (sys_info$max_seg_size) based (mrds_area_ptr);
	dcl     alloc_value_ptr         ptr;
	dcl     alloc_value             (actual_allocated_size) bit (36) based (alloc_value_ptr);


	/* round up to even word boundary. */
	actual_allocated_size = requested_word_size + mod (requested_word_size, 2);
	if mrds_area_ptr = null then return (null);
	else if mrds_area.area_id ^= MRDS_AREA then do;
	     /* must be a standard PL/I area. */
	     allocate alloc_value set (alloc_value_ptr) in (p_work_area);
	     return (alloc_value_ptr);
	end;
	else if actual_allocated_size <= length_free_space then do;
	     /* get pointer to next free word of area.  */
	     alloc_value_ptr = ptr (mrds_area_ptr, mrds_area.offset_to_free_word);
	     /* increase offset of remaining free space */
	     mrds_area.offset_to_free_word = mrds_area.offset_to_free_word + actual_allocated_size;
	     /* decrease length of remaining free space */
	     mrds_area.length_free_space = mrds_area.length_free_space - actual_allocated_size;
	     return (alloc_value_ptr);
	end;
	else return (null);


end mrds_space_allocate;

/* END OF:     mrds_space_allocate.incl.pl1  * * * * * * * * * * * * * * * * */


*/
                                          -----------------------------------------------------------


Historical Background

This edition of the Multics software materials and documentation is provided and donated
to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. 
as a contribution to computer science knowledge.  
This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology,
Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull
and Bull HN Information Systems Inc. to the development of this operating system. 
Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970),
renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership
of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for 
managing computer hardware properly and for executing programs. Many subsequent operating systems 
incorporated Multics principles.
Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., 
as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. .

                                          -----------------------------------------------------------

Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without
fee is hereby granted,provided that the below copyright notice and historical background appear in all copies
and that both the copyright notice and historical background and this permission notice appear in supporting
documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining
to distribution of the programs without specific prior written permission.
    Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc.
    Copyright 2006 by Bull HN Information Systems Inc.
    Copyright 2006 by Bull SAS
    All Rights Reserved

*/
