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
Damien George
c73cf9d931
tests/thread: Rename thread_stress_XXX.py to stress_XXX.py.
2016-06-28 11:28:50 +01:00
Damien George
f443504f86
unix/mpthreadport: Suppress compiler warning about unused arguments.
2016-06-28 11:28:50 +01:00
Damien George
f1dbd2909e
unix/gccollect: Provide declaration of exported function.
2016-06-28 11:28:50 +01:00
Damien George
c2508ac8bd
unix/mpthreadport: Use SA_SIGINFO for GC signal handler.
...
SA_SIGINFO allows the signal handler to access more information about
the signal, especially useful in a threaded environment. The extra
information is not currently used but it may prove useful in the future.
2016-06-28 11:28:49 +01:00
Damien George
3653f5144a
py/gc: Fix GC+thread bug where ptr gets lost because it's not computed.
...
GC_EXIT() can cause a pending thread (waiting on the mutex) to be
scheduled right away. This other thread may trigger a garbage
collection. If the pointer to the newly-allocated block (allocated by
the original thread) is not computed before the switch (so it's just left
as a block number) then the block will be wrongly reclaimed.
This patch makes sure the pointer is computed before allowing any thread
switch to occur.
2016-06-28 11:28:49 +01:00
Damien George
dbd54e0b5b
unix: Implement garbage collection with threading.
...
This patch allows any given thread to do a proper garbage collection and
scan all the pointers of all active threads.
2016-06-28 11:28:49 +01:00
Damien George
9172c0cb25
py/modthread: Call mp_thread_start/mp_thread_finish around threads.
...
So the underlying thread implementation can do any necessary bookkeeping.
2016-06-28 11:28:49 +01:00
Damien George
722cff5fd0
py/modthread: Be more careful with root pointers when creating a thread.
2016-06-28 11:28:49 +01:00
Damien George
f1b6db2218
unix/file: If write syscall returns because of EINTR then try again.
...
As per PEP-475.
2016-06-28 11:28:49 +01:00
Damien George
e33806aaff
py/gc: Fix 2 cases of concurrent access to ATB and FTB.
2016-06-28 11:28:49 +01:00
Damien George
7f4658a7ee
py/modthread: Satisfy unused-args warning.
2016-06-28 11:28:49 +01:00
Damien George
dcc7c5bd89
tests/thread: Add tests for running GC within a thread, and heap stress.
2016-06-28 11:28:49 +01:00
Damien George
c93d9caa8b
py/gc: Make memory manager and garbage collector thread safe.
...
By using a single, global mutex, all memory-related functions (alloc,
free, realloc, collect, etc) are made thread safe. This means that only
one thread can be in such a function at any one time.
2016-06-28 11:28:49 +01:00
Damien George
34fc006f5e
py/modthread: Add with-context capabilities to lock object.
2016-06-28 11:28:49 +01:00
Damien George
801d1b3803
py/modthread: Implement lock object, for creating a mutex.
2016-06-28 11:28:49 +01:00
Damien George
2dacd604c5
py/modthread: Add exit() function.
...
Simply raises the SystemExit exception.
2016-06-28 11:28:48 +01:00
Damien George
707f98f207
py/modthread: Add stack_size() function.
2016-06-28 11:28:48 +01:00
Damien George
3eb7a26809
py/modthread: Properly cast concrete exception pointer to an object.
2016-06-28 11:28:48 +01:00
Damien George
a791be936a
unix: Add basic thread support using pthreads.
...
Has the ability to create new threads.
2016-06-28 11:28:48 +01:00
Damien George
27cc07721b
py: Add basic _thread module, with ability to start a new thread.
2016-06-28 11:28:48 +01:00
Damien George
330165a2cc
py: Add MP_STATE_THREAD to hold state specific to a given thread.
2016-06-28 11:09:31 +01:00
Damien George
3545ef8bb4
tests/thread: Remove need to sleep to wait for completion in some tests.
...
Use a lock and a counter instead, and busy wait for all threads to
complete. This makes test run faster and they no longer rely on the time
module.
2016-06-28 11:09:31 +01:00