Closed hduffddybz closed 9 years ago
IMHO, the core of RM is:
1. tasks with long period has low priority.
2. the system always runs the runnable highest priority task.
So, you will get the latter for free if you use the current kernel. But for the former, how does the kernel would know the period of a task at the time initializing the task? How does the kernel assign the priority for a task relatively to other tasks that has not been initialized by the kernel?
So, IMHO, even for the bare RM algorithm, we need off-line analyze to figure out the priorities for each tasks. Once the off-line analyze is done, than you can assign the priority for each task in rt_thread_{init,create}
. Then you get RM for free.
Please correct me if I'm wrong ;-)
BTW, are you going to Harvard? Congratulations!! ;-D
Welcome to do more research base on RT-Thread. To add one or more scheduling algorithm, the scheduler interface need to be modified. If that, please let me know.
how does the kernel would know the period of a task at the time initializing the task?
This period should be set by the programmer since that all this tasks that may include sensor capturing or machine control should be executed at a regular interval all depending on the application.
How does the kernel assign the priority for a task relatively to other tasks that has not been initialized by the kernel?
All the periodic tasks should be initialized when system start up, and all the schedulability analysis should be done before the system start up which made by the off-line tool.What cannot predict for a real-time system may only contains the aperiodic tasks when system is running.
even for the bare RM algorithm, we need off-line analyze to figure out the priorities for each tasks.
What the off-line analysis to do should include that whether the system can be scheduled for these periodic tasks but the assignment of priority for these tasks should be done by the RM scheduling algorithm.
So, if I understand it right, we are going to implement a "off-line tool" which is powered by the RM algorithm to analyze the schedulability and assign priorities for the priodic tasks, right?
Once we archive this, we may deal with the aperiodic tasks. One step by one step.
@grissiom I think you are wrong! The analysis of the schedulability of Real-Time system should be guaranteed by the application programmer! What the kernel should do include:
when implement this algorithm, I think what should do first include:
Change of the kernel(should be independent from the previous algorithm ) may include:
add task criticalness,computation time(worse case execution time),period(task period),relative deadline,utilization factor
the status of thread should include
Since the priority of the task depend on the period of it, so the number of task priorities should not limit to 256, and it is not necessary to use bitmap algorithm. Priority queue may be a good alternative, and what am I confused is that whether the insertion of task should be O(1)(any useful algorithm)?
@hduffddybz In RT-Thread, the TCB of each thread, there is a user data filed: struct rt_thread { ... rt_uint32_t user_data; /*< private user data beyond this thread / };
You can extend your scheduler in this field.
Right now, the task queue with READY status is a priority queue. Therefore, you can use current queue implementation.
Hi! Recently my teacher (at yifanwu) are guiding me to the world of RTOS. So the basic work may include the implementation of some classical scheduling algorithm. It has been widely proved that RM(rate monotonic) scheduling is valuable both in academic research and industry filed!
According to the RM scheduling algorithm, tasks are assigned with fixed priorities by their rates, so the task with lower period can get higher priority.
Any more information should be noticed for the implementation of RM?