Commit Graph

9 Commits

Author SHA1 Message Date
Damien George 17ba6ef5fa cc3200: Fix thread mutex's so threading works with interrupts.
Running Python code on a hard interrupt is incompatible with having a GIL,
because most of the time the GIL will be held by the user thread when the
interrupt arrives.  Hard interrupts mean that we should process them right
away and hence can't wait until the GIL is released.

The problem with the current code is that a hard interrupt will try to
exit/enter the GIL while it is still held by the user thread, hence leading
to a deadlock.

This patch works around such a problem by just making GIL exit/enter a
no-op when in an interrupt context, or when interrupts are disabled.

See issue #2406.
2016-10-19 14:24:56 +11:00
Damien George 50ddaafa6a cc3200: Use mp_raise_XXX helper functions to reduce code size.
Reduces code size by 632 bytes.
2016-10-18 09:53:43 +11:00
Damien George fa2ac93c3a cc3200/mpthreadport: Move mem alloc outside the thread_mutex lock.
Otherwise there could be a deadlock, with the GC's mutex and
thread_mutex.
2016-06-28 11:28:52 +01:00
Damien George 757146efe3 cc3200/mpthreadport: Scan more root pointers from thread data. 2016-06-28 11:28:52 +01:00
Damien George 3b0fbfe4e5 cc3200/mpthreadport: Properly initialise the main thread's data. 2016-06-28 11:28:52 +01:00
Damien George 27241293c4 cc3200/mpthreadport: Make mutex statically allocated.
Reduced the need for the FreeRTOS heap to allocate the mutex.
2016-06-28 11:28:52 +01:00
Damien George c9520c591b cc3200: Fix call to new exception to be _msg instead of _arg1. 2016-06-28 11:28:51 +01:00
Damien George df95f52583 py/modthread: Allow to properly set the stack limit of a thread.
We rely on the port setting and adjusting the stack size so there is
enough room to recover from hitting the stack limit.
2016-06-28 11:28:51 +01:00
Damien George eef4f13a33 cc3200: Add basic threading capabilities.
Can create a new thread and run it.  Does not use the GIL at this point.
2016-06-28 11:28:51 +01:00