实时应用程序的操作系统服务的按比例分配计划 [英] Proportional Share Scheduling of Operating System Services for Real-Time Applications

查看:79
本文介绍了实时应用程序的操作系统服务的按比例分配计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用c ++代码为实时应用算法提供共享调度操作系统服务.

I need the share scheduling operating system service for real time application algorithm in c++ code. is there any one can help me ?

推荐答案

我认为您需要为您想象中的RTOS编写上下文切换功能. (上下文切换或任务计划程序是RTOS中的功能,它决定应该计划哪个任务.)

我假设没有优先级,也没有必要为更高优先级的任务分配更多的CPU时间.

正如您希望用C/C ++编写的那样,为了满足您的要求,调度程序应该有一个指向所有任务入口点的函数指针表,以及每个任务消耗的CPU时间的运行时数据(数组),因此远的.我们将其称为"CPU滴答计数器",每个任务将有一个.

分配的第一部分是安排正确的任务(到目前为止,为确保公平起见,该任务的CPU时间比其他任务少)

简单地说,您将在数组中找到最低的CPU滴答计数器,并安排该任务(通过函数指针调用).

任务的第二部分是正确维护任务的滴答计数器.为了准确地做到这一点,您需要在固定的计时器中断控制下进行测量.在中断例程中,您将确定当前正在运行的任务,并增加该任务的滴答计数器.如果这是一项家庭作业,那么您可以简单地暗示一个事实,即这将是必需的,并且可能无需编写实际代码即可摆脱它.

最后,您需要做一些内务处理,并防止滴答计数器溢出.简而言之,您可以从所有任务的CPU滴答计数器中减去最小值,最佳时间是在计划任务之前.当然,在这种情况下,将要调度的任务的滴答计数器为0,非常干净.如果正确执行此操作,几乎可以保证A +级.

干杯
I think you are required to write the context switch function for your imagined RTOS. (The context switch or the task scheduler is the function in the RTOS which decides which task should be scheduled).

I assume there are no priorities and that there is no need to give more CPU time to higher priority tasks.

As you want it written in C/C++, to achieve your requirement, the scheduler should have a table of function pointers to all task''s entry points, and also run-time data (array) on CPU time that each task consumed so far. We will call it "CPU tick counter", and you will have one per each task.

The first part of the assignment is to schedule the correct task (the one that so far has had less CPU time than others, to ensure fairness)

Simplistically, you would find the lowest CPU tick counter in the array and schedule that task (call it via a function pointer).

The second part of the task is to correctly maintain the task''s tick counters. To do it accurately, you need to measure this under a fixed timer interrupt control. Inside the interrupt routine, you will identify which task is currently running, and increment the tick counter for that task. If this is a homework assignment, you can simply allude to the fact that this will be required and may get away with it without writing the actual code for it.

And finally, you want to do some housekeeping - and prevent the tick counters from overflowing. Simplistically, you can subtract the the lowest value from CPU tick counters of all tasks, the best time to do this is just before you schedule the task. Of course, in this case the task which will be scheduled will have the tick counter of 0 which is kind-of neat. If you do this correctly, an A+ grade is almost guaranteed.

Cheers


这篇关于实时应用程序的操作系统服务的按比例分配计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆