apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.83k stars 1.17k forks source link

arch code shouldn't include sched/sched.h which violate the modular rule #1652

Open xiaoxiang781216 opened 4 years ago

xiaoxiang781216 commented 4 years ago

sched.h is an internal header file and then should be accessed only inside nuttx/sched folder. #include "sched/sched.h" which spread around arch/ folder should be removed.

patacongo commented 4 years ago

Yes, this is an exception to the rule which has been there since day 1. The intention is that that these are interfaces that are shared only between arch/ and sched/ and nowhere else. This is the way that that scoping is enforced.

Much of the code under arch/ is logically part of the scheduler and needs to share prototypes and definitions that are internal and private to the scheduler: up_block_task(), up_unblock_task(). etc.

The alternative would be to move the prototypes into include/nuttx/sched.h, but that then reveals internal interfaces that should not be used outside of arch. So that is a not a very good idea.

I have thought about this before and decided that although the current solution is not clean, it is better than any other solution that I have know of. We need to have a way to share internal OS definitions with arch/ and no where else. I think it just needs to be better documented. I don't think any code change is required.

xiaoxiang781216 commented 4 years ago

If we change the macro to function, the internal detail don't need to expose outside of sched folder.