* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download lecture notes
Survey
Document related concepts
Scala (programming language) wikipedia , lookup
Dependency injection wikipedia , lookup
Library (computing) wikipedia , lookup
Class (computer programming) wikipedia , lookup
Name mangling wikipedia , lookup
Application Interface Specification wikipedia , lookup
Resource management (computing) wikipedia , lookup
Design Patterns wikipedia , lookup
Java (programming language) wikipedia , lookup
C Sharp syntax wikipedia , lookup
Object-oriented programming wikipedia , lookup
Java performance wikipedia , lookup
Transcript
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. Why is it beneficial for an operating system to enable processes to communicate with one another? Share information Cooperation Computational speed-up via parallel programming Modularity of program design Convenience Message Passing Shared Memory both IPC mechanisms require a protocol and synchronization Processes may communicate on the same machine or across multiple machines Use sockets for interprocess client-server communication Use remote procedure calls (RPCs) to call procedures across a network In Java, use remote method invocation (RMI) to call a method on an object in a different virtual machine Using RPC, heterogeneous operating systems can interact with one another RPCs can be made across a mix of machines and operating systems All parameters must be marshaled to ensure proper interpretation Consider date representations ▪ YYYY-MM-DD or MM-DD-YYYY or DD-MM-YYYY Also consider big endian versus little endian integer representations ▪ (see http://en.wikipedia.org/wiki/Endianness) RMI is a Java mechanism similar to RPCs RMI enables a running Java program to call a method on a remote object running on a separate Java Virtual Machine this requires object serialization A socket is an endpoint for communication Communication takes place over a pair of sockets <ip-address>:<port> listener socket 128.113.2.9:80 socket socket 66.195.8.34:8123 128.113.2.9:9500 Pitfalls of socket-based communication between client and server include: Once a server binds to a port, no other program may listen on that port If client and server do not obey the rules of the protocol, errors occur In Java, we transmit primitive data types (e.g. int, double) using DataInputStream and DataOutputStream To transmit objects, use ObjectInputStream and ObjectOutputStream instead this requires object serialization Objects exist in a JVM’s memory space To transmit an object over a socket, we must first serialize the object For an object to be serializable, its class definition must implement the java.io.Serializable interface Also useful for saving runtime objects to a file The Serializable interface has no methods Simply identifies a class as being serializable And enables the use of readObject() and writeObject() methods of ObjectInputStream and ObjectOutputStream Student object serialized object writeObject() network readObject() Student object Classes that are not serializable include: java.lang.Thread java.io.OutputStream java.net.Socket etc. Such classes refer to operating system resources, which are not serializable Serialized objects are assigned a unique identifier as a means to version control If you write object X to a socket or file, then modify the source code of class X and recompile the .class file, loading object X results in an InvalidClassException runtime exception All processes must be using the same version