Date: Fri, 3 Jul 2020 00:36:05 +0530 From: "Kamal R. Prasad" <kamalpr@gmail.com> To: Ian Lepore <ian@freebsd.org> Cc: kamalp@acm.org, freebsd-arm@freebsd.org Subject: Re: cv_wait Message-ID: <CAK=yUGLvZ7uM=pTNrODnTgw6NStT4gHExsTDkrYTP_rQBV1C-A@mail.gmail.com> In-Reply-To: <ef01153a05887b10a443c71cb42aff6180ae7f8f.camel@freebsd.org> References: <CAK=yUGLoM1YWX5yxsboKqaCMr2jKGgtJ0a-CVVsfeEO3SpsYLQ@mail.gmail.com> <ef01153a05887b10a443c71cb42aff6180ae7f8f.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
but if i am doing cv_wait() for the first time, should someone be calling cv_signal for it to proceed? my algo is something like this in my driver:- function1() { mtx_lock(&sc->sc_mtx); cv_wait(&sc->sc_cv); mtx_unlock(&sc->sc_mtx); .... critical section .... cv_signal(&sc->sc_cv); } function2() { mtx_lock(&sc->sc_mtx); cv_wait(&sc->sc_cv); mtx_unlock(&sc->sc_mtx); .... critical section .... cv_signal(&sc->sc_cv); } --------------------- i want to protect critical section. The critical section calls a common piece of code which has some locks. if i put in locks to guard the cs, it triggers a call to witness(). Update: i saw an implementation wherein they used a callout to periodically send a cv_signal(). i could do that but the pt of this implementation is that cs in either of these functions should not be eecuting at the same time. thanks -kamal On Thu, Jul 2, 2020 at 10:29 PM Ian Lepore <ian@freebsd.org> wrote: > On Thu, 2020-07-02 at 21:48 +0530, Kamal R. Prasad wrote: > > hello, > > > > i have written a piece of code in a freebsd driver meant for arm. The > > first > > cv_wait(&sc->sc_cv, &sc->sc_mtx); > > keeps waiting indefinitely. If I use cv_timedwait() instead, it > > returns > > > > EWOULDBLOCK > > > > > > does someone know why this is happening? > > > > > > thanks > > > > -kamal > > > > That would imply that nothing is ever calling cv_signal(&sc->sc_cv) or > cv_broadcast(&sc->sc_cv). > > -- Ian > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAK=yUGLvZ7uM=pTNrODnTgw6NStT4gHExsTDkrYTP_rQBV1C-A>