On Saturday 06 April 2002 04:48 am, Rusty Russell wrote:
> In message <20020404162751.B0A253FE06@smtp.linux.ibm.com> you write:
Enclosed is an "asynchronous" extension to futexes.
This mechanism is required to implement global locks in the presence of an
M:N threading package.
Here "N" denotes a set of kernel threads, that serve as virtual processors on
which the M user threads can be dispatched by the user level thread
manager/scheduler.
Under no circumstances can one block the kernel threads through the futex
interface. Instead, I want to indicate to the futex-subsystem, that I want a
notification for a particular futex, when its woken up.
Working with some M:N threading folks we came up with the following design
implemented in the attached patch to Rusty's previously posted futex
generalization patch. I can also provide a integrated patch over 2.5.7
vanilla.
The futex_q structure is extended to hold a <tgid>, the <uaddr> of the futex
and a signal with which to notify a caller.
We now provide a FUTEX_AWAIT call which attaches a futex_q object to the wait
queue, similar the FUTEX_WAIT. Differences are as follows.
(a) futex_q must be dynamically allocated in the AWAIT case, instead of on
the stack. We use the tgid to identify <async> vs. <sync> == 0.
(b) there will be no blocking in the kernel and hence we don't release the
page upon return from this AWAIT call.
(c) Upon wakeup, if the futex_q is an async wait (tgid != 0) we move it to a
global notification queue and signal the <tgid> with the specified signal.
We release the page (put_page) at this point.
If the <tgid> doesn't exist (e.g. died), we delete futex_q and signal the
next.
(d) A FUTEX_AWAKERS call is provided to the application to retrieve waiting
notifications, typically called within the signal handler.
We need a cleanup mechanism for the notification queue, when a process dies
prematurely before it had a chance to get their items out of the queue.
For this I introduced _exit_futex(task) to be called from do_exit().
It simply wakes the notifcation queue and deletes everything that is
associated with its pid. Right now that is done for each exiting task.
In general one might want to think about a flag indicating whether this
callback is necessary.
For easier reading I also attach the futex.c program.
Comments.
-- -- Hubertus Franke (frankeh@watson.ibm.com) --------------Boundary-00=_61WCC6Y813RGKY6NFQTQ Content-Type: text/x-diff; charset="iso-8859-1"; name="patch_afutex_gen" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="patch_afutex_gen"ZGlmZiAtdXJiTiBsaW51eC0yLjUuNy1mdXRleC9pbmNsdWRlL2xpbnV4L2Z1dGV4L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VEVUxFX1RJTUVPVVQ7CisJdW5zaWduZWQgbG9uZyB0aW1lOwogCisJLyogZmlyc3Qg aGFuZGxlIHRoZSBzcGVjaWFsIGNhc2UgY29tbWFuZHMgKi8KKwlpZiAob3AgPT0gRlVURVhfQVdB S0VSUykgeworCQlyZXR1cm4gZnV0ZXhfYXdhaXRlcnMoKHZvaWQqKil1YWRkciwgdmFsKTsKKwl9 CisKKworCXRpbWUgPSBNQVhfU0NIRURVTEVfVElNRU9VVDsKIAlpZiAodXRpbWUpIHsKIAkJc3Ry dWN0IHRpbWVzcGVjIHQ7CiAJCWlmIChjb3B5X2Zyb21fdXNlcigmdCwgdXRpbWUsIHNpemVvZih0 KSkgIT0gMCkKQEAgLTIxMiwxMSArMzUxLDE3IEBACiAJY2FzZSBGVVRFWF9XQUtFOgogCQlyZXQg PSBmdXRleF93YWtlKGhlYWQsIHBhZ2UsIHBvc19pbl9wYWdlLCB2YWwpOwogCQlicmVhazsKKwlj YXNlIEZVVEVYX0FXQUlUOgorCQlyZXQgPSBmdXRleF9hd2FpdChoZWFkLCBwYWdlLCBwb3NfaW5f cGFnZSwgdmFsLCB1YWRkciwgKGludCl1dGltZSk7CisJCWlmICghcmV0KSAKKwkJCWdvdG8gb3V0 IDsgIC8qIGRvbid0IHJlbGVhc2UgdGhlIHBhZ2UgKi8KKwkJYnJlYWs7CiAJZGVmYXVsdDoKIAkJ cmV0ID0gLUVJTlZBTDsKIAl9CiAJcHV0X3BhZ2UocGFnZSk7CiAKK291dDoKIAlyZXR1cm4gcmV0 OwogfQogCg==
--------------Boundary-00=_61WCC6Y813RGKY6NFQTQ Content-Type: text/x-c; charset="iso-8859-1"; name="futex.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="futex.c"
LyoKICogIEZhc3QgVXNlcnNwYWNlIE11dGV4ZXMgKHdoaWNoIEkgY2FsbCAiRnV0ZXhlcyEiKS4K ICogIChDKSBSdXN0eSBSdXNzZWxsLCBJQk0gMjAwMgogKgogKiAg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tRUlOVkFMOwoJfQoJcHV0X3BhZ2UocGFnZSk7CgpvdXQ6CglyZXR1cm4g cmV0Owp9CgpzdGF0aWMgaW50IF9faW5pdCBpbml0KHZvaWQpCnsKCXVuc2lnbmVkIGludCBpOwoK CWZvciAoaSA9IDA7IGkgPCBBUlJBWV9TSVpFKGZ1dGV4X3F1ZXVlcyk7IGkrKykKCQlJTklUX0xJ U1RfSEVBRCgmZnV0ZXhfcXVldWVzW2ldKTsKCXJldHVybiAwOwp9Cl9faW5pdGNhbGwoaW5pdCk7 Cg==
--------------Boundary-00=_61WCC6Y813RGKY6NFQTQ-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/