

  PROCEDURE [INLINE] tmp$new_set_lock
    (VAR lock: tmt$new_ptl_lock);

    VAR
      b: boolean,
      bc: integer,
      old_traps: 0 .. 3;

    IF osv$cpus_logically_on > 1 THEN
      bc := #read_register (osc$pr_base_constant);
      IF lock.id <> bc THEN

        { Disable traps, the process of setting the lock.locked bit and setting the lock.id can not be
        { interrupted.

        REPEAT
          i#mtr_disable_traps (old_traps);
          #TEST_SET (lock.locked, b);
          IF b THEN
            i#mtr_restore_traps (old_traps);
          IFEND;
        UNTIL NOT b;
        lock.id := bc;
        i#mtr_restore_traps (old_traps);

      ELSE
        lock.count := lock.count + 1;
      IFEND;
    IFEND;

PROCEND tmp$new_set_lock;

?? PUSH (LISTEXT := ON) ??
*copyc i#mtr_disable_traps
*copyc i#mtr_restore_traps
*copyc osc$processor_defined_registers
*copyc osv$cpus_logically_on
*copyc tmt$new_ptl_lock
?? POP ??
