Print this page
*** NO COMMENTS ***


 239 }
 240 
 241 /*
 242  * =========================================================================
 243  * condition variables
 244  * =========================================================================
 245  */
 246 /*ARGSUSED*/
 247 void
 248 cv_init(kcondvar_t *cv, char *name, int type, void *arg)
 249 {
 250         VERIFY(cond_init(cv, type, NULL) == 0);
 251 }
 252 
 253 void
 254 cv_destroy(kcondvar_t *cv)
 255 {
 256         VERIFY(cond_destroy(cv) == 0);
 257 }
 258 
 259 void
 260 cv_wait(kcondvar_t *cv, kmutex_t *mp)
 261 {
 262         ASSERT(mutex_owner(mp) == curthread);
 263         mp->m_owner = NULL;
 264         int ret = cond_wait(cv, &mp->m_lock);
 265         VERIFY(ret == 0 || ret == EINTR);
 266         mp->m_owner = curthread;







 267 }
 268 
 269 clock_t
 270 cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
 271 {
 272         int error;
 273         timestruc_t ts;
 274         clock_t delta;
 275 
 276 top:
 277         delta = abstime - ddi_get_lbolt();
 278         if (delta <= 0)
 279                 return (-1);
 280 
 281         ts.tv_sec = delta / hz;
 282         ts.tv_nsec = (delta % hz) * (NANOSEC / hz);
 283 
 284         ASSERT(mutex_owner(mp) == curthread);
 285         mp->m_owner = NULL;
 286         error = cond_reltimedwait(cv, &mp->m_lock, &ts);




 239 }
 240 
 241 /*
 242  * =========================================================================
 243  * condition variables
 244  * =========================================================================
 245  */
 246 /*ARGSUSED*/
 247 void
 248 cv_init(kcondvar_t *cv, char *name, int type, void *arg)
 249 {
 250         VERIFY(cond_init(cv, type, NULL) == 0);
 251 }
 252 
 253 void
 254 cv_destroy(kcondvar_t *cv)
 255 {
 256         VERIFY(cond_destroy(cv) == 0);
 257 }
 258 
 259 int
 260 cv_wait_sig(kcondvar_t *cv, kmutex_t *mp)
 261 {
 262         ASSERT(mutex_owner(mp) == curthread);
 263         mp->m_owner = NULL;
 264         int ret = cond_wait(cv, &mp->m_lock);
 265         VERIFY(ret == 0 || ret == EINTR);
 266         mp->m_owner = curthread;
 267         return (ret == EINTR ? 0 : 1);
 268 }
 269 
 270 void
 271 cv_wait(kcondvar_t *cv, kmutex_t *mp)
 272 {
 273         (void) cv_wait_sig(cv, mp);
 274 }
 275 
 276 clock_t
 277 cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
 278 {
 279         int error;
 280         timestruc_t ts;
 281         clock_t delta;
 282 
 283 top:
 284         delta = abstime - ddi_get_lbolt();
 285         if (delta <= 0)
 286                 return (-1);
 287 
 288         ts.tv_sec = delta / hz;
 289         ts.tv_nsec = (delta % hz) * (NANOSEC / hz);
 290 
 291         ASSERT(mutex_owner(mp) == curthread);
 292         mp->m_owner = NULL;
 293         error = cond_reltimedwait(cv, &mp->m_lock, &ts);