sjf调度算法_如何通过动态方法预测SJF调度中未来过程的突发时间?

本文介绍了在SJF调度算法中如何通过动态方法预测未来进程的突发时间,包括简单平均和指数平均(老化)两种技术。简单平均是取已执行进程的平均突发时间,指数平均则考虑了平滑因子来平衡历史和当前数据的权重。通过实例展示了这两种方法的计算过程。
摘要由CSDN通过智能技术生成

sjf调度算法

Prerequisites: Static methods to predict burst time in SJF Scheduling

先决条件: SJF计划中预测突发时间的静态方法

动态方法 (Dynamic Method)

We can dynamically predict the burst time of future process by following two techniques,

我们可以通过以下两种技术动态预测未来过程的爆发时间:

  1. Simple Averaging

    简单平均

  2. Exponential averaging or Aging

    指数平均或老化

1)简单平均 (1) Simple Averaging)

In the simple averaging method, the average burst time is taken of all the processes that have executed till now.

在简单的平均方法中,平均突发时间被采用到现在为止已执行的所有进程。

There is a total of n processes P(1), P(2), ... , P(n) and burst time of each process P(i) as t(i),

共有n个进程P(1),P(2),...,P(n) ,每个进程P(i)的突发时间为t(i)

where i = 1,2,3, ..., n.

其中i = 1,2,3,...,n

The predicted burst time for process P(n+1) is T(n+1) given by the following,

进程P(n + 1)的预计突发时间为T(n + 1) ,如下所示:

T(n+1) = (1/n) ∑ t(i)

T(n + 1)=(1 / n)∑ t(i)

Example: There are processes P1, P2, P3, and P4. The burst time of these processes is 6, 3, 4, 7.

示例:存在进程P1P2P3P4 。 这些过程的突发时间为6、3、4、7

Then the average burst time of the newly arrived process is calculated as:

然后,新到达进程的平均突发时间计算为:

    Average burst time 
        = (P1 + P2 + P3 + P4)/4
        = (6+3+4+7)/4
        = 20/4
        = 5 units

2)指数平均或老化 (2) Exponential averaging or Aging)

Let, t(n) be the actual burst time of nth process. T(n) be the predicted burst time for nth process then the CPU burst time for the next process T(n+1) given by the following,

t(n)为第n 进程的实际突发时间。 T(n)是第n 进程的预测突发时间,然后是下一个进程的T(n + 1)的CPU突发时间,如下所示:

T(n+1) = α. t(n) + (1-α) . T(n)

T(n + 1)=α。 t(n)+(1-α) T(n)

Where, α is the smoothening factor, where 0<= α <=1

其中, α是平滑因子,其中0 <=α<= 1

Smoothening factor (α)

平滑系数(α)

It controls and manages the relative weight of the recent and past history of processes in our prediction,

在我们的预测中,它控制和管理过程的最近和过去历史的相对权重,

  • If α = 0, Τ(n+1) = Τ(n), it represents there is no change in the value of initial predicted burst time.

    如果α= 0Τ(n + 1)=Τ(n) ,则表示初始预测突发时间的值没有变化。

  • If α = 1, Τ(n+1) = t(n), it represents predicted burst-time of the new process will always change according to actual burst-time of the nth process.

    如果α= 1Τ(n + 1)= t(n) ,则表示新进程的预测突发时间将始终根据第n 进程的实际突发时间而变化。

  • If α = 1/2, it represents the current and past history of equally-weighted processes.

    如果α= 1/2 ,则表示等权过程的当前和过去历史。

Example:

例:

In this example, if the predicted burst time for the first process is 20 units and the actual burst time of the first four processes is 6, 10, 4 and 7 units respectively. Given α = 0.5. Then we will calculate the predicted burst time using the exponential averaging technique for the fifth process.

在此示例中,如果第一个进程的预测突发时间为20个单位 ,而前四个进程的实际突发时间分别为6、10、4和7个单位。 给定α= 0.5。 然后,我们将使用指数平均技术为第五个过程计算预测的突发时间。

So given that, predicted burst time for first process = 20 units.

因此,鉴于此,第一道工序的预计破裂时间为20个单位

And actual burst time of the first four processes are as follows = 6, 10, 4, 7.

并且前四个过程的实际突发时间如下= 6,10,4,7

And the smoothening factor (α) = 0.5.

平滑因子(α)= 0.5

We can calculate the predicted Burst Time for the second Process by,

我们可以通过以下公式计算第二个过程的预计爆发时间:

    = α * Actual burst time of first process + (1-α) * Predicted burst time for first process
    = 0.5 * 6 + 0.5 * 20
    = 3 + 10
    = 13 units

We can calculate predicted Burst Time for third Process by,

我们可以计算出第三过程的预测爆发时间,

    = α * Actual burst time of second process + (1-α) * Predicted burst time for second process
    = 0.5 * 10 + 0.5 * 13
    = 5 + 6.5
    = 11.5 units

We can calculate predicted burst time for fourth process by,

我们可以计算出第四过程的预测突发时间,

    = α * Actual burst time of third process + (1-α) * Predicted burst time for third process
    = 0.5 * 4 + 0.5 * 11.5
    = 2 + 5.75
    = 7.75 units

We can calculate predicted Burst Time for fifth Process by,

我们可以计算出第五个过程的预测爆发时间,

    = α * Actual burst time of fourth process + (1-α) * Predicted burst time for fourth process
    = 0.5 * 7 + 0.5 * 7.75
    = 3.5 + 3.875
    = 7.375 units

References:

参考文献:

翻译自: https://www.includehelp.com/operating-systems/how-can-be-predict-the-burst-time-of-future-process-in-sjf-scheduling-by-dynamic-method.aspx

sjf调度算法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值