embedded python - cancel "while 1: pass"

Warren Postma embed at NO_SPAM_PLEASE.geocities.com
Fri Jan 5 09:11:39 EST 2001


>    Wow, it seems you are a Windows guy! Why not just kill the process
> instead of rebooting everything?

Nope, embedded win32 realtime-operating-system (pharlap ets -
www.pharlap.com ).

It so happens that I can build test/debug builds that run on NT, but the
final target is a single process with no virtual memory, running on a small
pc-104 cpu.   There is no way to kill a process without rebooting the
machine as the RTOS *is* the single
process.

I have figured out the problem is that only the foreground thread can be
aborted, the background threads cannot be aborted.

Ie, if you do

X = 2L ** 2L ** 256

in the foreground, it will be abortable.

In a background thread (which is how I do everything in this system) nothing
can be aborted.  I have decided to patch Python 1.5.2 to have thread-based
signals.

I noticed a comment in ceval.c, that said someone else has the same thought
as me, was it Guido?

-- (snippet) --

There are two possible race conditions:
   (1) nested asynchronous registry calls;
   (2) registry calls made while pending calls are being processed.
   While (1) is very unlikely, (2) is a real possibility.
   The current code is safe against (2), but not against (1).
   The safety against (2) is derived from the fact that only one
   thread (the main thread) ever takes things out of the queue.

XXX Darn!  With the advent of thread state, we should have an array
   of pending calls per thread in the thread state!  Later...

-- (end snippet) --

Since Pharlap has no "registry", I don't know what equivalent trouble
"nested asynchronous registry calls" might get me in on PharLap, but so far,
so good. I have removed the checks to see if thread id == main_thread.

Warren





More information about the Python-list mailing list