clone(): use CAS for TID allocation

This commit is contained in:
Balazs Gerofi
2016-08-16 14:18:58 +09:00
parent 4410e702d9
commit 73cf93727b

View File

@ -1941,9 +1941,13 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
}
/* Find an unused TID */
retry_tid:
for (i = 0; i < newproc->nr_tids; ++i) {
if (!newproc->tids[i].thread) {
newproc->tids[i].thread = new;
if (!__sync_bool_compare_and_swap(
&newproc->tids[i].thread, NULL, new)) {
goto retry_tid;
}
new->tid = newproc->tids[i].tid;
dkprintf("%s: tid %d assigned to %p\n", __FUNCTION__, new->tid, new);
break;