version 1.19, 2017/11/13 09:09:28 |
version 1.19.4.2, 2020/04/08 14:07:22 |
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
.\" POSSIBILITY OF SUCH DAMAGE. |
.\" POSSIBILITY OF SUCH DAMAGE. |
.\" |
.\" |
.Dd November 12, 2017 |
.Dd December 12, 2019 |
.Dt CONDVAR 9 |
.Dt CONDVAR 9 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
Line 144 as available until the calling LWP has b |
|
Line 144 as available until the calling LWP has b |
|
.Pp |
.Pp |
Non-interruptable waits have the potential to deadlock the system, and so must |
Non-interruptable waits have the potential to deadlock the system, and so must |
be kept short (typically, under one second). |
be kept short (typically, under one second). |
|
.Pp |
|
Upon being awakened, the calling LWP should verify the availability |
|
of the resource (or other condition). |
|
It should not blindly assume that the resource is now available. |
|
If the resource is still not available, the calling LWP may call |
|
.Fn cv_wait |
|
again to continue waiting. |
.It Fn cv_wait_sig "cv" "mtx" |
.It Fn cv_wait_sig "cv" "mtx" |
.Pp |
.Pp |
As per |
As per |
Line 263 be called while holding the interlocking |
|
Line 270 be called while holding the interlocking |
|
.Fn cv_wait . |
.Fn cv_wait . |
.El |
.El |
.Sh EXAMPLES |
.Sh EXAMPLES |
.Bd -literal |
|
Consuming a resource: |
Consuming a resource: |
|
.Bd -literal |
/* |
/* |
* Lock the resource. Its mutex will also serve as the |
* Lock the resource. Its mutex will also serve as the |
* interlock. |
* interlock. |
Line 298 Consuming a resource: |
|
Line 304 Consuming a resource: |
|
res->state = BUSY; |
res->state = BUSY; |
mutex_exit(&res->mutex); |
mutex_exit(&res->mutex); |
consume(res); |
consume(res); |
|
.Ed |
|
.Pp |
Releasing a resource for the next consumer to use: |
Releasing a resource for the next consumer to use: |
|
.Bd -literal |
mutex_enter(&res->mutex); |
mutex_enter(&res->mutex); |
res->state = IDLE; |
res->state = IDLE; |
cv_signal(&res->condvar); |
cv_signal(&res->condvar); |