Skip to content

Commit

Permalink
With the saving of HIP into R15, the threading works in 64 bit too.
Browse files Browse the repository at this point in the history
  • Loading branch information
albert committed Jan 23, 2016
1 parent 37f5240 commit 25e43cb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
10 changes: 5 additions & 5 deletions blocks.frt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3709,4 +3709,4 @@ WANT BIN-SEARCH



( 3344 last line.)
( 3712 last line in blocks.)
18 changes: 9 additions & 9 deletions ci86.gnr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -7460,30 +7458,32 @@ _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}
POP DX _C{ Third parameter, or dummy}
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 }
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,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_})
Expand Down
2 changes: 1 addition & 1 deletion constant_64.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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. }
Expand Down
32 changes: 32 additions & 0 deletions logforth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 25e43cb

Please sign in to comment.