⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rzkscheduler.s

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 S
字号:
;/*
;* File				:	RZKScheduler
;*
;* Description		:	Defines scheduler call.
;* 
;* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
;*
;* This file contains unpublished confidential and proprietary information
;* of ZiLOG, Inc.
;* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
;* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
;* This is not a license and no use of any kind of this work is authorized
;* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
;* sole discretion 
;*/
; 
;    RZKScheduler.s
;
;    Offset for operationmode in TCB has been changed, this routine wont work with previous TCB structure
;
;
;	.INCLUDE	"debug.inc"	
	.extern _RZKSwitchContextA
	.extern _FindHighestIndex
	.extern _DispatchQueue
	.extern	_BitMap
	.extern	_bTaskChangeFlag
	.extern	_uNestedISRCount
	.extern	_hCurrentThread 
	.extern	_DQPriorityBitMap
	.extern _UpdateStatistics			
	
	.DEBUG1	.equ 0
	OFFSET_STATE	:	equ	06H
	OFFSET_OPMODE	:	equ	11H
	
	.def _RZKScheduler
	.assume	adl=1

;/* Function		:	_RZKScheduler
;*
;* Description		:	Schedules RZK
;* 
;* Inputs			:	None.
;*							
;* Outputs			:	None.
;*							
;*
;* Dependencies		:	None.
;*/
_RZKScheduler:
	LD	IY, (_hCurrentThread)	;if((!(pCurrentThread->uState&THREAD_RUNNING))||(pCurrentThread->uOperationMode&RZK_THREAD_PREEMPTION))			
	LD	A, (IY+OFFSET_STATE)	
	BIT	3,A						;THREAD_RUNNING=0x80
	JP	Z,DO_IT			 		
	LD	A, (IY+OFFSET_OPMODE)
    BIT	2,A						;is op mode is preemption enabled,  RZK_THREAD_PREEMPTION=0x04
	JP	Z,RETURN				;Dont Context switch if both conditions are not met, just return

DO_IT:
	CALL _FindHighestIndex
	LD L,A		
	LD H,6			;size of DispatchQueue=6 	typedef struct DISPATCHQ_t
					;							{ RZK_TCB_t  * pNext;	
					;							  RZK_TCB_t  * pPrevious;	
					;							} RZK_DISPATCHQ_t 
	MLT HL			;multiply with index 
	LD BC,_DispatchQueue
	ADD HL,BC	;DispatchQueue[uIndex].pNext
	XOR A,A	   	;Clear the carry
	LD BC,IY	;Load pCurrentThread in BC
	LD HL,(HL)	
	PUSH HL		
	SBC HL,BC  	;check if (DispatchQueue[uIndex].pNext == pCurrentThread)
	JP Z, RETURN_1
.IF .DEBUG1
	CALL _UpdateStatistics	
ENDIF
	CALL _RZKSwitchContextA	; Switch context if not

RETURN_1:	
	POP HL
	RET

RETURN:
	RET

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -