当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

中国科学技术大学:《Linux操作系统分析》课程教学资源(PPT课件讲稿)Linux进程管理(3/3)

资源类别:文库,文档格式:PPT,文档页数:51,文件大小:2.26MB,团购合买
进程调度
点击下载完整版文档(PPT)

主要内容 进程描述符 冬进程切换 进程的创建和删除 学 冬进程调度 1958 2023/7/14 嵌入式系统实验室 Linux操作系统分析 2152 EMBEDDED SYSTEM LABORATORY 百uE料DUAN0 ITUTE FOR AOVANCED5 FUOY DF U百TC

2023/7/14 Linux操作系统分析 2/52 主要内容 ❖进程描述符 ❖进程切换 ❖进程的创建和删除 ❖进程调度

进程的分类 冬不同类型的进程有不同的调度需求 必第一种分类: >I/O-bound ●频繁的进行I/01958 ●通常会花费很多时间等待/○操作的完成 >CPU-bound ●计算密集型 ● 需要大量的CPU时间进行运算 Ccience and Technoloc 嵌入式系统实验室 2023/7/14 Linux操作系统分析 3/52 EMBEDDED SYSTEM LABORATORY 5uE料DUAN0 ITUTE FOR AOVANCED5 FUOY OF U百TC

2023/7/14 Linux操作系统分析 3/52 进程的分类 ❖不同类型的进程有不同的调度需求 ❖第一种分类: ➢I/O-bound ⚫频繁的进行I/O ⚫通常会花费很多时间等待I/O操作的完成 ➢CPU-bound ⚫计算密集型 ⚫需要大量的CPU时间进行运算

第二种分类 >交互式进程(interactive process) ●需要经常与用户交互,因此要花很多时间等待用户输入操作 ●响应时间要快,平均延迟要低于50~150ms 。典型的交互式程序:shel、文本编辑程序、图形应用程序等 1958 嵌入式系统实验室 2023/7/14 Linux操作系统分析 4152 EMBEDDED SYSTEM LABORATORY 5uE料DUAN0 ITUTE FOR AOVANCED5 FUOY OF U百TC

2023/7/14 Linux操作系统分析 4/52 ❖第二种分类 ➢交互式进程(interactive process) ⚫需要经常与用户交互,因此要花很多时间等待用户输入操作 ⚫响应时间要快,平均延迟要低于50~150ms ⚫典型的交互式程序:shell、文本编辑程序、图形应用程序等

>批处理进程 (batch process ●不必与用户交互,通常在后台运行 ●不必很快响应 ●典型的批处理程序:编译程序、科学计算 >实时进程(real-time process) ●有实时需求,不应被低优先级的进程阻塞 ●响应时间要短、要稳定 ●典型的实时进程:视频/音频、机械控制等 of Science and Technolg 嵌入式系统实验室 2023/7/14 Linux操作系统分析 5/52 EMBEDDED SYSTEM LABORATORY 5uE料DUAN0 ITUTE FOR AOVANCED5 FUOY OF U百TC

2023/7/14 Linux操作系统分析 5/52 ➢批处理进程(batch process) ⚫不必与用户交互,通常在后台运行 ⚫不必很快响应 ⚫典型的批处理程序:编译程序、科学计算 ➢实时进程(real-time process) ⚫有实时需求,不应被低优先级的进程阻塞 ⚫响应时间要短、要稳定 ⚫典型的实时进程:视频/音频、机械控制等

Linux中的进程调度 。Linux既支持普通的分时进程,也支持实时进程 冬Linux中的调度是多种调度策略和调度算法的混 合。 什么是调度策略?958 >是一组规则,它们决定什么时候以怎样的方式选择一 个新进程运行 Linux的调度基于分时和优先级 >随着版本的变化,分时技术在不断变化 嵌入式系统实验室 2023/7/14 Linux操作系统分析 6/52 EMBEDDED SYSTEM LABORATORY 5uE料DUN0 ITUTE FOR AOVANCED5 UOY DF U百TC

2023/7/14 Linux操作系统分析 6/52 Linux中的进程调度 ❖Linux既支持普通的分时进程,也支持实时进程 ❖Linux中的调度是多种调度策略和调度算法的混 合。 ❖什么是调度策略? ➢是一组规则,它们决定什么时候以怎样的方式选择一 个新进程运行 ❖Linux的调度基于分时和优先级 ➢随着版本的变化,分时技术在不断变化

冬Linux的进程根据优先级排队 >根据特定的算法计算出进程的优先级,用一个值表示 >这个值表示把进程如何适当的分配给CPU Linux中进程的优先级是动态的 >调度程序会根据进程的行为周期性的调整进程的优先 级 ●较长时间未分配到CPU的进程,通常个 已经在CPU上运行了较长时间的进程,通常) 嵌入式系统实验室 2023/7/14 Linux操作系统分析 7152 EMBEDDED SYSTEM LABORATORY 5uE料DUAN0 ITUTE FOR AOVANCED5 FUOY OF U百TC

2023/7/14 Linux操作系统分析 7/52 ❖Linux的进程根据优先级排队 ➢根据特定的算法计算出进程的优先级,用一个值表示 ➢这个值表示把进程如何适当的分配给CPU ❖Linux中进程的优先级是动态的 ➢调度程序会根据进程的行为周期性的调整进程的优先 级 ⚫较长时间未分配到CPU的进程,通常↑ ⚫已经在CPU上运行了较长时间的进程,通常↓

与调度相关的系统调用 nice getpriority/setpriority sched getscheduler/sched setscheduler sched getparam/sched setparam sched yield *sched_get priority_min/sched_get priority_max sched rr get interval Ecience and Technolv 嵌入式系统实验室 2023/7/14 Linux操作系统分析 8152 EMBEDDED SYSTEM LABORATORY 5uE料DUAN0 ITUTE FOR AOVANCED5 FUOY OF U百TC

2023/7/14 Linux操作系统分析 8/52 与调度相关的系统调用 ❖nice ❖getpriority/setpriority ❖sched_getscheduler/sched_setscheduler ❖sched_getparam/sched_setparam ❖sched_yield ❖sched_get_priority_min/sched_get_priority_max ❖sched_rr_get_interval

例如 nice(2)-Linux man page Name nice-change process priority Synopsis #include int nice(int inc); Description 仅作用于调用者进程 nice()adds inc to the nice value for the calling process.(A higher nice value means a low priority.)Only the superuser may specify a negative increment,or priority increase. The range for nice values is described in getpriority(2). Return Value On success,the new nice value is returned (but see NOTES below).On error,-1 is 室 2023/7/1 returned,and errno is set appropriately

2023/7/14 Linux操作系统分析 9/52 例如 仅作用于调用者进程

getpriority(2)-Linux man page Name getpriority,setpriority-get/set program scheduling priority Synopsis #include #include int getpriority(int which,int who); int setpriority(int which,int who,int prio); Description The scheduling priority of the process,process group,or user,as indicated by which and who is obtained with the getpriority()call and set with the setpriority()call. The value which is one of PRIO_PROCESS,PRIO_PGRP,or PRIO_USER,and who is interpreted relative to which(a process identifier for PRIO_PROCESS,process group identifier for PRIO_PGRP,and a user ID for PRIO_USER).A zero value for who denotes(respectively)the calling process,the process group of the calling process,or the real user ID of the calling process.Prio is a value in the range-20 to 19(but see the Notes below).The default priority is 0;lower priorities cause more favorable scheduling The getpriority()call returns the highest priority(lowest numerical value)enjoyed by 弋系统实验室 20 any of the specified processes.The setpriority()call sets the priorities of all of the specified processes to the specified value.Only the superuser may lower priorities. SYSTEM LABORATORY TE FOR AOVANCED STUOY DF USTC

2023/7/14 Linux操作系统分析 10/52 又如

sched setscheduler(2)-Linux man page Name sched_setscheduler,sched_getscheduler-set and get scheduling algorithm/parameters Synopsis include int sched setscheduler(pid t pid,int policy, const struct sched param *param) int sched getscheduler(pid t pid); struct sched param int sched priority; }; Description sched_setscheduler()sets both the scheduling policy and the associated parameters for the process identified by pid.If pid equals zero,the scheduler of the calling process will be set.The interpretation of the parameter param depends on the selected policy. Currently,the following three scheduling policies are supported under Linux: SCHED_FIFO,SCHED_RR,SCHED_OTHER,and SCHED_BATCH;their respective semantics are described below. sched_getscheduler()queries the scheduling policy currently applied to the process 2023/7/1 identified by pid.If pid equals zero,the policy of the calling process will be retrieved. 统实验室 MLAB口RATORY UZHDU INSTIYUTE FOR AOVANCED SYUDY DF USTC

2023/7/14 Linux操作系统分析 11/52

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共51页,可试读17页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有