PETSc version 3.17.0
Fix/Edit manual page

# VecLockWriteSet_Private

Lock or unlock a vector for exclusive read/write access

### Synopsis

    #include "petscvec.h"
    PetscErrorCode VecLockWriteSet_Private(Vec x,PetscBool flg)

Logically Collective on Vec

### Input Parameters

| x | - the vector
| flg | - PETSC_TRUE to lock the vector for writing; PETSC_FALSE to unlock it.

### Notes

The function is usefull in split-phase computations, which usually have a begin phase and an end phase. One can call VecLockWriteSet_Private(x,PETSC_TRUE) in the begin phase to lock a vector for exclusive access, and call VecLockWriteSet_Private(x,PETSC_FALSE) in the end phase to unlock the vector from exclusive access. In this way, one is ensured no other operations can access the vector in between. The code may like

VecGetArray(x,&xdata); // begin phase VecLockWriteSet_Private(v,PETSC_TRUE);

Other operations, which can not acceess x anymore (they can access xdata, of course)

VecRestoreArray(x,&vdata); // end phase VecLockWriteSet_Private(v,PETSC_FALSE);

The call can not be nested on the same vector, in other words, one can not call VecLockWriteSet_Private(x,PETSC_TRUE) again before calling VecLockWriteSet_Private(v,PETSC_FALSE).

### See Also

VecRestoreArray(), VecGetArrayRead(), VecLockReadPush(), VecLockReadPop(), VecLockGet()

### Level

beginner

### Location

src/vec/vec/interface/rvector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages