掘金 人工智能 07月18日 17:56
写译 — 我靠!短进程优先调度算法究竟是怎么一回事?
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文深入探讨了短进程优先调度算法(SPF)及其抢占式版本SRT。文章详细阐述了这两种算法的工作原理,包括SPF的非抢占式调度和SRT的抢占式调度机制。同时,文章也指出了它们适用的场景,如批处理系统和短作业较多的情况,并分析了各自的优缺点。SPF相较于FCFS有性能提升,SRT则进一步优化了平均等待时间。然而,SPF可能导致长作业“饥饿”,且依赖于进程预估的处理器使用时间,而SRT则因频繁计算剩余时间而带来较大的开销。

💡 **SPF(Shortest Process First)** 是一种非抢占式调度算法,它根据就绪队列中进程预估的处理器使用时间来选择剩余时间最短的进程执行。在作业调度中,它被称为短作业优先调度(SJF),依据作业所需执行时间选择最短的作业。SPF在特定条件下(如待调度进程同时可运行或同时到达)能提供最优的平均等待时间和周转时间。

⚡️ **SRT(Shortest Remaining Time)** 是SPF的抢占式版本,它选择剩余运行时间最短的进程执行。如果当前进程运行时有就绪队列中出现所需时间更短的新进程,新进程将抢占处理器,原进程转为就绪状态。SRT能够进一步优化平均等待时间。

🎯 **适用场景与优缺点**:SPF和SRT都适用于批处理系统,尤其适合短作业多的场景。SPF相比FCFS性能更优,但可能导致长作业“饥饿”,且依赖于不一定准确的进程时间预估。SRT虽然进一步缩短了平均等待时间,但频繁计算剩余时间会增加系统开销。

🤔 **预估时间与差异性考量**:SPF算法的一个关键挑战是需要进程预估其运行时间,这可能导致估算不准确或“谎报”时间的问题。此外,与FCFS一样,SPF未能充分考虑到不同进程之间的差异性,这也是其局限性之一。


【原文内容】

    短进程优先调度算法(SPF和SRT)
      工作原理: 可以适用于作业调度、进程调度。
      1> SPF(Shortest Process First)非抢占式,在进程调度时,根据就绪队列中排队的进程所预估的处理器使用时间,每次调度选择预估剩余处理器使用时间最短的进程 ;在作业调度时,称为短作业优先调度算法(Shortest Job First, SJF),根据外存队列中作业所要求的执行时间来调度作业,每次调度选择预估剩余处理器使用时间最短的作业。
      2> SRT(Shortest Remaining Time)抢占式,选择剩余运行时间最短的进程执行;如果在当前进程运行过程中,就绪队列中出现了要求时间更短的进程,则这个要求时间更短的进程会抢占处理器资源,当前运行的进程状态会由执行态变为就绪态。适用情景:适合批处理系统,尤其是短作业较多的场景。优点
      1> SPF(Shortest Process First):较FCFS性能更好,如果调度时满足“待调度进程同时可运行” 或者 “待调度进程都几乎同时到达”,那么SPF的平均等待时间和平均周转实际是最优的
      2> SRT(Shortest Remaining Time):进一步优化平均等待时间。缺点
      1> SPF(Shortest Process First):长作业可能“饥饿”;算法需要进程预估其运行时间,在预估时,可能出现估算时间不准确 或者 进程“谎报”时间等问题;同FCFS一样,未考虑到不同进程间的差异性。
      2> SRT(Shortest Remaining Time):需要频繁计算剩余时间,开销较大。

【第一版翻译:(润色前,手译)】

    Shortest Process First (SPF and SRT)
      FUNCTIONAL PRINCIPLES : it's applicable to both job scheduling and process scheduling.
      1> SPF(Shortest Process First) : it's non-preemptive. During each process scheduling event, the system selects the process which holds the shortest Estimated CPU Burst Time according to all of processes' estimated CPU burst time in the ready queue. When it turns to job scheduling, it's claimed as Shortest Job First(SJF); The system selects the job which holds the shortest estimated remaining CPU burst time, scheduling processes according to all of jobs' execution time in the Secondary Storage Queue.
      2> SRT(Shortest Remaining Time) : It's preemptive. The system selects the process which holds the shortest remaining run time to execute; If within current process's function duration a process that needs shorter time appears in the ready queue, then this process which needs shorter time preempts processor resource, and current process turns its state from the running state to the ready state.APPLICABLE SCENARIOS : it's suitable to Batch Processing Systems, especially when short jobs are major.ADVANTAGES :
      1> SPF(Shortest Process First) : it's better than FCFS in terms of performance. If scheduling conditions contain "All processes ready for scheduling simultaneously" or "All processes arrive at nearly the same time", the SPF's average waiting time and average turnaround time are optimal
      2> SRT(Shortest Remaining Time) : further optimizes the average waiting time.DISADVANTAGES :
      1> SPF(Shortest Process First) : Long jobs may end up with "Starvation"; Algorithm needs processes to estimate their function time, but there may be some of issues emerging, for instance, the given time can be inaccurate or fake; Like FCFS, it does not consider the differential among different processes.
      2> SRT(Shortest Remaining Time) : It needs to calculate remaining time frequently so its cost is relatively high.

【第二版翻译:(润色后,雅思水准)】

    Shortest Process First (SPF and SRT)
      FUNCTIONAL PRINCIPLES : This algorithm is applicable to both job scheduling and process scheduling.
      1> SPF(Shortest Process First) : This is a non-preemptive algorithm. During each process scheduling event, the system selects the process with the shortest Estimated CPU Burst Time from the ready queue. When applied to job scheduling, it is known as Shortest Job First(SJF). In this context, the system selects the job with the shortest estimated remaining execution time, scheduling jobs according to all of jobs' execution time in the Secondary Storage Queue.
      2> SRT(Shortest Remaining Time) : It is preemptive. The system selects the process with the shortest remaining run time to execute; If, during the current process's execution, a new process requiring a shorter remaining time appears in the ready queue, then this new process preempts the processor resource, and the current process transitions from the running state to the ready state.APPLICABLE SCENARIOS : It is suitable for Batch Processing Systems, especially in scenarios where short jobs are prevalent.ADVANTAGES :
      1> SPF(Shortest Process First) : It generally offers better performance than FCFS. If scheduling conditions involve "All processes ready for scheduling simultaneously" or "All processes arriving at nearly the same time", the SPF yields optimal average waiting time and average turnaround time
      2> SRT(Shortest Remaining Time) : It further optimizes the average waiting time.DISADVANTAGES :
      1> SPF(Shortest Process First) : Long jobs may experience "Starvation"; The algorithm requires processes to estimate their execution time, but issues may arise during estimation, such as inaccurate or fabricated time values; Like FCFS, it does not consider the variation among different processes.
      2> SRT(Shortest Remaining Time) : It requires frequent calculation of remaining time, leading to relatively high overhead.

【生词整理】


【写译手稿】

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

短进程优先调度 SPF SRT 进程调度 算法优化
相关文章