320 likes | 756 Views
Client-Server Communication. Sockets Remote Procedure Calls Remote Method Invocation (Java). Sockets. A socket is defined as an endpoint for communication Concatenation of IP address and port The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8
E N D
Client-Server Communication • Sockets • Remote Procedure Calls • Remote Method Invocation (Java)
Sockets • A socket is defined as an endpoint for communication • Concatenation of IP address and port • The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 • Communication consists between a pair of sockets • Low level: Sends/receives a stream of bytes. • Sockets are either connection-oriented (i.e., TCP) or connectionless (i.e., UDP).
Remote Procedure Calls • Remote procedure call (RPC) abstracts procedure calls between processes on networked systems. • Stubs – client-side proxy for the actual procedure on the server. • The client-side stub locates the server and marshalls the parameters. • The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server. • Returns output of procedure (if applicable).
Remote Method Invocation • Remote Method Invocation (RMI) is a Java mechanism similar to RPCs. • RMI allows a Java program on one machine to invoke a method on a remote object. • Can send objects to remote JVM
Benefits • Responsiveness (e.g., Web server). • Resource Sharing (several threads of control within a common address space). • Economy (threads are often termed lightweight processes). Much cheaper to create and manage. • Utilization of MP Architectures
User vs Kernel Threads • User Threads: • Thread management done by user-level threads library. • When one thread blocks, the process blocks. • Kernel Threads: • Supported by the kernel. • When one thread blocks the OS can pick another thread within the same process to execute. • Allows overlapping of (for example) computation and I/O requests.
Kernel Threads • Examples • Windows XP/2000 • Solaris • Linux • Tru64 UNIX • Mac OS X
Multithreading Models • Many-to-One • One-to-One • Many-to-Many
Many-to-One • Many user-level threads mapped to single kernel thread. • Possible to overlap I/O computation? • Examples: • Solaris Green Threads • GNU Portable Threads
One-to-One • Each user-level thread maps to kernel thread • Examples • Windows NT/XP/2000 • Linux • Solaris 9 and later
Many-to-Many Model • Allows many user level threads to be mapped to many kernel threads • Allows the operating system to create a sufficient number of kernel threads • Solaris prior to version 9 • Windows NT/2000 with the ThreadFiber package
Two-level Model • Similar to M:M, except that it allows a user thread to be bound to kernel thread • Examples • IRIX • HP-UX • Tru64 UNIX • Solaris 8 and earlier