中科大操作系统原理与实现课件3_Processes1.pdf

上传人:asd****56 文档编号:70322048 上传时间:2023-01-19 格式:PDF 页数:30 大小:281.57KB
返回 下载 相关 举报
中科大操作系统原理与实现课件3_Processes1.pdf_第1页
第1页 / 共30页
中科大操作系统原理与实现课件3_Processes1.pdf_第2页
第2页 / 共30页
点击查看更多>>
资源描述

《中科大操作系统原理与实现课件3_Processes1.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件3_Processes1.pdf(30页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、.操作系统原理与设计第3章 Processes(进程)2陈香兰中国科学技术大学计算机学院2009年09月01日.提纲Process SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.OutlineProcess SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess Creation

2、Process Termination小结和作业.Process SchedulingThe objective of multiprogramming:?The objective of time sharing:?What the system need?the process scheduler selects an available process to execute on theCPU.Process SchedulingThe objective of multiprogramming:?The objective of time sharing:?What the syste

3、m need?the process scheduler selects an available process to execute on theCPU.Process Scheduling QueuesProcesses migrate among the various queuesIJob queue set of all processes in the systemIReady queue set of all processes residing in main memory,ready and waiting to executeIDevice queues set of p

4、rocesses waiting for an I/O device.Ready Queue And Various I/O Device Queues.Representation of Process SchedulingIa queueing diagram.OutlineProcess SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.Schedulers ILong-term schedule

5、r(or job scheduler)Iselects which processes should be brought into the readyqueueShort-term scheduler(or CPU scheduler)Iselects which process should be executed next and allocatesCPU.The primary distinction between long-term&short-termschedulers IIThe primary distinction between long-term&short-term

6、schedulers lies in frequency of executionIShort-term scheduler is invoked very frequently(UNIT:ms)(must be fast)ILong-term scheduler is invoked very infrequently(UNIT:seconds,minutes)(may be slow)IWHY?IThe long-term scheduler controls the degree ofmultiprogrammingIthe number of processes in memory.I

7、stable?.The primary distinction between long-term&short-termschedulers IIIProcesses can be described as either:I/O-bound processIspends more time doing I/O than computations,many shortCPU burstsCPU-bound processIspends more time doing computations;few very long CPUburstsIIMPORTANT for long-term sche

8、duler:IA good process mix of I/O-bound and CPU-bound processes.IThe long-term scheduler may be absent or minimalIUNIX,MS Windows,.IThe stability depends on.The primary distinction between long-term&short-termschedulers IIIIphysical limitationIself-adjusting nature of human users.Addition of Medium T

9、erm SchedulingIswapping.OutlineProcess SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.Context Switch IICONTEXTIwhen an interrupt occurs;When scheduling occursPCBICPU registersIprocess stateImemory-management infoI.Ioperation:

10、state save VS.state restoreIContext switchIWhen CPU switches to another process,the system must savethe state of the old process and load the saved state for thenew process.Context Switch IIIContext-switch time is overhead;the system does no usefulwork while switchingITime dependent on hardware supp

11、ort(typical:n s)ICPU&memory speedIN of registersIthe existence special instructions.Code readingI观察I队列的组织I上下文的内容和组织I上下文切换Ilinux-0.11Ilinux-2.6.26IuC/OS-II.OutlineProcess SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.Process

12、Creation IIParent process create children processes,which,in turncreate other processes,forming a tree of processesIpidIUNIX&LinuxCommand:ps-el.Process Creation IIIA tree of processes on a typical Solaris.Process Creation IIIIResource sharingIParent and children share all resourcesIChildren share su

13、bset of parents resourcesIParent and child share no resourcesIExecutionIParent and children execute concurrentlyIParent waits until children terminateIAddress spaceIChild duplicate of parentIChild has a program loaded into it.Process Creation IVIUNIX examples:fork+execIfork system call creates new p

14、rocessIexec system call used after a fork to replace the processmemory space with a new program.C Program Forking Separate Process.int main(void)pid t pid;/*fork another process*/pid=fork();if(pid 0)/*error occurred*/fprintf(stderr,“Fork Failed”);exit(-1);else if(pid=0)/*child process*/execlp(“/bin/

15、ls”,“ls”,NULL);else/*parent process*/*parent will wait for the child to complete*/wait(NULL);printf(“Child Complete”);exit(0);.OutlineProcess SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.Process TerminationIProcess executes

16、 last statement and asks the operatingsystem to delete it(exit)IOutput data from child to parent(via wait)IProcess resources are deallocated by operating systemIParent may terminate execution of children processes(abort)IChild has exceeded allocated resourcesITask assigned to child is no longer requ

17、iredIIf parent is exitingSome operating system do not allow child to continue if itsparent terminatesIAll children terminated-cascading termination.小结Process SchedulingProcess Scheduling QueuesSchedulersContext SwitchOperation on processesProcess CreationProcess Termination小结和作业.作业I名词解释:I长中短期调度I多道程序度IIO密集型CPU密集型.华夏班上机作业I基于i386的模拟器(推荐bochs)I编写启动加载程序。(从16位实模式启动,加载OS代码,进入32位保护模式,能调用C语言编写的OS入口程序)I编写任务管理和上下文切换代码I能够从OS入口程序主动切换到被创建的任务上.非华夏班上机作业I在ftp:/alpha.gnu.org/gnu/grub/上下载grub-0.97.tar.gz,编译I制作grub启动软盘I到网络上下载一个可用的OS映像,编写menu.lst,利用grub启动之Idlxlinux,或其他I这里提供2个RTEMS操作系统的映像Ihello.exeIticker.exe谢谢!

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁