Closed miurahr closed 3 years ago
How can we implement it for windows?
@cielavenir could you mind to review changes, test it, and help the progress?
@miurahr it is too large to review, but at least tests are working.
The core functions to be reviewed are three in lib2/Ppmd8Tdecoder.c
:
Byte TReader(const void *p)
is called from PPMd library under lib/
folder. It send signal empty
when buffer exhausted, and wait signal notEmpty
.
static void * Ppmd8T_decode_run(void *p)
is a function that run in the thread. the core logic comes from src/ext/_ppmdmodule.c
L1440-L1470 and protect critical part with mutex.
int Ppmd8T_decode()
is a function that start and handle thread, and return when input buffer is empty.
It also handles signals and detect state of _run
function.
Windows fatal exception: access violation
errors are reproduced on Windows test, there may be a bug but it is too difficult to debug from log.
Actually I have an issue:
I found that PPMD_pthread_cond_wait1(&inEmpty, &mutex)
could fail to receive inEmpty signal. I have not investigated deeply but it seems like that signal was sent during pthread_cond_timedwait's relocking (here relocking would be done because of pthread_cond_wait(¬Empty, &mutex)
).
This happens because pthread_cond_timedwait is not FIFO, so I wrote simple implementation in https://github.com/cielavenir/pyppmd-py2/commit/f224a04102da9e596ae7df3212ed37bd6c2b9a9b (part of UseEndmarkProperly2).
Another question: did you test FFI version? The test does not run here.
Inserting https://github.com/cielavenir/pyppmd-py2/commit/43791a5169d0858c6911ef623b1ff803ac5ca226 worked.
I found that PPMD_pthread_cond_wait1(&inEmpty, &mutex) could fail to receive inEmpty signal. I have not investigated deeply but it seems like that signal was sent during pthread_cond_timedwait's relocking (here relocking would be done because of pthread_cond_wait(¬Empty, &mutex)).
This happens because pthread_cond_timedwait is not FIFO, so I wrote simple implementation in cielavenir@f224a04 (part of UseEndmarkProperly2).
Thank you for the suggestion! I don't prefer global variable other than mutex lock one, so I'd like to rewrite based on your suggestion.
@miurahr see https://github.com/miurahr/pyppmd/commit/7e707cc5fbae0a224a25d740a327544ca7e5d4a4 and https://github.com/miurahr/pyppmd/commit/92d52dfa492d6118e4f3cff2d5b600699f1fea58
I'd like to handle pypy3 case, infinite loop to wait thread finish, on another issue tracker.
maybe please merge this as it is and I'll revisit my UseEndmarkProperly branch later
Partial fix for #28
Todo:
Issues:
Signed-off-by: Hiroshi Miura miurahr@linux.com