L07-IPC-and-Scheduling.ppt

L07-IPC-and-Scheduling

Operating System Lecture 7: IPC Scheduling Hu Yan School of Software , DLUT Outline 本讲纲要 回顾:写者优先问题 Inter-Process Communication (IPC, 进程间通信) Scheduling(调度) Overview Reader: while (true) { P(rw_mutex); P(r_mutex); r_cnt++; if(r_cnt==1) P(mutex); V(r_mutex); V(rw_mutex); read(); P(r_mutex); r_cnt- -; if(r_cnt==0) V(mutex); V(r_mutex); }; Writer: while (true) { P(rw_mutex); P(mutex); write(); V(mutex); V(rw_mutex); }; Overview Reader: while (true) { P(rw_mutex); P(r_mutex); r_cnt++; if(r_cnt==1) P(mutex); V(r_mutex); V(rw_mutex); read(); P(r_mutex); r_cnt- -; if(r_cnt==0) V(mutex); V(r_mutex); }; Writer: while (true) { P(rw_mutex); P(mutex); write(); V(mutex); V(rw_mutex); }; Outline 本讲纲要 回顾:进程同步及其信号量实现 Inter-Process Communication (IPC, 进程间通信) Scheduling(调度) Review 问一个问题 一个房间,里面有三盏灯,外面装了三个开关来控制,只允许进房间一次,请问怎么判断那个开关控制哪盏灯? 答:把开关编号为A,B,C 首先,开关A从off-on,维持几分钟后,而后再从on-off 把开关B从off-on 进去屋里,摸一下两个不亮的灯泡,结论是: 感受一下温度,发热的是开关A所控制的灯泡 没有发热的是开关C所控制的 一个信号是on/off 而对于处于off状态的,有通过温度这个信号完成了区分 Inter-Process Communication 进程间通信 IPC : the interchange of information among processes 进程间的信息交换称为进程通信 Two Types of IPC(进程间的通信分为两种): Low-level IPC: the interchange of simple control information 控制信息的传送(低级通信) High-level IPC: the interchange of more complex information among processes 大量信息的传送(高级通信) Low-level IPC 低级通信 Process Mutual Exclusion and Process Synchronization are typical low-level IPCs 进程的互斥与同步为低级通信方式 Accordingly, Locks, P/V primitives, and Wait/Signal primitives are called low-level primitives 相应地,锁、P/V原语、wait/signal操作为低级的通信原语。 High-level IPC 高级通信 进程之间除了基本的互斥与同步控制之外,还可能存在需要交换大量数据的情况 如网络协议的实现,需要在Client/Server之间传送大量的数据用来建立连接,传递数据包等 Four types of high-level IPCs(4类进程间通信): Master/Servant 主从式 Dialogue System 会话式 Message Passing/Mailbox 消息传递/邮箱机制 Shared Memory 共享存储区 High-level IPC 1: Master/Servant 高级通信之一:主从式 主从式通信的特点: 主进程可以自由的使用从进

文档评论(0)

1亿VIP精品文档

相关文档