L 6.2:   nchief

(Revision 1 - 4 November 2000)

 

overview    nchief finds id of nearest thread that would actually receive a message sent from the caller to the specified destination thread. It's called from id_nearest, k_ipc and ipc_long. Algorithm is described in IL4M, paragraph 6.1.1.

on entry        t8  pointer to caller's tcb
		a0  destination tid (if called from id_nearest)
0-3 id_nearest entry point
t2 ¬ caller's tid
v1¬ destination real tid
4 ipc_long entry point
5-8 if source and destination tasks have same chief, destination is in same clan
    Þ  goto  same_clan
9-13 else if destination is source's chief, destination is in an outer clan
    Þ  goto outer_clan
14 move sources task into source's chief field
15-18 if source is destination's chief, destination is in an inner clan
    Þ  goto inner_clan
19-22 else  if source and destination's indirect chief have same chief, destination's indirect chief is in same clan as source and destination is in an inner clan (for first time through test is a repeat of l5-l8 and fails again)
   Þ   goto  inner_clan
23 k_ipc entry point
24-27 if nesting depth of destination is less than or equal to nesting depth of source, destination is in an outer clan
   Þ   goto outer_clan
28-33 else construct tid of destination's chief, put it in v1, and goto line15 to repeat tests for direction between source and destination's chief at l18, l22, and l27
these tests are:
   l18 if source is destination's chief's chief, destination is in an inner clan
   l22 if source and destination's chief have same chief, destination is in an inner clan
   l27 if nesting level of destination's chief is equal to nesting depth of source, destination is in an outer clan (case where destination's chief's nesting level is less than source's nesting level is detected on previous test at l27 which tested whether destination was at same level as source)
and repeat process for destination's chief's chief,  etc.
34-41
outer clan	v1 ¬ sender's chief's tid (message will be sent to sender's
		      chief/sender's chief is nearest thread)
		v0 ¬ direction is from sender to an outer clan
		and return to caller
42-44
inner clan	v0 ¬ direction is from sender to an inner clan
		(v1 already has destination tid - either destination or 
		destination's chief or destination's chief's chief, etc.
		and return to caller)
45-47
same clan	v0  ¬  sender and destination are in same clan (no redirection)
		(v1 already has destination tid)
		and return to caller