chapter4processes进程内容摘要:
on the size of the 没有对缓冲区大小的限制 boundedbuffer assumes that there is a fixed buffer 缓冲 对缓冲区大小作了限定 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – SharedMemory Solution The Buffer may either be provided by the operating system through the use of an interprocessmunication (IPC) facility (Sec ) , or by explicitly coded by the application programmer with the use of shared memory . SharedMemory Solution to the BoundedBuffer problem : Shared data define BUFFER_SIZE 10 Typedef struct { . . . } item。 item buffer[BUFFER_SIZE]。 int in = 0。 int out = 0。 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – Producer Process Producer : item nextProduced。 while (1) { produce an item in nextProduced。 while (((in + 1) % BUFFER_SIZE) == out)。 /* do nothing */ buffer[in] = nextProduced。 in = (in + 1) % BUFFER_SIZE。 } Solution is correct, but can only use BUFFER_SIZE1 elements Buffer is full Why? How to improve? 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – Consumer Process Consumer : item nextConsumed。 while (1) { while (in == out)。 /* do nothing */ nextConsumed = buffer[out]。 out = (out + 1) % BUFFER_SIZE。 consume the item in nextConsumed。 } In Chap 7 we discuss how synchronization among cooperating processes . Buffer is empty 2020年 9月 26日 12时 27分 Operating System Concepts Interprocess Communication (IPC) 进程间通信 IPC provides a Mechanism for processes to municate and to synchronize their actions without sharing the same address space . IPC提供 无须共享相同地址空间可用于进程通信的机制,同步其间的活动 IPC is best provided by a messagepassing system . signal( 信号机制) :给其他进程发送异步事件信号。 如: kill –9 pid :向 pid 进程发送 9号信号(无条件终止) kill –l : 显示系统中所有的信号 ls –l | wc –l :求出当前目录下的文件数 pipe( 管道技术) :一个进程的输出作为另外一个进程的输入,实现相关进程(如父子进程)通信,可看作一个临时文件。 如: 无名管道( pipe): ls –l | grep ‗^d‘, 实现相同父进程的子进程间通信。 命名管道 (named pipe, FIFO): 是有名字的管道,在 OS中作为一个对象(文件,即FIFO文件)存在,实现任何进程间通信 mkfifo pipename ls –l pipename amp。 wc –l pipename 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System消息传递系统 Message system – processes municate with each other without resorting to shared variables. 消息系统 进程间通信无须对共享变量进行再分类 IPC facility provides two operations:IPC提供两个操作 : send(message) – message size fixed or variable 发送 固定或可变大小消息 receive(message) 接受 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System (Cont.) If P and Q wish to municate, they need to: 若 P与 Q要通信,需要 : establish a munication link between them 建立通信连接 exchange messages via send/receive 通过 send/receive交换消息 Implementation of munication link通信连接的实现 physical (., shared memory, hardware bus) 物理的(如,共享存储,硬件总线) logical (., logical properties) 逻辑的(如,逻辑特性) 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System (Cont.) several method for implementing a link and the send / receive operation : 实现链接的几种方法和发送 /接收操作 : Direct or indirect munication 直接或间接的通信 Symmetric or asymmetric munication 同步或异步通信 Automatic or explicit buffering 自动或显式的缓冲 Send by copy or send by reference 通过拷贝或通过引用发送 Fixedsized or variablesized message 固定大小或可变大小的消息 2020年 9月 26日 12时 27分 Operating System Concepts Implementation Questions实现中的问题 How are links established?连接如何建立。 Can a link be associated with more than two processes?连接可同多于两个的进程相关吗。 How many links can there be between every pair of municating processes? 每对在通信进程有多少连接。 What is the capacity of a link?一个连接的容量是多少。 Is the size of a message that the link can acmodate fixed or variable? 连接可使用的固定或可变消息的大小。 Is a link unidirectional or bidirectional? 连接是无向的还是双向的。 2020年 9月 26日 12时 27分 Operating System Concepts Naming命名 Direct Communication直接通信 Processes must name each other explicitly: 进程必须互相显式的命名 send (P, message) – send a message to process P 向进程 P发消息 receive(Q, message) – receive a message from process Q 从进程 Q收消息 2020年 9月 26日 12时 27分 Operating System Concepts Direct Communication直接通信 Properties of munication link通信连接的特性 Links are established A link is associated with exactly one pair of municating processes. 连接精确的与一对在通信的进程相关 Between each pair there exists exactly one link. 在每一对之间就存在一个连接 The link may be unidirectional, but is usually bidirectional. 连接可以单向的,但通常是双向的 2020年 9月 26日 12时 27分 Operating System Concepts Indirect Communication 间接通信 Messages are directed and received from mailboxes (also referred to as ports). 消息导向至信箱并从信箱接收(被视作端口) Each mailbox has a unique id. 每一个信箱有一个唯一的 id Processes can mun。chapter4processes进程
相关推荐
isual C++ – Windows CE的 C++編譯器 Compact .Net Framework – 精簡的 .Net平台,可快速移植桌上型程式到 Windows CE平台中 415 BSP Board support package 元件 說明 啟動程式 系統啟動時,啟動程式會下載作業系統 ( OS)映像檔。 OEM配階層 ( OAL) 連結核心映像檔,將硬體初始化並管理之。
子商務軟體基本的功能 電子商務軟體需要提供以下功能 型錄展示 購物推車功能 交易處理(含金流) 購物者在網站進行虛擬的結帳時,按下結帳按鈕時才會開始進行 其他加值功能 7 標示語言 HTML: Hypertext Markup Language 簡單的超文本標示語言,有固定的標簽 SGML: Standard Generalized ML ISO 8879:1986
1 1 1 3241 3 3 3 3。 2 3 3 3。 3 3。 0 3 3 3 3 3 有限循环群和无限循环群 若元素 a的所有幂次均不相同 (无限循环群 ) 存在整数 h和 k,使得 ak=ah,则有 a生成的循环群中元素个数有限 (有限循环群 ) 循环群元素的级 若 ak=ah,则有
现实世界中有许多问题(关系)可用队列描述,顾客服务部门的工作方式往往是排队方式,这类系统称作排队系统。 在计算机算法实现中,也经常使用队列记录需按 FIFO方式处理的数据。 • ────────────── • 出队 ← ○ ○ …… ○ ← ○进队 • ────────────── • 队头 队尾 Queue front rear enqueue dequeue A B C A queue
10 100 370 10 700 )1()( 222nnyynS)16(6 10700622 S 3 62 SS練習 6個樣本數據 :,, 求其標準差 解 : 數據減去 再乘上 100倍 算出來的標準差 會是原來的 100倍 ∴ 標準差為 x y= z=100y z2 5 25 6 36 4 16 5 25 2 4 0 0 0 4 106 0)16(6
} 四川大学 计算机学院 唐宁九 template class Type int StackType::GetTop ( Type amp。 x ) { if ( IsEmpty ( ) ) return 0。 x = topdata。 return 1。 } 四川大学 计算机学院 唐宁九 Linked Stacks 四川大学 计算机学院 唐宁九 四川大学 计算机学院 唐宁九 四川大学