001000 |
rt |
rs |
rd |
x |
1000101 |
000 |
6 |
5 |
5 |
5 |
1 |
7 |
3 |
FORK rd, rs, rt |
MIPS MT |
Allocate and Schedule a New Thread |
Allocate and Schedule a New Thread
To cause a thread context to be allocated and associated with a new instruction stream.
Description: NewThread's GPR[rd] = GPR[rt], NewThread's TCRestart = GPR[rs]
The FORK instruction causes a free dynamically allocatable thread context (TC) to be allocated and activated on the issuing VPE. It takes two operand values from GPRs. The rs value is used as the starting fetch address and execution mode for the new thread. The rt value is copied into GPR rd of the new TC. The TCStatus register of the new TC is set up as a function of the FORKing TC as described in Section 6.12. If the UserLocal register is implemented, the
UserLocal value of the FORKing TC is also copied to the new TC. The newly allocated TC will begin executing
instructions according to the implemented scheduling policy if and when multi-threaded execution is otherwise enabled.
If no free, non-halted, dynamically allocatable TC is available for the fork, a Thread Exception is raised for the FORK instruction, with the VPEControl.EXCPT CP0 register field set to 1 to indicate the Thread Overflow case.
Processors which implement only a single TC per VPE may implement FORK by simply raising the Thread Exception and indicating the Overflow.
Any exceptions associated with the virtual address passed in rs will be taken by the new thread of execution.
if Config3MT = 1 then success = 0 for t in 0...MVPConf0PTC if TC[t].TCBindCurVPE = TCBindCurVPE then if (TC[t].TCStatusDA = 1) and (TC[t].TCHaltH = 0) and (TC[t].TCStatusA = 0) and (success = 0) then TC[t].TCRestart = GPR[rs] TC[t].GPR[rd] = GPR[rt] if (Config3ULRI = 1) then TC[t].UserLocal = UserLocal endif activated = 1 priorcu = TC[t].TCStatusTCU3..TCU0 priormx = TC[t].TCStatusTMX priorixmt = TC[t].TCStatusIXMT TC[t].TCStatus = priorcu || priormx || StatusFR || 05 || 1 || ImpDep4 || 1 || 0 || activated|| StatusKSU || priorixmt || 02 || TCStatusTASID success = 1 endif endif endfor if success = 0 VPEControlEXCPT = 1 endif else SignalException(ReservedInstruction) endif
Reserved Instruction
Thread