[issue12936] armv5tejl segfaults: sched_setaffinity() vs. pthread_setaffinity_np()

Charles-François Natali report at bugs.python.org
Tue Sep 13 22:47:10 CEST 2011


Charles-François Natali <neologix at free.fr> added the comment:

> If we have access (and as I understood from Victor's post we do):
> pthread_getaffinity_np() also exists on FreeBSD, which would be
> an advantage.

Yes, but I see several drawbacks:
- as noted by Victor, it's really easy to crash the interpreter by passing an invalid thread ID, which IMHO, should be avoided at all cost
- to be safe, we would need to have a different API depending on whether Python is built with threads or not (i.e. sched_setaffinity() without threads, and pthread_setaffinity_np())
- pthread_setaffinity_np() is really non-portable (it's guarded by __USE_GNU in my system's header)
- sched_setaffinity() seems to work fine on most systems even when linked with pthread

> I don't care strongly about using pthread_getaffinity_np(), but at least I'd
> like to skip the scheduling sections on arm-linux if they don't work reliably.

Sounds reasonable.
I guess you could use os.uname() or platform.machine().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12936>
_______________________________________


More information about the Python-bugs-list mailing list