I am writing a simple RTOS i have some tasks the works with different frequencies and priorities each task is represented by a function void f1(void),..etc. f1 is higher priority than f2 and it interrupt its execution and when finished f2 continues. the question is how to calculate the actual execution of f1 and f2 without pauses? second question? is their anyway to calculate the worst case execution time of a functions?
Haven't you tabulated a list of all your available timing resources and then given them + or - for their advantages or disadvantages? What exact functionality does your specific RTC give you? Can it measure short enough times with the required resolution? Can it measure long enough times with the required resolution? Can it function as an RTC at the same time as you use it to measure time slices?
You - the designer - must be the one who keeps track of what resources you have, and what timing resolution they have, and what timing resolution you want/need for computing the length of the individual time slices. And what the shortest/longest time slices possible are. And what happens if/when the timing hardware overflows.
Note that some threads may consume a tiny sliver of time before returning back to calling one of the "wait" methods available, while some other threads may try to get as much time as possible requiring the OS itself to step in and force a task switch.
Next thing to consider - should you try to compute time spent in interrupts? If they aren't instrumented for the task, then it's likely that such measurements will consume a significant amount of additional CPU time. And what about time spent in system functions?
Being a software designer means that you must spend own time actually designing. Decisions you must make, based on your specific requirements. There are not any one single correct answer you can poll the world for - the difference between being a good or bad designer is just how often you'll select a route that is good enough, and how often you need to rework a bad choice. But it's still better to sometimes makes a bad decision compared to always expecting someone else to think for you.