L 7.3   The ins_busy_list macro

(Revision 0 - 20 November 2000)

 

insert_busy_list (tcb, kern_base, temp_reg)

on entry 
tcb points to the thread control block of a thread to be inserted into the READY list for its priority
kern_base has the physical address of kernel_vars (PA=40000H and VA=ffff ffff 8004 0000H) for this hardware platform
temp_reg is a register that can be used for scratch purposes

overview   insert_busy_list inserts tcb at the tail of the READY  list for its priority making it the new list tail. Each READY list has a list head that points at the tail of the list. The list is circular. The tail points to the head which points to the next to the head which point to the next to the next to the head ... which points to the next to the tail which points to the tail. This organization facilitates easy insertion and removal (by get_next_thread) because both the insertion and deletion points are readily accessible. See Handout #11.

notes    after line 7 AT holds a pointer to the previous tail
            after line 13 temp_reg holds a pointer to the head

0,1 if thread already linked in busy list goto line 16
2,3 if timeslice = 0 goto line 20 (and leave)
4-7 AT <--  previous tail of the READY list for this thread's priority
8 point list head at tcb, making it the new tail
9-12 if this priority list was empty, point tcb at itself
else goto line16
13,14 point new tail tcb at head of list (copy pointer from previous tail to do this)
15 point previous tail at new tail
16,17 remaining timeslice for new tail tcb<--  normal timeslice for new tail tcb
18-20 current priority for new tail tcb <--  normal priority for new tail tcb