?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE: Binary Name Management' ??
MODULE osm$unique_name_management;

{ Purpose: The purpose of this module is to generate binary unique names.
{          Binary unique names are unique and can only occur once.

{ Design:  Binary unique names contain an identification of a processor ( model/serial) and
{          the date and time that they are created - down to the microsecond.

?? NEWTITLE := '    Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc ost$binary_unique_name
*copyc ost$date_time
*copyc ost$free_running_clock
*copyc ost$processor_element_id
*copyc ost$status
?? POP ??
*copyc pmp$get_binary_processor_id
*copyc pmp$get_date_time_at_timestamp
?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] osp$generate_unique_binary_name', EJECT ??
*copyc osh$generate_unique_binary_name

  PROCEDURE [XDCL, #GATE] osp$generate_unique_binary_name
    (VAR name: ost$binary_unique_name;
     VAR status: ost$status);

    VAR
      processor_element_id: ost$processor_element_id,
      free_running_clock: ost$free_running_clock,
      free_running_clock_modulus: integer,
      universal_time: ost$date_time;

{ Free_running_clock_modulus is used to take the least_significant bits of the
{ free_running_clock and place them into the binary unique name as the sequence.
{ The sequence represents the microsecond and millisecond time of day.

    free_running_clock_modulus := UPPERVALUE (name.sequence_number) + 1;

    pmp$get_binary_processor_id (processor_element_id, status); {sets status always normal

    name.serial_number := processor_element_id.serial_number;
    name.model_number := processor_element_id.model_number;

    free_running_clock := #FREE_RUNNING_CLOCK (0);

    pmp$get_date_time_at_timestamp (free_running_clock, pmc$use_universal_time, universal_time, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    name.year := universal_time.year + 1900;
    name.month := universal_time.month;
    name.day := universal_time.day;
    name.hour := universal_time.hour;
    name.minute := universal_time.minute;
    name.second := universal_time.second;
    name.sequence_number := free_running_clock MOD free_running_clock_modulus;
    name.fill := 0;

  PROCEND osp$generate_unique_binary_name;
?? OLDTITLE ??
MODEND osm$unique_name_management;

