How to get shorter time tick for OSTimeDly()

Discussion to talk about software related topics only.
Post Reply
leetehui
Posts: 10
Joined: Thu Aug 27, 2009 2:50 am

How to get shorter time tick for OSTimeDly()

Post by leetehui » Tue Mar 10, 2020 8:13 pm

platform: MOD5270B
I need faster response of the module to the request. Currently, TICKS_PER_SECOND is 20. Every tick will takes 50 msec which is too slow for me.
I try to use OSChangeTaskDly() to change the new tick but it seems not working and the function is not recommended as described in the manual.
I try to change the define of TICKS_PER_SECOND to 200 in \include\constants.h and recompile the system file. The behavior of the module becomes a little queer. It becomes faster but I can't get the correct timing of the task for other purposes.
Any suggestion?
Robert Lee
National Synchrotron Radiation Research Center, Taiwan

User avatar
pbreed
Posts: 842
Joined: Thu Apr 24, 2008 3:58 pm

Re: How to get shorter time tick for OSTimeDly()

Post by pbreed » Wed Mar 11, 2020 3:37 pm

Are you trying to:
change the resolution of OS Timedly,
trying to increase the task switching speed.
trying to make more precise time measurments?

Do you need this for a single task/chunk of code, or many...


The call OSChangeTaskDly just changes the current delay interval for a specific task, it has nothing to do with ticks per second.

If you change TICKS_PER_SECOND you must rebuild EVERYTHING... system, platform and application ie rebuild everything.

Increasing TICKS_PERSECOND will increase the resolution of OSTimeDly and all pend/post timeouts.
It will have ZERO effect on the task switching speed as that has no releation to ticks...
The highest priority unblocked task always runs, and the task switching latency on 5270 is on the order of 1 to 2 uSec.

You can get high precision delays using the high res timer class....

What NNDK version are you running?

#include <HiResTimer.h>

User avatar
pbreed
Posts: 842
Joined: Thu Apr 24, 2008 3:58 pm

Re: How to get shorter time tick for OSTimeDly()

Post by pbreed » Wed Mar 11, 2020 3:41 pm

Are you trying to:
change the resolution of OS Timedly,
trying to increase the task switching speed.
trying to make more precise time measurments?

Do you need this for a single task/chunk of code, or many...


The call OSChangeTaskDly just changes the current delay interval for a specific task, it has nothing to do with ticks per second.

If you change TICKS_PER_SECOND you must rebuild EVERYTHING... system, platform and application ie rebuild everything.

Increasing TICKS_PERSECOND will increase the resolution of OSTimeDly and all pend/post timeouts.
It will have ZERO effect on the task switching speed as that has no releation to ticks...
The highest priority unblocked task always runs, and the task switching latency on 5270 is on the order of 1 to 2 uSec.

You can get high precision delays using the high res timer class....

What NNDK version are you running?

#include <HiResTimer.h>

//Should either be global static or only constructed ONCE...
HiResTimer MyTimer( DEFAULT_TIMER);


Then
MyTimer .delay_uSec(delay_in_usec); //Use to block and task swithc should not be used for delays shortere than 150usec...

or...

MyTimer.pollingDelay_uSec(delay_in_usec); //Can be used for very short delays, this is a spin loop so task still runs... does not block or allow other tasks to run.

leetehui
Posts: 10
Joined: Thu Aug 27, 2009 2:50 am

Re: How to get shorter time tick for OSTimeDly()

Post by leetehui » Tue Apr 14, 2020 7:22 pm

Thank you very much for your reply. Sorry for the late response. I am shifted to other tasks recently.
I am using NNDKSetupRel24_rc2.exe for MOD5070B. Quite an old version I believe.
I need a faster response of certain task in my program. No problem with task switch.
HiResTimer seems to be a good solution. I think I need to update my NNDK.
I will do more trials and post my test results later.
Robert Lee
National Synchrotron Radiation Research Center, Taiwan

User avatar
pbreed
Posts: 842
Joined: Thu Apr 24, 2008 3:58 pm

Re: How to get shorter time tick for OSTimeDly()

Post by pbreed » Thu Apr 16, 2020 7:06 am

The task switch is in usec.
If you are having task performance issues, its probably because some higher priority task is running.

The Tick interval ONLY effects the timeout, not the task switch time.

Post Reply