4 ms·
I couldn't find this in the design document but the only obvious solution is to track globals via the shared count. Since a global reference is part of all thre
by ameixaseca 5y ago
I couldn't find this in the design document but the only obvious solution is to track globals via the shared count. Since a global reference is part of all threads simultaneously, it cannot be treated as local.
If you follow this reasoning, the operations above result in local=0/shared=0 after the last assignment.
- twic 5y agoAs i said in the comment, that doesn't work. Put a list in the global, and then push and pop the string on the list. Even better, push the string into a local list, then put that list in another local list, then put that in a global, etc. You would need to dynamically keep every object reachable from a global marked as such, and that's a non-starter.
- ameixaseca 5y agoSorry, you're right - I missed that part. I had a few assumptions in mind that obviously break down with a bit of reasoning. The algorithm from the paper you posted in another comment indeed looks more complicated than it needs to be and prone to bad performance. Judging by the design, it appears they were trying to avoid the local thread to touch the shared counter in any circumstance on the hot path, but I wonder if it would not be much simpler for the owner thread to just check a flag set by the non-owner thread and perform the unbiasing/freeing right away without going through all the queuing mechanism.