| \c pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
\c pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| \c return &attr; |
\c return &attr; |
| \c } |
\c } |
| |
\c void create_pipe(FILE ** addr) |
| |
\c { |
| |
\c int epipe[2]; |
| |
\c pipe(epipe); |
| |
\c addr[0]=fdopen(epipe[0], "r"); |
| |
\c addr[1]=fdopen(epipe[1], "a"); |
| |
\c setvbuf(addr[1], NULL, _IONBF, 0); |
| |
\c } |
| c-function pthread+ pthread_plus a -- a ( addr -- addr' ) |
c-function pthread+ pthread_plus a -- a ( addr -- addr' ) |
| c-function pthreads pthreads n -- n ( n -- n' ) |
c-function pthreads pthreads n -- n ( n -- n' ) |
| c-function thread_start gforth_thread_p -- a ( -- addr ) |
c-function thread_start gforth_thread_p -- a ( -- addr ) |
| c-function pthread-mutexes pthread_mutexes n -- n ( n -- n' ) |
c-function pthread-mutexes pthread_mutexes n -- n ( n -- n' ) |
| c-function pause sched_yield -- void ( -- ) |
c-function pause sched_yield -- void ( -- ) |
| c-function pthread_detatch_attr pthread_detach_attr -- a ( -- addr ) |
c-function pthread_detatch_attr pthread_detach_attr -- a ( -- addr ) |
| |
c-function create_pipe create_pipe a -- void ( pipefd[2] -- ) |
| end-c-library |
end-c-library |
| |
|
| User pthread-id -1 cells pthread+ uallot drop |
User pthread-id -1 cells pthread+ uallot drop |
| |
User epiper |
| |
User epipew |
| |
|
| :noname ' >body @ ; |
:noname ' >body @ ; |
| :noname ' >body @ postpone literal ; |
:noname ' >body @ postpone literal ; |
| : >task ( user task -- user' ) + next-task - ; |
: >task ( user task -- user' ) + next-task - ; |
| |
|
| : kill-task ( -- ) |
: kill-task ( -- ) |
| 0 (bye) ; |
epiper @ close-file drop epipew @ close-file drop 0 (bye) ; |
| |
|
| :noname ( -- ) |
:noname ( -- ) |
| [ here throw-entry ! ] |
[ here throw-entry ! ] |
| throw-entry r@ udp @ throw-entry next-task - /string move |
throw-entry r@ udp @ throw-entry next-task - /string move |
| word-pno-size chars dup allocate throw dup holdbufptr r@ >task ! |
word-pno-size chars dup allocate throw dup holdbufptr r@ >task ! |
| + dup holdptr r@ >task ! holdend r@ >task ! |
+ dup holdptr r@ >task ! holdend r@ >task ! |
| |
epiper r@ >task create_pipe |
| ['] kill-task >body rp0 r@ >task @ 1 cells - dup rp0 r@ >task ! ! |
['] kill-task >body rp0 r@ >task @ 1 cells - dup rp0 r@ >task ! ! |
| handler r@ >task off |
handler r@ >task off |
| r> ; |
r> ; |