mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 09:55:19 +02:00
UPSTREAM: rust: sync: Makes CondVar::wait()
an uninterruptible wait
Currently, `CondVar::wait()` is an interruptible wait, and this is
different than `wait_event()` in include/linux/wait.h (which is an
uninterruptible wait). To avoid confusion between different APIs on the
interruptible/uninterruptible, make `CondVar::wait()` an uninterruptible
wait same as `wait_event()`, also rename the old `wait()` to
`CondVar::wait_interruptible()`.
Spotted-by: Tiago Lam <tiagolam@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Tiago Lam <tiagolam@gmail.com>
Link: https://lore.kernel.org/r/20231214200421.690629-1-boqun.feng@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
[ Upstream commit 0a7f5ba73e
]
Change-Id: I79b6f6b1aec24cd7ec46f097683d4177c2190db8
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
parent
5e2edfbc03
commit
0f40dd3c65
|
@ -50,7 +50,7 @@ macro_rules! new_condvar {
|
||||||
/// fn wait_for_value(e: &Example, v: u32) {
|
/// fn wait_for_value(e: &Example, v: u32) {
|
||||||
/// let mut guard = e.value.lock();
|
/// let mut guard = e.value.lock();
|
||||||
/// while *guard != v {
|
/// while *guard != v {
|
||||||
/// e.value_changed.wait_uninterruptible(&mut guard);
|
/// e.value_changed.wait(&mut guard);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -120,26 +120,26 @@ impl CondVar {
|
||||||
unsafe { bindings::finish_wait(self.wait_list.get(), wait.get()) };
|
unsafe { bindings::finish_wait(self.wait_list.get(), wait.get()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases the lock and waits for a notification in interruptible mode.
|
/// Releases the lock and waits for a notification in uninterruptible mode.
|
||||||
///
|
///
|
||||||
/// Atomically releases the given lock (whose ownership is proven by the guard) and puts the
|
/// Atomically releases the given lock (whose ownership is proven by the guard) and puts the
|
||||||
/// thread to sleep, reacquiring the lock on wake up. It wakes up when notified by
|
/// thread to sleep, reacquiring the lock on wake up. It wakes up when notified by
|
||||||
/// [`CondVar::notify_one`] or [`CondVar::notify_all`], or when the thread receives a signal.
|
/// [`CondVar::notify_one`] or [`CondVar::notify_all`]. Note that it may also wake up
|
||||||
/// It may also wake up spuriously.
|
/// spuriously.
|
||||||
///
|
pub fn wait<T: ?Sized, B: Backend>(&self, guard: &mut Guard<'_, T, B>) {
|
||||||
/// Returns whether there is a signal pending.
|
self.wait_internal(bindings::TASK_UNINTERRUPTIBLE, guard);
|
||||||
#[must_use = "wait returns if a signal is pending, so the caller must check the return value"]
|
|
||||||
pub fn wait<T: ?Sized, B: Backend>(&self, guard: &mut Guard<'_, T, B>) -> bool {
|
|
||||||
self.wait_internal(bindings::TASK_INTERRUPTIBLE, guard);
|
|
||||||
crate::current!().signal_pending()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases the lock and waits for a notification in uninterruptible mode.
|
/// Releases the lock and waits for a notification in interruptible mode.
|
||||||
///
|
///
|
||||||
/// Similar to [`CondVar::wait`], except that the wait is not interruptible. That is, the
|
/// Similar to [`CondVar::wait`], except that the wait is interruptible. That is, the thread may
|
||||||
/// thread won't wake up due to signals. It may, however, wake up supirously.
|
/// wake up due to signals. It may also wake up spuriously.
|
||||||
pub fn wait_uninterruptible<T: ?Sized, B: Backend>(&self, guard: &mut Guard<'_, T, B>) {
|
///
|
||||||
self.wait_internal(bindings::TASK_UNINTERRUPTIBLE, guard)
|
/// Returns whether there is a signal pending.
|
||||||
|
#[must_use = "wait_interruptible returns if a signal is pending, so the caller must check the return value"]
|
||||||
|
pub fn wait_interruptible<T: ?Sized, B: Backend>(&self, guard: &mut Guard<'_, T, B>) -> bool {
|
||||||
|
self.wait_internal(bindings::TASK_INTERRUPTIBLE, guard);
|
||||||
|
crate::current!().signal_pending()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calls the kernel function to notify the appropriate number of threads with the given flags.
|
/// Calls the kernel function to notify the appropriate number of threads with the given flags.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user