操作系统-Operating-Systems-ch3-Processes-课件

上传人:痛*** 文档编号:252047256 上传时间:2024-11-12 格式:PPT 页数:48 大小:4.99MB
返回 下载 相关 举报
操作系统-Operating-Systems-ch3-Processes-课件_第1页
第1页 / 共48页
操作系统-Operating-Systems-ch3-Processes-课件_第2页
第2页 / 共48页
操作系统-Operating-Systems-ch3-Processes-课件_第3页
第3页 / 共48页
点击查看更多>>
资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,3.,Silberschatz,Galvin and Gagne 2018,Operating System Concepts 10,th,Edition,Chapter 3:Processes,Chapter 3:Processes,Process Concept,Process Scheduling,Operations on Processes,Interprocess Communication,IPC in Shared-Memory Systems,IPC in Message-Passing Systems,Examples of IPC Systems,Communication in Client-Server Systems,Process Concept,An operating system executes a variety of programs that run as a process.,Process,a program in execution;process execution must progress in sequential fashion,Multiple parts,The program code,also called,text section,Current activity including,program,counter,processor registers,Stack,containing temporary data,Function parameters,return addresses,local variables,Data section,containing global variables,Heap,containing memory dynamically allocated during run time,Process in Memory,Memory Layout of a C Program,Process State,As a process executes,it changes,state,New,:The process is being created,Running,:Instructions are being executed,Waiting,:The process is waiting for some event to occur,Ready,:The process is waiting to be assigned to a processor,Terminated,:The process has finished execution,Diagram of Process State,Process Control Block(PCB),Information associated with each process,(also called,task control block,),Process state running,waiting,etc,Program counter location of instruction to next execute,CPU registers contents of all process-centric registers,CPU scheduling information-priorities,scheduling queue pointers,Memory-management information memory allocated to the process,Accounting information CPU used,clock time elapsed since start,time limits,I/O status information I/O devices allocated to process,list of open files,Threads,So far,process has a single thread of execution,Consider having multiple program counters per process,Multiple locations can execute at once,Multiple threads of control-,threads,Must then have storage for thread details,multiple program counters in PCB,Explore in detail in Chapter 4,Process Representation in Linux,Represented by the C structure,task_struct,pid_t pid;/*process identifier*/long state;/*state of the process*/unsigned int time_slice/*scheduling information*/struct task_struct*parent;/*this process,s parent*/struct list_head children;/*this process,s children*/struct files_struct*files;/*list of open files*/struct mm_struct*mm;/*address space of this process*/,Process Scheduling,Maximize CPU use,quickly switch processes onto CPU core,Process scheduler,selects among available processes for next execution on CPU core,Maintains,scheduling queues,of processes,Ready queue,set of all processes residing in main memory,ready and waiting to execute,Wait queues,set of processes waiting for an event(i.e.I/O),Processes migrate among the various queues,Ready and Wait Queues,Representation of Process Scheduling,CPU Switch From Process to Process,A,context switch,occurs when the CPU,switches from one process to another.,Context Switch,When CPU switches to another process,the system must,save the state,of the old process and load the,saved state,for the new process via a,context switch,Context,of a process represented in the PCB,Context-switch time is overhead;the system does no useful work while switching,The more complex the OS and the PCB,the,longer the context switch,Time dependent on hardware support,Some hardware provides multiple sets of registers per CPU,multiple contexts loaded at once,Process,Operation:,Creation,Parent,process create,children,processes,which,in turn create other processes,forming a,tree,of processes,Generally,process identified and managed via a,process identifier,(,pid,),Resource sharing options,Parent and children share all resources,Children share subset of parent,s resources,Parent and child share no resources,Execution options,Parent and children execute concurrently,Parent waits until children terminate,A Tree of Processes in Linux,Process Creation(Cont.),Address space,Child duplicate of parent,Child has a program loaded into it,UNIX examples,fork(),system call creates new process,exec(),system call used after a,fork(),to replace the process,memory space with a new program,Parent process calls,wait(),for the child to terminate,C Program Forking Separate Process,Process Termination,Process executes last statement and then asks the,OS,to delete it using the,exit(),system call.,Returns status data from child to parent(via,wait(),),Process,resources are deallocated by OS,Parent may terminate the execution of children processes using the,abort(),system call.Some reasons for doing so:,Child has exceeded allocated resources,Task assigned to child is no longer required,The parent is exiting and the OS does not allow a child to continue if its parent terminates,Process Termination,Some,OSs,do not allow child to exists if its parent has terminated.If a process terminates,then all its children must also b
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 施工组织


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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