[pypy-dev] Implementing CAS
Benjamin Peterson
benjamin at python.org
Tue Mar 22 22:14:09 CET 2011
2011/3/22 Timothy Baldridge <tbaldridge at gmail.com>:
> After my last discussion about getting some multi-threading
> primitives, I took a look at how locks are implemented in PyPy. PyPy
> currently uses OS level mutexes...which is okay for most uses, but in
> my case, I need super fast spinlocks, and for that I need a CAS
> operation. What I'm looking for is a bit of direction on how to go
> about implementing this function (shown in C syntax):
>
> int cas(*expected, *new, **location)
I suggest you create a new low-level operation. Then the C backend can
translate it into asm.
--
Regards,
Benjamin
More information about the Pypy-dev
mailing list