Operating Systems Processes and threads 21 Processes(进程) 22 Threads(线程) 23 Scheduling(调度) 24 Interprocess communication(进程间通信) 2. Classical IPc problems(经典IPC问题) Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 3 2.1 Processes (进程) 2.2 Threads(线程) 2.3 Scheduling(调度) 2.4 Interprocess communication(进程间通信) 2.5 Classical IPC problems (经典IPC问题) Processes and Threads
Operating Systems Processes: The Process model c Process: an executing program, including the current values of the program counter, register, and variables One program counter Process Four program counters A B C B D DcBA D Time g Multiprogramming of 4 programs Conceptual model of 4 independent, sequential processes g Only one program active at any instant Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 4 Processes: The Process Model Multiprogramming of 4 programs Conceptual model of 4 independent, sequential processes Only one program active at any instant Process: an executing program, including the current values of the program counter, register, and variables
Operating Systems Process Concept c An operating system executes a variety of programs H Batch system- jobs H Time-shared systems-user programs or tasks g Textbook uses the terms job and process almost interchangeably. G Process execution must progress in sequential fashion A process includes: a program counter程序计数器 stack栈 u data section数据部分 Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 5 Process Concept An operating system executes a variety of programs: Batch system – jobs Time-shared systems – user programs or tasks Textbook uses the terms job and process almost interchangeably. Process execution must progress in sequential fashion. A process includes: program counter 程序计数器 stack 栈 data section 数据部分
Operating Systems P rocess creation Principal events that cause process creation System initialization(系统初始化) 2. Execution of a process creation system(系统调用) 3. User request to create a new process(用户命令) 4. Initiation of a batch job(批处理作业的初始化) Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 6 Process Creation Principal events that cause process creation: 1. System initialization (系统初始化) 2. Execution of a process creation system (系统调用) 3. User request to create a new process(用户命令) 4. Initiation of a batch job(批处理作业的初始化)
Operating Systems Process Creation(2) Parent process creates children processes, which, in turn create other processes, forming a tree of processes. g Resource sharing t Parent and children share all resources A Children share subset of parents resources t Parent and child share no resources g Execution执行 a Parent and children execute concurrently Parent waits until children terminate Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 7 Process Creation (2) Parent process creates children processes, which, in turn create other processes, forming a tree of processes. Resource sharing Parent and children share all resources. Children share subset of parent’s resources. Parent and child share no resources. Execution 执行 Parent and children execute concurrently. Parent waits until children terminate