Download presentation
Presentation is loading. Please wait.
Published byArline Page Modified over 8 years ago
1
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 3: Processes
2
3.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Synchronization Message passing may be either blocking or non- blocking Blocking is considered synchronous Blocking send has the sender block until the message is received Blocking receive has the receiver block until a message is available Non-blocking is considered asynchronous Non-blocking send has the sender send the message and continue Non-blocking receive has the receiver receive a valid message or null
3
3.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Buffering Queue of messages attached to the link; implemented in one of three ways 1.Zero capacity – 0 messages Sender must wait for receiver (rendezvous) 2.Bounded capacity – finite length of n messages Sender must wait if link full 3.Unbounded capacity – infinite length Sender never waits
4
3.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Examples of IPC Systems - Mach Mach communication is message based Even system calls are messages Each task gets two mailboxes at creation- Kernel and Notify Only three system calls needed for message transfer msg_send(), msg_receive(), msg_rpc() Mailboxes needed for commuication, created via port_allocate()
5
3.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Mach Message Passing (Contd.) Order guarantees Messages from same sender buffered in FIFO order No guarantees for messages from different senders Fixed length headers followed by variable length payload Headers include two mailbox ids: sender and receiver – Why?
6
3.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Synchronicity Sender Process – what happens if mailbox is full? Wait indefinitely Wait for certain time Do not wait Temporary message caching Receiver process – what happens if mailbox is empty? Wait for certain time No wait
7
3.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Communications in Client-Server Systems Sockets Remote Procedure Calls Remote Method Invocation (Java)
8
3.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Sockets A socket is defined as an endpoint for communication An interface through which an application can send and receive messages to/from another application 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
9
3.9 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Socket Communication
10
3.10 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Types of Sockets SOCK_STREAM (TCP) Reliable delivery Order guarantees Connection-oriented Bi-directional SOCK_DGRAM (UDP) Unreliable delivery No order guarantees Connection-less
11
3.11 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Berkeley Sockets Socket primitives for TCP/IP. PrimitiveMeaning SocketCreate a new communication endpoint BindAttach a local address to a socket ListenAnnounce willingness to accept connections AcceptBlock caller until a connection request arrives ConnectActively attempt to establish a connection SendSend some data over the connection ReceiveReceive some data over the connection CloseRelease the connection Interface for transport layer A communications end point
12
3.12 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Berkeley Sockets Connection-oriented communication pattern using sockets.
13
3.13 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Socket Communication in Java
14
3.14 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Socket Communication in Java
15
3.15 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Remote Procedure Calls Sockets are low-level communication primitives – no structure to communication Higher level communication paradigms – Remote Procedure Call and Remote Method Invocation RPC – mimics traditional procedure call Messages are well structured Messages are addressed to an RPC Daemon
16
3.16 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Remote Procedure Calls - Preview Providing transparency Client Stub Proxy code put into client Server stub Proxy code put into server
17
3.17 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Operation of Client/Server Stubs Client Stub Packs parameters into a message Makes a call to local OS Sends the message via “send” call Blocks on “receive” Server Stub Would have blocked on a “receive” call Unpacks the message from client Calls the server procedure (putting parameters into stack) Packs the results and sends it to caller
18
3.18 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Steps of a Remote Procedure Call 1. Client procedure calls client stub in normal way 2. Client stub builds message (marshals parameters), calls local OS 3. Client's OS sends message to remote OS 4. Remote OS gives message to server stub 5. Server stub un-marshals parameters, calls server 6. Server does work, returns result to the stub 7. Server stub packs it in message, calls local OS 8. Server's OS sends message to client's OS 9. Client's OS gives message to client stub 10. Stub unpacks result, returns to client
19
3.19 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Execution of RPC
20
3.20 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition RPC Issues Differences in data representation – little endian and big-endian formats Resolved by using external data representations (XDR) Client-to-Server Binding Fixed end-point Rendezvous mechanism (match maker daemon) Dealing with (partial) failures How to provide “exactly-once” semantics
21
3.21 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition 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
22
3.22 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition End of Chapter 3
23
3.23 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 4: Threads
24
3.24 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Linux Threads
25
3.25 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems To discuss the APIs for the Pthreads, and Java thread libraries To examine issues related to multithreaded programming
26
3.26 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Threads – What? A basic unit of CPU utilization Perceived as execution of a (part of a ) program Mechanism to provide concurrency within an application Recall that processes provide concurrency across different applications
27
3.27 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Threads – Why? Need for concurrency within a single application Web browser example Web server example Processes are an inefficient choice for intra- application concurrency Process creation and switching are expensive Communication between processes is also expensive Concurrent channels of execution within an application do not need strict isolation In fact they need to communicate often
28
3.28 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Threads – How? Threads of an application share address space (memory), code and files No need to create address space or switch address spaces when creating/switching processes Shared address space provides easy cooperation/communication mechanism Each thread has a thread ID, program counter, registers and stack Context of threads essentially captured by CPU context May be a little more information (e.g., locks)
29
3.29 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Single and Multithreaded Processes
30
3.30 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Multithreaded Server Architecture
31
3.31 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Benefits Responsiveness Resource Sharing Economy Scalability
32
3.32 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Multithreading Models User-level threads Thread management done by user-level threads library without kernel involvement POSIX Pthreads, Win32 threads, Java Threads Kernel-level threads Threads managed directly by the OS kernel Windows XP, Vista, Windows 7, Linux, Mac OS X provide kernel threads Mapping must exist between user-level threads and kernel-level threads
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.