8000 GitHub - kevinmingtarja/py-futex: Python futex lock · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python futex lock

An educational mutex implementation in python using Linux futex with atomic operations written in C. Requires Linux x86-64. Mostly handwritten, with some assistance from Codex.

Inspired by section 28.15 of https://pages.cs.wisc.edu/~remzi/OSTEP/threads-locks.pdf.

For a brief overview of futex: https://eli.thegreenplace.net/2018/basics-of-futexes.

Testing

docker run --rm --platform linux/amd64 \
  -v "$PWD:/work" -w /work py-futex:local \
  bash -c 'clang -O2 -shared -fPIC atomics.c -o atomics.so && python3 example.py'

The example uses two threads to increment a shared counter. Expected output: Counter: 200 (expected 200).

About

Python futex lock

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0