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
17886828c8
cc3200/gccollect: Use MP_STATE_THREAD(stack_top) to get top of stack.
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
0455755296
cc3200: Use xTaskCreateStatic instead of osi_TaskCreate.
...
This allows to statically allocate the TCB (thread control block) and
thread stack in the BSS segment, reducing the need for dynamic memory
allocation.
2016-06-28 11:28:52 +01:00
Damien George
77e37ff98b
py/mpthread: Include mpstate.h when defining GIL macros.
2016-06-28 11:28:52 +01:00
Damien George
15e68277c1
tests/thread: Make sure that thread tests don't rely on floating point.
2016-06-28 11:28:52 +01:00
Damien George
5b7789d519
tests/thread: Make stack-size test run correctly and reliable on uPy.
2016-06-28 11:28:52 +01:00
Damien George
94238d4ae5
py/nlrsetjmp: Update to take into account new location of nlr_top.
...
It's now accessed via the MP_STATE_THREAD macro.
2016-06-28 11:28:52 +01:00
Damien George
1df4168c33
py/nlrthumb: Convert NLR thumb funcs from asm to C with inline-asm.
...
Now only the bits that really need to be written in assembler are written
in it, otherwise C is used. This means that the assembler code no longer
needs to know about the global state structure which makes it much easier
to maintain.
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
Damien George
9b1c1262dc
cc3200: Define our own FreeRTOS heap so it can go in a special segment.
2016-06-28 11:28:50 +01:00
Damien George
5c0fc73f33
cc3200: Update FreeRTOS to v9.0.0.
...
This is a pristine copy (actually a subset of files) of upstream FreeRTOS
v9.0.0.
Modifications to the previous version of FreeRTOS (v8.1.2) included
addition of __attribute__ ((section (".boot"))) to the following
functions:
pxPortInitialiseStack
prvTaskExitError
prvPortStartFirstTask
xPortStartScheduler
vPortSetupTimerInterrupt
xTaskGenericCreate
vTaskStartScheduler
prvInitialiseTCBVariables
prvInitialiseTaskLists
prvAllocateTCBAndStack
This attribute will need to be reinstated on a case-by-case basis
because some of the above functions are now removed/changed.
2016-06-28 11:28:50 +01:00
Damien George
e90b6ce0b5
py/mpthread.h: Move GIL macros outside MICROPY_PY_THREAD block.
...
The GIL macros are needed even if threading is not enabled.
2016-06-28 11:28:50 +01:00
Damien George
94d2919b77
unix/modtime: Release the GIL when sleeping.
2016-06-28 11:28:50 +01:00
Damien George
c567afc5fa
py/modthread: Make Lock objects work when GIL is enabled.
2016-06-28 11:28:50 +01:00
Damien George
a1c93a62b1
py: Don't use gc or qstr mutex when the GIL is enabled.
...
There is no need since the GIL already makes gc and qstr operations
atomic.
2016-06-28 11:28:50 +01:00
Damien George
4cec63a9db
py: Implement a simple global interpreter lock.
...
This makes the VM/runtime thread safe, at the cost of not being able to
run code in parallel.
2016-06-28 11:28:50 +01:00
Damien George
1f54ad2aed
py: Make interning of qstrs thread safe.
2016-06-28 11:28:50 +01:00
Damien George
b7274e91bc
tests/thread: Add test for concurrent mutating of user instance.
2016-06-28 11:28:50 +01:00
Damien George
2e4cdae4fd
tests/thread: Add test for concurrent interning of strings.
...
Qstr code accesses global state and needs to be made thread safe.
2016-06-28 11:28:50 +01:00
Damien George
094a0dd11a
tests/thread: Add tests that mutate shared objects.
...
Tests concurrent mutating access to: list, dict, set, bytearray.
2016-06-28 11:28:50 +01:00