进程调度赖以运行的基础设施

内核进程调度剖析 1 介绍 对于内核主要分为:进程管理,内存管理,文件系统,内核协议栈四部分。 而对于进程管理主要有创建进程方式,进程调度,内核线程等 进程在内核中描述定义(task_struct)和调度器(sched) 2 调度器 调度器功能是模块化结构,主要工作可以完全由特定调度类方法执行。 cur->sched_class->task_tick(rq,curr,0); 内核核心调度器:主要分为周期性调度器函数和主调度器函数 1 周期性调度器函数 内核中由scheduler_tick()函数实现。 主要工作 阅读详情
Each process descriptor includes several fields related to scheduling:

        thread_info
     |--------------|
 +---|*task         |
 |   |--------------|
 |   |              |
 |   |--------------|
 |   |flags         |flags中的TIF_NEED_RESCHED为1表明该进程
 |   |--------------|需要调用schedule()
 |   |              |
 |   |--------------|
 |   |cpu           |Logical number of the CPU owning the
 |   |--------------|runqueue to which the runnable process belongs
 |   |              |
 |   |--------------|<--内核堆栈低端地址
 |
 |
 |
 |       task_struct
 |   |----------------|
 +-->|state           |TASK_RUNNING
     |----------------|
     |*thread_info    |
     |----------------|
     |prio            |调度程序要用到的动态优先级存放在prio域中
     |----------------|
     |static_prio     |静态优先级,影响进程获得CPU时间的多少
     |----------------|
     |run_list        |Pointers to the next and previous elements
     |----------------|in the runqueue list to which the process belongs
     |                |
     |----------------|
     |array           |    Pointer to the runqueue's
     |----------------|    prio_array_t set that includes the process
     |sleep_avg       |Average sleep time of the process
     |----------------|
     |                |
     |                |
     |----------------|
     |policy          |The scheduling class of the process
     |----------------|(SCHED_NORMAL, SCHED_RR, or SCHED_FIFO)
     |                |
     |----------------|
     |time_slice      |Ticks left in the time quantum of the process
     |----------------|
     |first_time_slice|Flag set to 1 if the process
     |----------------|never exhausted its time quantum
     |                |
     |                |
     |----------------|
     | rt_priority    |Real-time priority of the process
     |----------------|
     |                |
     |                |
     |----------------|



task_struct.activated  (int)
    Condition code used when the process is awakened
    表示进程因什么原因进入就绪态,这一原因会影响到调度优先级的计算。activated 有四个值:
  • -1,进程从 TASK_UNINTERRUPTIBLE 状态被唤醒;
  • 0,缺省值,进程原本就处于就绪态;
  • 1,进程从 TASK_INTERRUPTIBLE 状态被唤醒,且不在中断上下文中;
  • 2,进程从 TASK_INTERRUPTIBLE 状态被唤醒,且在中断上下文中。
    activated 初值为 0,在两个地方修改,一是在 schedule() 中,被恢复为 0,另一个就是 activate_task(),这个函数由 try_to_wake_up() 函数调用,用于激活休眠进程:
  • 如果是中断服务程序调用的 activate_task(),也就是说进程由中断激活,则该进程最有可能是交互式的,因此,置 activated=2;否则置activated=1。   
  • 如果进程是从 TASK_UNINTERRUPTIBLE 状态中被唤醒的,则 activated=-1(在try_to_wake_up()函数中)。
task_stuct.timestamp (unsigned long long)
    Time of last insertion of the process in the runqueue, or time of last process switch involving the process.
    该进程进入sleeping状态的时间戳;或者该进程最新一次得到CPU控制权的时间戳

task_struct.run_list (struct list_head)
    Pointers to the next and previous elements in the runqueue list to which the process belongs.
    指向该进程所在队列中的前后进程

task_struct.cpus_allowed ( cpumask_t)  
    Bitmask of the CPUs that can execute the process
    可以执行该进程的CPU掩码集




  • task_struct.static_prio

    Processes have an initial priority that is called the nice value. This value ranges from 20 to +19 with a default of zero. Nineteen is the lowest and 20 is the highest priority. This value is stored in the static_prio member of the process's task_struct. The variable is called the static priority because it does not change from what the user specifies. The scheduler, in turn, bases its decisions on the dynamic priority that is stored in prio. The dynamic priority is calculated as a function of the static priority and the task's interactivity.
    进程拥有一个初始的优先级,叫做nice值。该数值变化范围为-20到+19,默认值为0。19优先级最低,-20最高。进程task_struct的 static_prio域就存放着这个值(存放着用nice计算出来的static_prio),之所以起名为静态优先级(static priority),是因为它从一开始由用户指定后,就不能改变。而调度程序要用到的动态优先级存放在prio域里。动态优先级通过一个关于静态优先级和进程交互性的函数关系计算而来。

static priority of a conventional process
    The kernel represents the static priority of a conventional process with a number ranging from 100 (highest priority) to 139 (lowest priority); notice that static priority decreases as the values increase.
static priority [0, 139]
static priority of a conventional process: [100, 139]

nice--> static_prio
    A new process always inherits the static priority of its parent. However, a user can change the static priority of the processes that he owns by passing some "nice values" to the nice( ) and setpriority( ) system calls.
nice: [-20, 19]

用nice计算static_prio:
#define NICE_TO_PRIO(nice)   (MAX_RT_PRIO + (nice) + 20)
#define MAX_RT_PRIO          MAX_USER_RT_PRIO
#define MAX_USER_RT_PRIO     100



  • task_struct.prio

    Besides a static priority, a conventional process also has a dynamic priority, which is a value ranging from 100 (highest priority) to 139 (lowest priority). The dynamic priority is the number actually looked up by the scheduler when selecting the new process to run.

    The method effective_prio() returns a task's dynamic priority. The method begins with the task's nice value and computes a bonus or penalty in the range 5 to +5 based on the interactivity of the task. For example, a highly interactive task with a nice value of ten can have a dynamic priority of five. Conversely, a mild processor hog with a nice value of ten can have a dynamic priority of 12. Tasks that are only mildly interactiveat some theoretical equilibrium of I/O versus processor usagereceive no bonus or penalty and their dynamic priority is equal to their nice value.
    effective_prio()函数可以返回一个进程的动态优先级。这个函数以nice值为基数,再加上-5到+5之间的进程交互性的奖励或罚分。一个交互性很强的进程(I/O消耗性的进程),即使它的nice值为10,它的动态优先级最终也有可能达到5。相反,一个处理器消耗性的进程,虽然本来nice值一样是10,它最后的动态优先级却可能是12。交互性不强也不弱的进程不会得到优先级的奖励,同样也不会被罚分,所以它的动态优先级和它的nice值相等。

dynamic priority of a conventional process: [100, 139]
dynamic priority = max ( 100, min(static priority - bonus + 5, 139) )
bonus: [0, 10]

(>200ms)      (2)
sleep_avg --> bonus  ----+    
                         |    
                         +----->prio
                         |    
        static_prio  ----+  

  • task_struct.sleep_avg
    To implement this heuristic, Linux keeps a running tab on how much time a process is spent sleeping versus how much time the process spends in a runnable state. This value is stored in the sleep_avg member of the task_struct. It ranges from zero to MAX_SLEEP_AVG, which defaults to 10 milliseconds. When a task becomes runnable after sleeping, sleep_avg is incremented by how long it slept, until the value reaches MAX_SLEEP_AVG. For every timer tick the task runs, sleep_avg is decremented until it reaches zero.
    为了支持这种机制,linux记录了一个进程用于休眠和用于执行的时间,该值存放在task_struct的sleep_avg域中。它的范围从0到MAX_SLEEP_AVG。它的默认值为10毫秒。当一个进程从休眠状态恢复到执行状态时,sleep_avg会根据它休息时间的长短而增加,直到达到MAX_SLEEP_AVG为止。相反,进程每运行一个时钟节拍,sleep_avg就做相应的递减,到0为止。
A newly created interactive process quickly receives a large sleep_avg.
    粗略地说讲,平均睡眠时间是进程在睡眠状态所消耗的平均纳秒数。注意,这绝对不是对过去时间的求平均值的操作。例如:在 TASK_INTERRUPTIBLE 状态与在 TASK_UNINTERRUPTIBLE状态的所计算出的平均睡眠时间是不同的。   而且, 进程在运行的过程中, 平均睡眠时间递减。最后,平均睡眠时间永远不会大于 1 秒
    task每一次从sleep中醒来,sleep_avg都会加上sleep的时间,直到MAX_SLEEP_AVG。相反,tick结束的时候,sleep_avg也会减去运行的时间, 直到0

sleep_avg --> interactive
    The average sleep time is also used by the scheduler to determine whether a given process should be considered interactive or batch. More precisely, a process is considered "interactive" if it satisfies the following formula:
dynamic priority  <=  3 * static priority / 4 + 28   (3)
which is equivalent to the following:
bonus - 5 >= static priority / 4 - 28
    The expression static priority / 4 - 28 is called the interactive delta ;It should be noted that it is far easier for high priority than for low priority processes to become interactive. For instance, a process having highest static priority (100) is considered interactive when its bonus value exceeds 2, that is, when its average sleep time exceeds 200 ms.

(>200ms)      (2)    
sleep_avg --> bonus  ----+      +--> interactive
                         |      |      
                         +------+根据公式(3)判断交互性      
                         |      |
        static_prio  ----+      +-->  batch


  • task_struct.time_slice

    Timeslice, on the other hand, is a much simpler calculation. It is based on the static priority.After a task's timeslice is exhausted, however, it is recalculated based on the task's static priority. The function task_timeslice() returns a new timeslice for the given task. The calculation is a simple scaling of the static priority into a range of timeslices.(时间片的计算只需要把静态优先级按比例缩放,使其符合时间片的数值范围要求就可以了)
    The higher a task's priority, the more timeslice it receives per round of execution.(进程的静态优先级越高,它每次执行得到的时间片就越长)
    The maximum timeslice, which is given to the highest priority tasks (a nice value of -20), is 800 milliseconds. Even the lowest-priority tasks (those with a nice value of +19) receive at least the minimum timeslice, MIN_TIMESLICE, which is either 5 milliseconds or one timer tick, whichever is larger. Tasks with the default priority (a nice value of zero) receive a timeslice of 100 milliseconds.

                          +--> (140 - static priority) * 20  
                          |          (static priority < 120)
(task_struct.time_slice)  |         
  base time quantum =     |                                   
(in milliseconds)         |
                          |          (static priority >= 120)
                          +--> (140 - static priority) * 5   

注:
 -20  nice() /setpriority()      100      (140-100)*20       800ms
nice -----------------------> static_prio --------------> time_slice

进程刚刚生成时其时间片是从父进程那里获得;如果时间片耗尽将根据静态优先级重新计算时间片:
    When a new process is created, sched_fork( ), invoked by copy_process( ), sets the time_slice field of both current (the parent) and p (the child) processes in the following way:
p->time_slice = (current->time_slice + 1) >> 1;
current->time_slice >>= 1;

p->first_time_slice = 1;

task_struct.first_time_slice
    The first_time_slice flag is set to 1, because the child has never exhausted its time quantum (if a process terminates or executes a new program during its first time slice, the parent process is rewarded with the remaining time slice of the child).
    将first_time_slice标志位置为1,是因为子进程还从没有使用过自己的时间片。(如果一个进程在其第一个时间片内执行或终止了新程序,那么其剩余时间片将归还于其父进程)

  • task_struct.thread_info.flags

    The kernel provides the need_resched flag to signify whether a reschedule should be performed. This flag is set by scheduler_tick() when a process runs out of timeslice, and by try_to_wake_up() when a process that has a higher priority than the currently running process is awakened. The kernel checks the flag, sees that it is set, and calls schedule() to switch to a new process. The flag is a message to the kernel that the scheduler should be invoked as soon as possible because another process deserves to run. Upon returning to user-space or returning from an interrupt, the need_resched flag is checked. If it is set, the kernel invokes the scheduler before continuing.
    内核提供了一个need_resched标志来表明是否需要重新执行一个调度。当某个进程耗尽它的时间片时,scheduler_tick()就会设置这个标志;当一个优先级高的进程进入可执行状态的时候,try_to_wake_up()也会设置这个标志。在返回用户空间以及从中断返回的时候,内核也会检查need_resched标志。如果已被设置,内核会在继续执行之前调用 调度程序。

    The flag is per-process, and not simply global, because it is faster to access a value in the process descriptor (because of the speed of current and high probability of it being in a cache line) than a global variable.Historically, the flag was global before the 2.2 kernel. In 2.2 and 2.4, the flag was an int inside the task_struct. In 2.6, it was moved into a single bit of a special flag variable inside the tHRead_info structure. As you can see, the kernel developers are never satisfied.
    每个进程都包含一个need_resched标志,这是因为访问进程描述符内的数值要比访问一个全局变量快(因为current宏速度很快并且描述符通常都在高速缓存中)。在2.2以前的内核版本中,该标志曾经是一个全局变量。2.2到2.4版本内核中它在task_struct中。而在2.6版中,它被移到thread_info结构体里,用一个特别的标志变量中的一位来表示。可见内核开发者是在不断改进。







Linux 中进程的调度算法 在迁移后,再加上迁移后的CPU的运行队列中最小虚拟运行时间。注意到sysctl_sched_child_runs_first那一行,可以指定 /proc/sys/kernel/sched_child_runs_first为1使子进程优先获得调度,如果是0,则 父进程优先获得调度。如果希望实时进程存在的情况下一般进程也可以消耗少量CPU时间,而不是等待实时进 程全部结束后才能执行,可以修改两个控制项:kernel.sched_rt_period_us和 kernel.sched_rt_runtime_us。 阅读详情

相关推荐

Linux操作系统之进程如何调度?

前言 操作系统对我来说很抽象的,学了几年,工作中天天打交道,却不懂它。偶然听了极客时间的一门课(这里就不打广告了),很有启发。其实操作系统就好比一个公司: 进程管理:可以理解为公司的项目管理 内存管理:可以理解为公共资源的管理,比如会议室 文件系统:可以理解为项目开发过程中文档的管理 输入输出系统:可以理解为售前售后体系 公司有很多项目,但人手是有限的,有的项目时间很紧,有的项目是VIP客户,应该先排;有的项目可以缓缓,但也不能让客户等太久,所以作为公司老大,你应该如何分配任务呢? 对操作系统来说,CP

Dufre 1837

进程调度算法

操作系统常见的进程调度算法 调度算法是指:根据系统的资源分配策略所规定的资源分配算法。常见的进程调度算法有:   1.先来先去服务   2.时间片轮转法   3.多级反馈队列算法   4.最短进程优先   5.最短剩余时间优先   6.最高响应比优先   7.多级反馈队列调度算法 一、先来先去服务   先来先去服务调度算法是一种最简单的调度算法,也称为先进先出或严格排队方案。当...

YOUN尔 5万+

海思方案定制hi3531dv200/SS528 DVR方案解析:从硬件选型到编解码实战应用

海思方案,Hi3518EV100,Hi3518CV100,Hi3515CV100,Hi3516CV100,Hi3516ECV100,Hi3516D,Hi3516A,Hi3519,Hi3520D,Hi3521A,Hi3535,Hi3531,Hi3536,Hi3536C,Hi3536D,Hi3518EV200,Hi3518EV201,Hi3520DV200,Hi3516CV200,Hi3516CV300,Hi3516AV200,Hi3520DV300,Hi3519V101,sd3403,hi3519av200

1593

Linux 进程调度浅析

进程调度含义 进程调度决定了将哪个进程进行执行,以及执行的时间。操作系统进行合理的进程调度,使得资源得到最大化的利用。 在单片机上,常常使用的方式是:系统初始化----&gt;while(1){}。(当然,单片机也可以跑类似 FreeRTOS,也可以有进程切换) 在带操作系统的 CPU 上跑的逻辑是,允许多个进程(其实就是程序) ”同时” 跑。比如,你可以在操作鼠标的同时,进行音乐播放,文字...

StephenZhou 1万+

告别命令行恐惧!用nTopology可视化工具5分钟搞定三维Voronoi泡沫建模

本文介绍如何利用nTopology可视化工具快速生成三维Voronoi泡沫结构,无需编程即可完成复杂建模。Voronoi结构在轻量化设计、能量吸收和生物医学等领域具有重要应用,传统命令行方法门槛较高。通过nTopology的四步流程,用户可在5分钟内创建仿真就绪模型,大幅提升设计效率。

weixin_30764771的博客 430

windows中如何将已安装的nodejs高版本降级为低版本

第一步:先清空本地安装的node.js版本 1.按健win+R弹出窗口,键盘输入cmd,然后敲回车(或者鼠标直接点击电脑左面最左下角的win窗口图标弹出,输入cmd再点击回车键) 然后进入命令控制行窗口,并输入where node查看之前本地安装的node的路径 2.找到上面找到的路径,将node.exe所在的父目录里面的所有东西都删除 3.为了彻底删除之前安装的node.js,鼠标点击电脑左面最左下角的win窗口图标弹出,输入“控制面板”再点击回车键进入,进入控制面板后,找到所安装的node.js并

weixin_44582077的博客 9万+

进程调度算法的模拟

编写程序,采用动态优先级调度算法实现进程调度。要求由用户输入进程PCB信息,优先级大的进程优先分配CPU,且优先级每运行一个CPU时间单位就降低一级。 进程状态分为W(就绪)、R(运行)、F(完成)。就绪进程在获得CPU后只能运行一个时间单位。运行后,将进行PCB中已占用CPU的时间加1。如果运行一个CPU时间单位后,进程的已占用时间达到了所需要的运行时间,则撤销该进程。如果运行一个CPU时间单位后,进程的已占用CPU时间尚未达到所需要的运行时间,即进程还需要继续运行,则此时将进程的优先数减1。

m0_71566369的博客 3835

瑞芯微RK809音频驱动

瑞芯微RV1126中的RK809音频驱动开发

m0_61899715的博客 5229

linux进程的调度

进程状态 进程主要有7种状态:就绪状态、运行状态、轻度睡眠、中度睡眠、深度睡眠、僵尸状态、死亡状态。它们之间状态变迁如下: 进程描述符task_struct结构体中有个成员state专门用来描述进程的状态。 就绪状态:state为TASK_RUNNING,正在运行队列中等待调度器调度。 运行状态:state为TASK_RUNNING,被调度器命中,正在处理器中运行。 轻度睡眠:称为可打断的睡眠状态。state为TASK_INTERRUPTIBLE,可以被信号打断。 中度睡眠:state为TASK_KIL

m0_65931372的博客 6410

基于YOLOv11的人脸识别系统:从构建到应用的全流程指南

深度学习是机器学习的一个分支,旨在通过多层神经网络模拟人脑的认知能力。它能够从大量数据中自动提取特征,并进行准确的预测和分类。在计算机视觉领域,深度学习技术已经取得了显著的成果,尤其是在图像识别、目标检测等方面。YOLOv11是YOLO系列模型的最新版本,结合了卷积神经网络(CNN)和其他创新技术。它在保持高精度的同时,显著提高了推理速度。YOLOv11的结构轻量且高效,非常适合实时目标检测任务。人脸检测的目标是从图像或视频中定位所有人脸的位置。

FJN110的博客 187

需求跟踪详解

需求跟踪是指在软件项目开发过程中,建立并维护需求与项目各阶段工作产物(如设计文档、代码模块、测试用例等)之间对应关系的过程。它不仅记录需求从提出到实现的完整路径,还能反映需求变更时对各阶段工作的影响范围,是连接用户期望与实际软件开发产出的桥梁。

跟佟格湾一起学习计算机知识吧~ 1424

进程调度

     这里简单介绍下,进程的调度原理,调度类型和常用的进程调度算法。 进程调度      说道进程调度,我们或许都有个疑问,为什么需要进程调度呢?进程调度的作用是什么?      需要进程调度的理由很充分,即充分利用计算机系统中的CPU资源,让计算机能够多快好省的完成各种任务。为此,可在内存中存放数目远大于计算机系统内CPU个数的进程,让这些进程在操作系统的进程调度器下,能够让进程高效(...

smile_zhangw的博客 1万+

《Linux GPU 驱动核心机制:面向图形与 AI 计算的 DRM 内存管理与任务调度》 目录

本文以缓冲区对象(BO)生命周期为主线,系统解析 Linux DRM 子系统中 GPU 驱动的核心机制。涵盖 GEM 与 TTM 内存管理、dma-buf/dma-fence 共享同步、GPU 调度与地址空间管理,结合 amdgpu、Xe 等驱动代码,深入剖析其设计动机与实现逻辑。旨在填补中文领域对 GPU 内核机制系统性讲解的空白,为图形与 AI 计算场景下的内存泄漏、同步死锁等疑难问题提供可追溯的分析路径。

图形/计算GPU的驱动与虚拟化技术分享园地 3830

[Linux] Linux 的进程如何调度——Linux的 O(1)进程调度算法

当你看过书上的讲解,它通常会将操作系统对进程的调度一笔带过:一个一个的进程会被存储在队列中(称为运行队列),CPU通过运行队列来调度进程。这样的讲解通常让人捉摸不透,Linux操作系统具体是怎么调用进程的?又是怎么一个调用法?能不能用直观的图来表示这样的调度过程?这就是本文着重讲解的内容。在系统当中查找一个最合适调度的进程的时间复杂度是一个常数,不随着进程增多而导致时间成本增加,我们称之为进程调度O(1)算法。

石墨博客 1801

【DRAM存储器六十七】DDR5介绍--训练相关之write leveling

详述DDR5 write leveling细节

highman110的博客 314

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Linux进程管理(二)进程调度

Linux进程管理(二)进程调度 文章目录Linux进程管理(二)进程调度一、进程调度解决什么问题?二、进程调度整体框架三、优先级与调度策略四、调度类五、运行队列和调度实体六、FIFO 和 RR 调度算法七、完全公平调度算法(CFS)八、总结 一、进程调度解决什么问题? 我们在使用电脑的时候,比如打开一个视频剪辑器,一个文本编辑器,可以认为它们都是一个进程。假如CPU是单核的,那么在同一时间只能运...

JT同学的博客 3507

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

【Linux进程调度】

调度是指操作系统内核中的调度器(Scheduler)负责分配CPU时间给各个进程,以确保系统资源的高效、公正分配。

weixin_40146547的博客 1816

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

进程调度实验,python实现

一、 设计一个有N个进程其行的进程调度算法。 进程调度算法:采用最高优先数的调度算法(即把处理机分配给优先数最高的进程)。 每个进程有一个进程控制块(PCB)表示。进程控制块可以包含如下信息:进程名、优先数、到达时间、需要运行时间、已用CPU时间、进程状态等等。 进程的优先数及需要的运行时间可以事先人为的指定(也可以由随机数产生)。进程的到达时间为进程的输入的时间。 进程的运行时间以时间片为单位进...

sdm12345的博客 4603

Linux 内核进程调度

CPU消耗型进程需要高的吞吐率,IO消耗型进程需要强的响应性,这两点都是调度器需要考虑的。为了更快响应IO消耗型进程,内核提供了一个抢占(preempt)机制,使优先级更高的进程,去抢占优先级低的进程运行。

LiuYong_01的博客 1519

深入Linux内核(进程篇)—进程调度

进程调度

liyuewuwunaile的博客 3825

操作系统进程调度算法,进程调度实验

用高级语言编写和调试一个进程调度程序,以加深对进程的概念及进程调度算法的理解。

qq_25015861的博客 2674

进程调度—主动调度

调度程序主要涉及4个方面,分别是主动调度、周期调度、高精度时钟调度、进程唤醒时调度,本次分析主动调度。

weixin_48405654的博客 819

调度器之调度类、运行队列

就是按照某种调度的算法设计,从进程的就绪队列当中选取进程分配CPU,主要是协调对CPU等相关资源的使用。。

congchp的博客 997

进程的调度方式,调度算法总结

进程的三种状态: 1、等待态:等待某个事件的完成; 2、就绪态:等待系统分配处理器以便运行 3、运行态:占有处理器正在运行 三种状态的转化: 运行态到等待态:往往是由于等待外设,等待主存等资源分配或等待人工干预而引起的; 等待态到就绪态:等待的条件已经满足,只需要分配到处理器后就能运行; 就绪态到运行态:系统按某种策略选中就绪队列中的一个进程占用处理器; 运行态到就绪态:由

vqtyh的博客 5943

进程调度模拟

采用最高优先数的调度算法(即把处理机分配给优先数最高的进程)。(1)先定义每个进程有一个进程控制块(PCB)表示。(2)其次设计每个进程状态为就绪 W(Wait)、运行 R(Run)、或完成 F(Finish)三种状态。(3)使用一个固定就绪队列与进程静、动态优先级相结合的方式实现进程调度。进程优先级范围0~0xFF(即 0~255),以小的数字为高优先级,大的数字为低优先级。

princekin_even的博客 3115
上一篇: 新年、新博客、新起点
下一篇: 运行队列和优先级数组
linux__kernel
博客等级 码龄20年 20粉丝 64原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址