正在加载图片...
958 CONCURRENCY,DISTRIBUTION,CLIENT-SERVER AND THE INTERNET $30.3 This notion,however,raises difficult problems. The most significant one is easy to see.A process has its own agenda:as illustrated by the printer example,it relentlessly executes a certain sequence of actions.Not so with classes and objects.An object does not do one thing;it is a repository of services (the features of the generating class),and just waits for the next client to solicit one of those services-chosen by the client,not the object.If we make the object active,it becomes responsible for the scheduling of its operations.This creates a conflict with the clients, which have a very clear view of what the scheduling should be:they just want the supplier, whenever they need a particular service,to be ready to provide it immediately! The problem arises in non-object-oriented approaches to concurrency and has led to mechanisms for synchronizing processes-that is to say,specifying when and how each is ready to communicate,waiting if necessary for the other to be ready too.For example in a very simple,unbuffered producer-consumer scheme we may have a producer process that repeatedly executes “Make it known that producer is not ready'” "Perform some computation that produces a valuex" “Make it known that producer is ready” "Wait for consumer to be ready" “Pass x to consumer” and a consumer process that repeatedly executes Handshake "Make it known that consumer is ready" “Wait for producer to be ready” “Get x from producer” "Make it known that consumer is not ready" "Perform some computation that uses the value x" a scheme which we may also view pictorially: producer consumer A simple Produce producer- Wait Wait consumer scheme Communicate Communicate Handshake (passx) ons ume Communication occurs when both processes are ready for each other;this is sometimes called a handshake or rende=-vous.The design of synchronization mechanisms -enabling us in particular to express precisely the instructions to "Make it known that process is ready"and"Wait for process to be ready"-has been a fertile area of research and development for several decades.958 CONCURRENCY, DISTRIBUTION, CLIENT-SERVER AND THE INTERNET §30.3 This notion, however, raises difficult problems. The most significant one is easy to see. A process has its own agenda: as illustrated by the printer example, it relentlessly executes a certain sequence of actions. Not so with classes and objects. An object does not do one thing; it is a repository of services (the features of the generating class), and just waits for the next client to solicit one of those services — chosen by the client, not the object. If we make the object active, it becomes responsible for the scheduling of its operations. This creates a conflict with the clients, which have a very clear view of what the scheduling should be: they just want the supplier, whenever they need a particular service, to be ready to provide it immediately! The problem arises in non-object-oriented approaches to concurrency and has led to mechanisms for synchronizing processes — that is to say, specifying when and how each is ready to communicate, waiting if necessary for the other to be ready too. For example in a very simple, unbuffered producer-consumer scheme we may have a producer process that repeatedly executes a scheme which we may also view pictorially: Communication occurs when both processes are ready for each other; this is sometimes called a handshake or rendez-vous. The design of synchronization mechanisms — enabling us in particular to express precisely the instructions to “Make it known that process is ready” and “Wait for process to be ready” — has been a fertile area of research and development for several decades. “Make it known that producer is not ready” “Perform some computation that produces a value x” “Make it known that producer is ready” “Wait for consumer to be ready” “Pass x to consumer” and a consumer process that repeatedly executes “Make it known that consumer is ready” “Wait for producer to be ready” “Get x from producer” “Make it known that consumer is not ready” “Perform some computation that uses the value x” Handshake A simple producer￾consumer scheme Produce Consume Wait Communicate producer consumer Handshake (pass x) Wait Communicate
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有