diff --git a/blocks.frt b/blocks.frt index b7e52a9..2a1dcc1 100644 --- a/blocks.frt +++ b/blocks.frt @@ -1751,10 +1751,10 @@ WANT CTA WANT -syscalls- HEX \ Create a thread with dictionary SPACE. Execute XT in thread. : THREAD-PET ALLOT CTA CREATE RSP@ SWAP RSP! R0 @ S0 @ ROT RSP! 2 CELLS - ( DSP) , ( TASK) , ( pid) 0 , - DOES> >R ( xt) R@ @ CELL+ ! R@ CELL+ @ ( R0) R@ @ ! - 100 R@ @ _ __NR_clone XOS DUP 0< IF THROW THEN - DUP IF ( Mother) R> 2 CELLS + ! - ELSE ( Child) DROP RSP! EXECUTE EXIT-PET THEN ; + DOES> DUP @ >R SWAP OVER CELL+ @ R@ 2! ( clone S: tp,xt) + 100 R> _ __NR_clone XOS DUP IF + ( Mother) DUP ?ERRUR SWAP 2 CELLS + ! ELSE + ( Child) DROP RSP! CATCH DUP IF ERROR THEN EXIT-PET THEN ; \ Kill a THREAD-PET , preemptively. Throw errors. : KILL-PET >BODY 2 CELLS + @ 9 _ __NR_kill XOS ?ERRUR ; DECIMAL @@ -3709,4 +3709,4 @@ WANT BIN-SEARCH -( 3344 last line.) +( 3712 last line in blocks.) diff --git a/ci86.gnr b/ci86.gnr index 5b903f0..f820017 100644 --- a/ci86.gnr +++ b/ci86.gnr @@ -7416,17 +7416,15 @@ _BITS32_({ INT 0x80 _C{ Generic call on LINUX } })_C{}_END_({_BITS32_}) _BITS64_({ - LEA RPO,[RPO - _CELLS(1)] _C{Save HIP on return stack.} - MOV [RPO],HIP -_C({ XCHG BX,HIP #Save HIP in BX why not }) +_C({ Saving HIP on the return stack, with RPO saved in memory or }) +_C({ R15 fails with the __NR_clone syscall (and only then) }) + MOV R15,HIP _C{ HIP is SI } POP AX _C{ Function number } POP DX _C{ Third parameter, or dummy } POP SI _C{ Second parameter, or dummy } POP DI _C{ First parameter. } SYSCALL _C{ Generic call on LINUX } - MOV HIP,[RPO] _C{ Restore} - LEA RPO,[RPO+_CELLS(1)] -_C({ XCHG BX,HIP #Restore why not }) + MOV HIP,R15 })_C{}_END_({_BITS64_}) _PUSH _C{ Positive means okay. Negative means -errno.} _C @@ -7460,10 +7458,10 @@ _BITS64_({ {{1 "CHIMP" 0 0 1 XOS5 .},{CHIMP5}}, }) enddoc) _LINUX_N_({ CODE_HEADER({XOS5},{XOS5}) +_BITS32_({ LEA RPO,[RPO - _CELLS(1)] _C{Save HIP on return stack.} MOV [RPO],HIP -_BITS32_({ POP AX _C{ Function number} POP DI _C{ 5th parameter, or dummy} POP SI _C{ 4th parameter, or dummy} @@ -7471,8 +7469,11 @@ _BITS32_({ POP CX _C{ Second parameter, or dummy} POP BX _C{ First parameter.} INT 0x80 _C{ Generic call on LINUX } + MOV HIP,[RPO] _C{ Restore} + LEA RPO,[RPO+_CELLS(1)] })_C{}_END_({_BITS32_}) _BITS64_({ + MOV R15,HIP _C{ HIP is SI } POP AX _C{ Function number } POP R8 _C{ 5th parameter, or dummy } POP R10 _C{ 4th parameter, or dummy } @@ -7480,10 +7481,9 @@ _BITS64_({ POP SI _C{ Second parameter, or dummy } POP DI _C{ First parameter. } SYSCALL _C{ Generic call on LINUX } + MOV HIP,R15 })_C{}_END_({_BITS64_}) - MOV HIP,[RPO] _C{ Restore} - LEA RPO,[RPO+_CELLS(1)] _PUSH _C{ Positive means okay. Negative means -errno.} _C })_C{}_END_({_LINUX_N_}) diff --git a/constant_64.m4 b/constant_64.m4 index 0114160..4ae1589 100644 --- a/constant_64.m4 +++ b/constant_64.m4 @@ -46,7 +46,7 @@ pipe EQU 0x16 _newselect EQU select wait4 EQU waitpid -RAWIO EQU (ECHO _OR_ ICANON) +_C{RAWIO EQU (ECHO _OR_ ICANON)} _C{ ------------------------------------------------------------ } _C{ End of constants stolen from C in linux 64 bit environment. } diff --git a/logforth.txt b/logforth.txt index d270b34..026aa77 100644 --- a/logforth.txt +++ b/logforth.txt @@ -13843,6 +13843,11 @@ CREATE AAP -2 CELLS +ORIGIN 'AAP >CFA ! AAP reveals that the WARM start of lina64 is okay. However installing that address as a signal handler fails. +2015 dec 5 +Added a couple of screens to do regression tests. +REGRESS tests stack depth and parameters. +The task area's are now allocated in the dictionary. + 2015 dec 11 I needed CS-ROLL for noforth meta compilation. CS-ROLL wwith two items each is 2* ROLL. However my ROLL didn't work @@ -13868,7 +13873,34 @@ do-sys and orifg's on the control stack are made the same size. CS-ROLL has been added. SLITERAL didn't compile well. +2016 jan 18 +nasm version of 64 bits lina works again and passes test. +The problems lies in the LDEMULATION thingy. It is added to +the Makefile. It has been tested whether any of those versions +works better with threadpet, but no. +nlina64 glina64 and lina64 (fasm) all work and can compile +hellow.frt. + +2016 jan 20 +Reinvestiaged threading in 64 bits. Downloaded an example, +see THREADS/threadpet.frt. Apparently the simple minded +cloning in assembler works. Experimentation reveals that +cloning returns a 0 or a 16 bit process counter in rax, +and that the base pointer (my return stack pointer, where +the HIP is saved) is not spoiled. + +2016 jan 20 +At last I have some clue about the problem why threads don't +work in 64 bits. It sysfaults at the NEXT of XOS. +This means that SI and/or BP are not saved properly. +If I save them in the USINI area, all is well, but that is not +re-entrant. +I don't need to save SI via BP in 64 bits. It turns out that +storing into X15 is well. + -------------------- +officialdecompilation fails on SEE _pad. + The description of ACCEPT is no good. The case about non-structured things merits a place in common problems.