 PROCEDURE [INLINE] osp$set_locked_variable (VAR variable: integer;
        initial: integer;
        final: integer;
    VAR actual: integer;
    VAR succeeded: boolean);
{
{   The purpose of this procedure is to set a compare_swap lock
{  when the user knows the initial contents of the lock.
{  This procedure has been generated to help users avoid problems
{  with #compare_swap.
{  CAUTION: Variables referenced by this procedure may not be
{  referenced (read or written) any way other than by the
{  following procedures:
{                             osp$increment_locked_variable
{                             osp$decrement_locked_variable
{                             osp$fetch_locked_variable
{        and the intrinsic    #compare_swap.
{
{     OSP$SET_LOCKED_VARIABLE (VARIABLE, INITIAL, FINAL, ACTUAL, SUCCEEDED)
{
{  VARIABLE: (input,output) This parameter is the variable on which the
{                     compare_swap operation is to be performed.
{  INITIAL: (input) This parameter is the value that the variable must contain
{                     initial content of the lock must be for the swap
{                     operation to be successful.
{  FINAL: (input) This parameter is the variable that specifies the value to be
{                     stored in the lock if the swap is successful.
{  ACTUAL: (output) This parameter is the variable into which the initial
{                     contents of the lock is returned.
{  SUCCEEDED: (output) This parameter specifies whether the swap was successful
{                     or not.
{

?? PUSH (LISTEXT := ON) ??

    VAR
      result: 0 .. 2;

    succeeded := FALSE;
    REPEAT
      #compare_swap (variable, initial, final, actual, result);
    UNTIL result <> 2;
    IF result = 0 THEN
      actual := final;
      succeeded := TRUE;
    IFEND;
  PROCEND osp$set_locked_variable;
?? POP ??
