Fast Task State Detection - Just 'if running' detection

westmorelandeng wrote on Wednesday, September 19, 2018:

Hello All,

I need to be able to detect (will be assembly as I have to put this into the tick ISR) the task status - what will make this ‘fast’ is that I only need to know if:

if( pxTCB == pxCurrentTCB )
{
		/* The task calling this function is querying its own state. */
		eReturn = eRunning;
	}

that’s true and I see that’s in the eTaskState funtion.

I guess I can start by implementing the assembly version of eTaskState up to that point - but I was wondering if there is any other quicker way to do this and if there’s some other function/macro someplace that does that.

Thanks!
John W.

westmorelandeng wrote on Thursday, September 20, 2018:

Hello All,

Well, I figured out a way to do this:

mov xar7, dbl ((#_save_xar7)) ; save xar7
mov xar6, dbl (
(#_save_xar6)) ; save xar6
amov #0x000000, xar7 ; must be cleared
amov #0x000000, xar6
mov *sp(#1), ar7 ;; sp+3
mov ar7, *(#_save_new_pxcode)
mov ssp, ar6
mov *ar6(#1), ar7 ;; ssp+3
mov ar7, *(#_save_new_pxlcode) ; ==> now we have our new return address, and if a task, it’s where we are

                    mov dbl (*(#_pxCurrentTCB)), xar7
                    mov xar7, dbl(*(#_xCompareTCB))
                    mov dbl (*(#_save_xar7)), xar7                  ; restore xar7
                    mov dbl (*(#_save_xar6)), xar6                  ; restore xar6

And:

.if 1
mov dbl (*(_xCompareTCB)), xar6 ; need to restore our return address
mov xar7, ac0
mov xar6, ac1
CMPU AC1 != AC0, TC1
BCC $5,TC1
amov #0x000000, xar7
amov #0x000000, xar6
mov *(#_save_new_pxcode), ar7
mov ar7, *sp(#0)
mov *(#_save_new_pxlcode) , ar7
mov ssp, ar6
mov ar7, *ar6(#0)

                    mov dbl (*(#_save_xar6)), xar6
					.endif

$5:

So, that’s not too bad.

Regards,
John W.