From owner-freebsd-arm@freebsd.org Thu Jul 2 19:06:18 2020 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 134A735DB6A for ; Thu, 2 Jul 2020 19:06:18 +0000 (UTC) (envelope-from kamalpr@gmail.com) Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ySHY5Hz2z4CQj; Thu, 2 Jul 2020 19:06:17 +0000 (UTC) (envelope-from kamalpr@gmail.com) Received: by mail-io1-xd42.google.com with SMTP id f23so30070397iof.6; Thu, 02 Jul 2020 12:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=Cma6ccFh5HErJjSjfadXByH+agn5cSMTre1dRpvIJmM=; b=s29FSG1lTYObid1VedaFmL9UORC5C7q/sQR6JBqq+0recmotnxieTXCqv5Q1SC6e6G TVYcth0Ppqz0G7bbtUCfnwdU7MLIXwmP2JLVy4HSoyUVIf8dvcfFM+a23Jgwqrz7mOqt VNkJ7mJ5NH/vwccQngkYxj4QZ37XkQEGwxffbXUrCLM8R62gmMObH3Co3IONZAEo4sQ5 qKnFJMyqTRf71D/EaNUB7toKXFTj26NgwP1wcrvMeYnpd7znStdZru8kr8+PcAoC+JmS tMGp0fJPBzRAIYIC5+zvf4UtAIvYZkMM+rp4ROrN3Ww4CBfO+WPJgwl7oAIjJUrmGVZm ltDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=Cma6ccFh5HErJjSjfadXByH+agn5cSMTre1dRpvIJmM=; b=AgmxGVynmKTu9sGIk3gwgCfO1mmIMftn6BYkxiXy+328fq8VM/oKGN/ozohYH6Ksv5 9imz9Mr623r1Q5jNObpvfLgKbgNVYRpRTZSDSdXPnsl0OY14DdKtYDfQdQ9gNAzuZSCz 9fjbm6lbBieRmHcGcZ8vbb0C2v03WJyggIj4jqKnOLmVfrtPMKllKOMuNfaCAAh4jUpa bm6s/ENcbtWIhb3v96rrMXj6qPP+FLSRV0Adn6nwBdvGN1uHtr6Bjkb7w15W4qGoVh0X 8B47f+aAMyHy9QeM8nsYTRm9j6YY9RJvbvblgPd3kmTJLUe7AUd5wLVdZ97+wJh73QaJ BtTw== X-Gm-Message-State: AOAM531JYBkWHhrWP7a0tl64fzqDiP8DqkkgUH78e5fLDAV7yA25U8y9 9Ob3DL+EPI+kT7Ir+PFOflhmh9gApO6xO9LFtXL2LFt6K4Md X-Google-Smtp-Source: ABdhPJzbc8PPjyOKlXfFD+9KE7i/1xwGogSVPynBsK4Qd9XcA8Zw/nTRXs1dfhowkt6xm3wg7GNY1Hxtkj1WnywP3fE= X-Received: by 2002:a6b:7d02:: with SMTP id c2mr8869701ioq.146.1593716776654; Thu, 02 Jul 2020 12:06:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: kamalp@acm.org From: "Kamal R. Prasad" Date: Fri, 3 Jul 2020 00:36:05 +0530 Message-ID: Subject: Re: cv_wait To: Ian Lepore Cc: kamalp@acm.org, freebsd-arm@freebsd.org X-Rspamd-Queue-Id: 49ySHY5Hz2z4CQj X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 19:06:18 -0000 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 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" >