例如,有两个循环程序A和已它们共享一 个变量N。程序A每执行一次时,都要做 都要执行 Print(N)操作,然后再将N置 成“0〃。程序A和B以不同的速度运行。 这样,可能出现其计算结果不可再现性, 亦即,程序经过多次执行后,虽然它们 执行时的环境和初始条件相同,但得到 的结果却各不相同
• 例如,有两个循环程序A和已它们共享一 个变量N。程序A每执行一次时,都要做 N:=N+1操作;程序B每执行一次时, 都要执行Print(N)操作,然后再将N置 成“0”。程序A和B以不同的速度运行。 这样,可能出现其计算结果不可再现性, 亦即,程序经过多次执行后,虽然它们 执行时的环境和初始条件相同,但得到 的结果却各不相同
Major Requirements of an Operating System Interleave the execution of several processes to maximize processor utilization while providing reasonable response time Allocate resources to processes Support interprocess communication and user creation of processes
Major Requirements of an Operating System • Interleave the execution of several processes to maximize processor utilization while providing reasonable response time • Allocate resources to processes • Support interprocess communication and user creation of processes
3.1 Process Also called a task Execution of an individual program √进程是程序在一个数据集合上的运行过程,是系统进 行资源分配和调度的一个独立单位 √进程是可并发执行的程序在一个数据集合上的运行过 程 · Can be traced list the sequence of instructions that execute
3.1 Process • Also called a task • Execution of an individual program ✓ 进程是程序在一个数据集合上的运行过程,是系统进 行资源分配和调度的一个独立单位 ✓ 进程是可并发执行的程序在一个数据集合上的运行过 程 • Can be traced – list the sequence of instructions that execute
例 假设内存中有3个进程A、B、C,他们 的程序代码已全部装入内存。若A、C两 进程需要执行12条指令,B进程需要执 行4条指令,且B进程执行到第4条指令 处必须等待Io
例 假设内存中有3个进程A、B、C,他们 的程序代码已全部装入内存。若A、C两 进程需要执行12条指令,B进程需要执 行4条指令,且B进程执行到第4条指令 处必须等待I/O
Address Main Memory Program Counter Dispatcher 5000 Process a 8O00 Process B 12000 Process c Figure 3.1 Snapshot of Example Execution(Figure 3.3) It Instruction Cycle 13