📄 tmt.s
字号:
;/* This function returns the time-sliced task pointer. */
;/* */
;/* AUTHOR */
;/* */
;/* Barry Sellew, Accelerated Technology, Inc. */
;/* */
;/* CALLED BY */
;/* */
;/* TMC_Timer_HISR Timer HISR */
;/* */
;/* CALLS */
;/* */
;/* None */
;/* */
;/* INPUTS */
;/* */
;/* None */
;/* */
;/* OUTPUTS */
;/* */
;/* TMD_Time_Slice_Task Time sliced task pointer */
;/* */
;/* HISTORY */
;/* */
;/* NAME DATE REMARKS */
;/* */
;/* B. Sellew 02-21-1997 Created and verified version 1.0 */
;/* */
;/*************************************************************************/
XDEF _TMT_Retrieve_TS_Task
_TMT_Retrieve_TS_Task:
;NU_TASK *TMT_Retrieve_TS_Task(VOID)
;{
;
; /* Return time-sliced task pointer. */
; return(TMD_Time_Slice_Task);
;
MOVE.L _TMD_Time_Slice_Task,D0 ; Pickup time slice pointer
RTS ; Return to caller
;}
;
;/*************************************************************************/
;/* */
;/* FUNCTION */
;/* */
;/* TMT_Timer_Interrupt */
;/* */
;/* DESCRIPTION */
;/* */
;/* This function processes the actual hardware interrupt. */
;/* Processing includes updating the system clock and the count- */
;/* down timer and the time-slice timer. If one or both of the */
;/* timers expire, the timer HISR is activated. */
;/* */
;/* AUTHOR */
;/* */
;/* Barry Sellew, Accelerated Technology, Inc. */
;/* */
;/* CALLED BY */
;/* */
;/* Interrupt Vector */
;/* */
;/* CALLS */
;/* */
;/* TCT_Activate_HISR Activate timer HISR */
;/* TCT_Interrupt_Context_Save Save interrupted context */
;/* TCT_Interrupt_Context_Restore Restore interrupted context */
;/* */
;/* INPUTS */
;/* */
;/* None */
;/* */
;/* OUTPUTS */
;/* */
;/* None */
;/* */
;/* HISTORY */
;/* */
;/* NAME DATE REMARKS */
;/* */
;/* B. Sellew 02-21-1997 Created and verified version 1.0 */
;/* */
;/*************************************************************************/
XDEF _TMT_Timer_Interrupt
_TMT_Timer_Interrupt:
;VOID TMT_Timer_Interrupt(void)
;{
;
; /* Save minimal context on the stack. */
;
MOVE.L D0,-(A7) ; Save D0 on the stack
;
; /* Increment the system clock. */
; TMD_System_Clock++;
;
ADDQ.L #1,_TMD_System_Clock ; Increment the system clock
;
; /* Determine if the count-down timer is active. */
; if (TMD_Timer_State == TM_ACTIVE)
; {
TST.L _TMD_Timer_State ; Determine if the timer state is
; active
BNE _TMT_Timer_Not_Active ; Non-zero, not active
; A bug found here, in sometimes, TMD_Timer will be zero,
; when subtract by 1, it's value will be a very large number,
; and the Timer will become unpredictable.
; LLH.2000.10.25.
TST.L _TMD_Timer ; Determine if the timer has just
; expired
BEQ _TMT_Timer_Expired
;
; /* Decrement the count-down timer. */
; TMD_Timer--;
;
SUBQ.L #1,_TMD_Timer ; Decrement the timer
;
; /* Determine if the timer has expired. If so, modify the state
; to indicate that it has expired. */
; if (TMD_Timer == 0)
;
TST.L _TMD_Timer ; Determine if the timer has just
; expired
BNE _TMT_No_Timer_Expired ; Non-zero, not expired
_TMT_Timer_Expired:
;
; TMD_Timer_State = TM_EXPIRED;
;
MOVEQ #2,D0 ; Indicate that the timer has
MOVE.L D0,_TMD_Timer_State ; expired
;
_TMT_No_Timer_Expired:
; }
_TMT_Timer_Not_Active:
;
; /* Determine if the time-slice timer is active. Note that the parameters
; for the time-slice are controlled by the Thread Control (TC)
; component. */
; if (TMD_Time_Slice_State == TM_ACTIVE)
; {
TST.L _TMD_Time_Slice_State ; Determine if time slice is active
BNE _TMT_Time_Slice_Not_Active ; Non-zero, time slice not active
;
; /* Decrement the time slice counter. */
; TMD_Time_Slice--;
;
SUBQ.L #1,_TMD_Time_Slice ; Decrement the time slice timer
;
; /* Determine if the time-slice timer has expired. If so, modify the
; time-slice state to indicate that it has. */
; if (TMD_Time_Slice == 0)
; {
TST.L _TMD_Time_Slice ; Determine if the time slice has
; expired
BNE _TMT_No_Slice_Expired ; Time slice has not expired
;
; TMD_Time_Slice_State = TM_EXPIRED;
;
MOVEQ #2,D0 ; Indicate that the time slice has
MOVE.L D0,_TMD_Time_Slice_State ; expired
;
; /* Copy the current thread into the time-slice task pointer. */
; TMD_Time_Slice_Task = TCD_Current_Thread;
;
MOVE.L _TCD_Current_Thread,D0
MOVE.L D0,_TMD_Time_Slice_Task
;
; /* Set the current time slice to 1, in order to insure that is is
; not lost. */
MOVE.L A0,-(A7) ; Save A0
MOVEA.L _TCD_Current_Thread,A0 ; Point at the task control block
MOVEQ #1,D0 ; Build minimal time slice value
MOVE.L D0,32(A0) ; Store it in task control block
MOVEA.L (A7)+,A0 ; Recover A0
; }
;
_TMT_No_Slice_Expired:
; }
_TMT_Time_Slice_Not_Active:
;
; /* Determine if either of the basic timers have expired. If so,
; activate the timer HISR. */
; if ((TMD_Timer_State == TM_EXPIRED) ||
; (TMD_Time_Slice_State == TM_EXPIRED))
; {
MOVE.L _TMD_Timer_State,D0 ; Determine if a timer has expired
CMP.L #2,D0
BEQ _TMT_Expiration ; A timer has expired
MOVE.L _TMD_Time_Slice_State,D0 ; Determine if a time slice has
CMP.L #2,D0 ; expired
BNE _TMT_No_Expiration ; No, nothing has expired
;
_TMT_Expiration:
;
; /* Save context of the system. */
; TCT_Interrupt_Context_Save(0);
;
MOVE.L (A7)+,D0 ; Recover D0
SUBQ.L #4,A7 ; Unused area on the stack
LEA.L -60(A7),A7
MOVEM.L D0-D7/A0-A6,(A7) ; Save all registers
JSR _TCT_Interrupt_Context_Save ; Save complete context
;
; /* Activate the HISR timer function. */
; TCT_Activate_HISR(&TMD_HISR);
;
MOVE.L #_TMD_HISR,-(A7) ; Put Timer's HISR pointer on the
; stack
JSR _TCT_Activate_HISR ; Activate the HISR
ADDQ.L #4,A7 ; Cleanup the stack
;
; /* Restore context. Note that control does not return from the
; TCT_Interrupt_Context_Restore function. */
; TCT_Interrupt_Context_Restore();
;
JMP _TCT_Interrupt_Context_Restore
; }
;
; /* Recover minimal context and return to point of interrupt. */
;
_TMT_No_Expiration:
MOVE.L (A7)+,D0 ; Recover D0
JMP _TCT_Check_For_Preemption ; Check for preemption
;}
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -