/* this ensures we copy sel before releasing the lock below */
rmb();
/* release the lock by setting tty of the struct to NULL */
tty = xchg(&ssw->tty, NULL);
if (spk_sel_cons != vc_cons[fg_console].d) {
spk_sel_cons = vc_cons[fg_console].d;
pr_warn("Selection: mark console not the same as cut\n"); goto unref;
}
int speakup_set_selection(struct tty_struct *tty)
{ /* we get kref here first in order to avoid a subtle race when * cancelling selection work. getting kref first establishes the * invariant that if speakup_sel_work.tty is not NULL when * speakup_cancel_selection() is called, it must be the case that a put * kref is pending.
*/
tty_kref_get(tty); if (cmpxchg(&speakup_sel_work.tty, NULL, tty)) {
tty_kref_put(tty); return -EBUSY;
} /* now we have the 'lock' by setting tty member of * speakup_selection_work. wmb() ensures that writes to * speakup_sel_work don't happen before cmpxchg() above.
*/
wmb();
cancel_work_sync(&speakup_sel_work.work); /* setting to null so that if work fails to run and we cancel it, * we can run it again without getting EBUSY forever from there on. * we need to use xchg here to avoid race with speakup_set_selection()
*/
tty = xchg(&speakup_sel_work.tty, NULL); if (tty)
tty_kref_put(tty);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.