If a workaround like itertools.count.__next__() is used because it will not be interrupted as it is implemented in C, then I have to ask if it would
make sense for Python to supply something similar in the standard library
for the sole purpose of a use in locks.
PostgreSQL has ways of doing this, and there are a few other ways, but
simply using a count object and relying on the GIL isn't going to
achieve the first (though it'll happily achieve the other two).
...
The
atomicity would be more useful in that context as it would give
lock-free ID generation, which doesn't work in Python.
What would have happened if all processors had been required to have
some low level instruction that effectively did something in an atomic
way that allowed a way for anyone using any language running on that
machine a way to do a simple thing like set a lock or check it?
On 2023-03-01 at 14:35:35 -0500,
avi.e.gross@gmail.com wrote:
What would have happened if all processors had been required to have
some low level instruction that effectively did something in an atomic
way that allowed a way for anyone using any language running on that machine a way to do a simple thing like set a lock or check it?
Have happened? I don't know about "required," but processors have
indeed had such instructions for decades; e.g., the MC68000 from the
early to mid 1980s (and used in the original Apple Macintosh, but I
digress) has/had a Test and Set instruction.
On Thu, 2 Mar 2023 at 08:01, <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
On 2023-03-01 at 14:35:35 -0500,
avi.e.gross@gmail.com wrote:
What would have happened if all processors had been required to have
some low level instruction that effectively did something in an atomic
way that allowed a way for anyone using any language running on that
machine a way to do a simple thing like set a lock or check it?
Have happened? I don't know about "required," but processors have
indeed had such instructions for decades; e.g., the MC68000 from the
early to mid 1980s (and used in the original Apple Macintosh, but I
digress) has/had a Test and Set instruction.
As have all CPUs since; it's the only way to implement locks (push the locking all the way down to the CPU level).
On 2023-03-01 at 14:35:35 -0500,
avi.e.gross@gmail.com wrote:
What would have happened if all processors had been required to have
some low level instruction that effectively did something in an atomic
way that allowed a way for anyone using any language running on that machine a way to do a simple thing like set a lock or check it?
Have happened? I don't know about "required," but processors have
indeed had such instructions for decades; e.g., the MC68000 from the
early to mid 1980s (and used in the original Apple Macintosh, but I
digress) has/had a Test and Set instruction.
So I guess we know what would have happened.
As have all CPUs since; it's the only way to implement locks (push the >locking all the way down to the CPU level).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 77:36:29 |
Calls: | 6,716 |
Files: | 12,247 |
Messages: | 5,357,739 |