Hi Giovanni,
In my project I need to roughly estimate "CPU usage". It can be calculated from Idle ticks and whole system ticks. For this purpose I need to get pointer to Idle thread. Is there elegant way to get Idle thread pointer? I have found 2:
1) Iterate through thread registry and search name "idle". Ugly.
2) Modify chSysInit() function to return idle thread pointer.
Also, I can realize second way and commit to trunk if it acceptable.
How to get pointer to IDLE thread?
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: How to get pointer to IDLE thread?
Hi,
There is already a macro chSysGetIdleThread() but it only works when the idle thread is the one internally defined.
Probably it would be better to change it to use "rlist.r_queue.r_prev", it always point to the idle thread because it is at the lowest priority and always ready.
Giovanni
There is already a macro chSysGetIdleThread() but it only works when the idle thread is the one internally defined.
Probably it would be better to change it to use "rlist.r_queue.r_prev", it always point to the idle thread because it is at the lowest priority and always ready.
Giovanni