SPL - PS12. Reactor and Java New-IO (nio) classes

Size: px
Start display at page:

Download "SPL - PS12. Reactor and Java New-IO (nio) classes"

Transcription

1 SPL - PS12 Reactor and Java New-IO (nio) classes

2 Multi-Threaded server, as seen in Tirgul 11 - one thread is in charge of accepting new connections - opens a new thread for each new client. - Thus, handling 30 clients requires 31 threads. Multi-Threaded server is problematic for several reasons: It's wastefull - Creating a new Thread is relatively expensive. - Each thread requires a fair amount of memory. - Threads are blocked most of the time waiting for network IO. It's not scalable - A Multi-Threaded server can't grow to accommodate hundreds of concurrent requests - It's also vulnerable to Denial Of Service attacks Poor availability - It takes a long time to create a new thread for each new client. Moreover, the response time degrades as the number of clients rises.

3 The Reactor Pattern is another (better) design for handling several concurrent clients 1. Use Non-Blocking IO, so Threads don't waste time waiting for Network. 2. Have one thread in charge of the Network - accepting new connections and handling IO. As the Network is non-blocking, read, write and accept operations "take no time", and a single thread is enough for all the clients. 3. Have a fixed number of threads (for example in a thread pool), which are in charge of the protocol. These threads perform: message framing (tokenizations) message processing (what to do with each message). Note - unlike the Multi-Threaded server, in this design a single thread may handle many clients.

4 Java NIO API previous PS (last week) Java's java.nio package is a new, efficient IO package. It also support Non-blocking IO. The key players we need to know are: - Channels - Buffers - Selector

5 Java NIO API Channels, a new primitive I/O abstraction java.nio.channels.channel is an interface Channels (classes implementing the interface) are designed to provide for bulk data transfers to and from NIO buffers (A Channel is something you can read from and write to). Channels can be either blocking (by default) or non-blocking. socket channels allow for data transfer between sockets and NIO buffers. java.nio.channels.socketchannel (similar to Socket) java.nio.channels.serversocketchannel (similar to ServerSocket) Here read(), write() and accept() methods can be non-blocking. The ServerSocketChannel's accpet() method returns a SocketChannel. The other side of the connection can of course be either blocking or non-blocking (it doesn't matter).

6 Java NIO API socket channels Setting up a non-blocking ServerSocketChannel listening on a specific port: int port = 9999; ServerSocketChannel sschannel = ServerSocketChannel.open(); sschannel.configureblocking(false); // false for non-blocking sschannel.socket().bind( new InetSocketAddress(port) ); Setting up a non-blocking SocketChannel and connecting to a server: SocketChannel schannel = SocketChannel.open(); schannel.connect( new InetSocketAddress("localhost", 1234) ); schannel.configureblocking(false); // false for non-blocking

7 Java NIO API NIO buffers NIO data transfer is based on buffers (java.nio.buffer and related classes). A buffer is a container that can hold a finite and contiguous sequence of primitive data types. It's essentially an object wrapper around an array of bytes with imposed limits. Using the right implementation, allows the buffer contents to occupy the same physical memory used by the operating system for its native I/O operations, thus allowing the most direct transfer mechanism, and eliminating the need for any additional copying. In most operating systems (provided some properties of the particular area of memory) transfer can take place without using the CPU at all. The NIO buffer is intentionally limited in features in order to support these goals. In simple words allows faster and more efficient implementations NIO buffers maintain several pointers that dictate the function of its accessor methods. The NIO buffer implementation contains a rich set of methods for modifying these pointers: flip() get() put() mark() reset()

8 Java NIO API NIO buffers Channels know how to read and write into Buffers, and buffers can read and write into other buffers. We'll be using ByteBuffer (These are buffers that hold bytes). Creating a new ByteBuffer: final int NUM_OF_BYTES = 1024; ByteBuffer buf = ByteBuffer.allocate(NUM_OF_BYTES); Creating a ByteBuffer from a an array of bytes: byte[] bytes = new byte[10]; ByteBuffer buf = ByteBuffer.wrap(bytes);

9 Java NIO API Capacity pointer - is the maximum number of items a buffer can hold position pointer points to start" limit pointer value that ranges from zero to capacity, representing an arbitrary limitation for the buffer ByteBuffer buffer = ByteBuffer.allocate(512); //creation of a nondirect ByteBuffer String str = "Hello"; byte[] data = str.getbytes(); buffer.put(data); //add the string "Hello" to the byte buffer The position pointer now points to the next empty cell after the data. So if we are to use this buffer to read the data, we need to flip the position of the position pointer. buffer.flip(); //readies the buffer for draining by resetting the position and limit pointer int limit = buffer.limit(); byte[] data = new byte[limit]; buffer.get(data); System.out.println(new String(data)); After the flip() is called, the position pointer points to the first cell, and the limit pointer points to the cell where the position pointer used to point before the flip() method was called.

10 Java NIO API NIO buffers The flip() method position pointer points to start" limit pointer points to size" or end" The flip() method, moves the position pointer to the origin of the underlying array (if any) and the limit pointer to the former position of the position pointer. Each buffer has a size and a position marker. A read operation reads a specified number of bytes from the current position, and updates the position marker to point to the yet unread bytes. Similarly, a write operation writes some bytes from the current position, and then advances the position. You can't read or write more than the size of the buffer. This means that if someone wrote some bytes into a buffer, and then you want to read them, you need to set the position marker to the start of the buffer, and the size of the buffer to the former position.

11 Java NIO API Character sets In Java, a character set is a mapping between Unicode characters (or a subset of them) and bytes. The java.nio.charset package of NIO provides facilities for identifying character sets and providing encoding and decoding algorithms for new mappings. Charset charset = Charset.forName("UTF-8"); _decoder = charset.newdecoder(); _encoder = charset.newencoder();

12 Java NIO API From Channel to Buffer and back Reading from a channel to a buffer: numbytesread = _socketchannel.read(buf); //returning number of bytes read Writing from a buffer to a channel: numbyteswritten = _socketchannel.write(buf); //returning number of bytes written If read or write returns -1, it means that the channel is closed. Read and write operations on Buffers update the position marker accordingly.

13 Java NIO API - Selectors When we perform non-blocking IO for example, read(): - Read the numbers of currently available bytes, and returns. This means we can read or write 0 bytes, and this is what will probably happen most of the time. - We would like a way for our thread to wait until any of our channels is ready, and only then perform the read(), write() or accept(), only on the ready channel. A selector (java.nio.channels.selector and subclasses) provides a mechanism: - for waiting on channels - and recognizing when one or more become available for data transfer.

14 Java NIO API - Selectors A selector (java.nio.channels.selector and subclasses) provides a mechanism: - for waiting on channels - and recognizing when one or more become available for data transfer. When a number of channels are registered with the selector - it enables blocking of the program flow until at least one channel is ready for use, or until an interruption condition occurs. Although this multiplexing behavior could be implemented with Java threads, the selector can provide a significantly more efficient implementation using native platform threads or, more likely, even lower-level operating system constructs. A POSIX-compliant operating system, for example, would have direct representations of these concepts, select(). A notable application of this design would be the common paradigm in server software which involves simultaneously waiting for responses on a number of sessions.

15 Java NIO API - Selectors The Selector registers itself to a Channel - Registration means that the channel informs the Selector when some event happens. This event can be: - the channel is ready to be read - the channel can now be written to - the channel can now accept() - During registration, the channel is told which events to monitor. - In addition, when registering a Selector to a channel, one can add an "attachment" - An attachment is an object that we will have access to when the event occurs (usually, this object is associated with a task that should be performed). Registration: Selector selector = Selector.open(); // a new Selector Object anattachment = new Object(); socketchannel.register(selector, SelectionKey.OP_READ, anattachmemt); //SelectionKey.OP_READ is a number representing the READ event

16 Java NIO API select() method - This method blocks until at least one of the channels is ready for the registered event. - Then, a list of SelectionKeys is returned. - Each Selectionkey is associated with one event, and holds the attachment registered with the event.

17 Java NIO API - The Reactor "core" reactor classes: - Reactor - ConnectionHandler - ConnectionAcceptor - ProtocolTask - The Reactor is the main thread, which is in charge of reading, writing and accepting new connections. - Reading and Writing are encapsulated in the ConnectionHandler class - accepting is encapsulated in the ConnectionAcceptor class - The reactor thread also holds a thread-pool of workers (an Executor). These worker-threads are in charge of the protocol handling. they receive the bytes read from the network, and let the protocol do something with them. The class which represents tasks submitted to the executor is ProtocolTask. - The ProtocolTask object is created along with the ConnectionHandler, and the same task object is reused over and over again. This is a bit different than what you saw in the beginning of the course, where each task was run once and then discarded.

18 Java NIO API - The Reactor Once some bytes were read by the reactor thread - The ConnectionHandler adds these bytes to its ProtocolTask, and passes the task to the thread pool. - The ProtocolTask passes the bytes to the tokenizer, which looks for complete messages. - Then, the protocoltask goes over all the messages which are available in the tokenizer, and asks the protocol to process them. - After the protocol process a message and return a response, the tokenizer is used to add framing information to the response, and then convert it into bytes. - Then, the protocol-task thread adds the response bytes back to the ConnectionHandler. - Notice - we don't have one thread per connection. - We have one ConnectionHandler object per connection. This object holds: the socket, the task and the protocol and tokenizer instances associated with this connection.

19 Java NIO API - The Reactor - Also notice - we are using an extended version of the SevrerProtocol (presented in the previous practical session). This extended version (AsyncServerProtocol) has two additional functions: 1. boolean shouldclose() - - returns true after the terminating message has been encountered. - This is used to signal the connection handler that the protocol has done its work and it's time to send all the remaining bytes and quit. 2. void connectionterminated() - used to notify the protocol that the client closed the connection, or that the network connection was lost. This is called by the ConnectionHandler when it identifies a network error.

20 The thread of the reactor performs the following: 1. Create a new thread pool (an executor). 2. Create a new Selector. 3. Create a new ServerSocketChannel, and bind it to a port. 4. Create a new ConnectionAcceptor 5. Register the ServerSocketChannel in the Selector, asking for accept readiness. While(_shouldRun && selector.isopen()) 6. wait for notifications from the selector. //selector.select() Get list of selection keys with pending events //selector.selectedkeys().iterator(); For each notification (SelectionKey) arrived check: //while (it.hasnext()) Accept notification - the server socket is ready to accept a new connection so: Get attached ConnectionAcceptor 1. call accept (2. Now a new socket was created): 3. Get a new channel for the connection request 4. register new socket in the Selector (5. return SelectionKey) 6. Create new ConnectionHandler and initialize it: //unique per connection 7. create protocol 8. create tokenizer 9. Create ProtocolTask //unique per connection 10. Attach itself (this.) to selectionkey 11. set the handler to read only mode Read notification - For each socket which is ready for reading: Get attached ConnectionHandler 1. read() 2. read some bytes (to buffer from the socket channel) and pass them down to the protocoltask: 3. addbytes(buf) 4. execute(pt) (run pt using the thread pool): //not in the main thread 5. add all the bytes we have to the tokenizer go over all complete messages (if ready) and process them: 6. msg = nextmessage() using tokenizer 7. processmessage(msg) using protocol, get response If there is a response: 8. send using ConnectionHandler 9. set the handler to Read or Write Mode Write notification - For each socket which is ready for writing: Get attached ConnectionHandler 1. write() //runs in the main thread if all the data has been successfully sent (outdata.size() == 0): 2. set the handler to read only mode (and return) if there is something to send 3. write some bytes (to socket channel from buffer)

21 The thread of the reactor performs the following: 1. Create a new thread pool (an executor). 2. Create a new Selector. 3. Create a new ServerSocketChannel, and bind it to a port. 4. Create a new ConnectionAcceptor 5. Register the ServerSocketChannel in the Selector, asking for accept readiness. While(_shouldRun && selector.isopen()) 6. wait for notifications from the selector. //selector.select() Get list of selection keys with pending events //selector.selectedkeys().iterator(); For each notification (SelectionKey) arrived check:

22 The thread of the reactor performs the following: 1. Create a new thread pool (an executor). ExecutorService executor = Executors.newFixedThreadPool(_poolSize); 2. Create a new Selector. selector = Selector.open(); 3. Create a new ServerSocketChannel, and bind it to a port. sschannel = createserversocket(_port); ServerSocketChannel sschannel = ServerSocketChannel.open(); sschannel.configureblocking(false); sschannel.socket().bind(new InetSocketAddress(port)); 4. Create a new ConnectionAcceptor ConnectionAcceptor connectionacceptor = new ConnectionAcceptor( sschannel, _data); 5. Register the ServerSocketChannel in the Selector, asking for accept readiness. sschannel.register(selector, SelectionKey.OP_ACCEPT, connectionacceptor); While(_shouldRun && selector.isopen()) 6. wait for notifications from the selector - selector.select(); Get list of selection keys with pending events: Iterator it = selector.selectedkeys().iterator(); For each notification (SelectionKey) arrived check: while (it.hasnext()) { SelectionKey selkey = (SelectionKey) it.next(); // Remove the selection key from the list to indicate that it is being // processed. it.remove() removes the last item returned by next. it.remove();

23 Accept notification - the server socket is ready to accept a new connection so: Get attached ConnectionAcceptor 1. call accept (2. Now a new socket was created): 3. Get a new channel for the connection request 4. register new socket in the Selector (5. return SelectionKey) 6. Create new ConnectionHandler and initialize it: 7. create protocol 8. create tokenizer 9. Create ProtocolTask 10. Attach itself (this.) to selectionkey 11. set the handler to read only mode

24 Accept notification - the server socket is ready to accept a new connection so: if (selkey.isvalid() && selkey.isacceptable()) { Get attached ConnectionAcceptor ConnectionAcceptor acceptor = (ConnectionAcceptor) selkey.attachment(); 1. call accept (2. Now a new socket was created): acceptor.accept(); 3. Get a new channel for the connection request SocketChannel schannel = _sschannel.accept(); 4. register new socket in the Selector (5. return SelectionKey) SelectionKey key = schannel.register(_data.getselector(), 0); 6. Create new ConnectionHandler and initialize it: ConnectionHandler handler = ConnectionHandler.create(sChannel, _data, key); 7. create protocol _protocol = _data.getprotocolmaker().create(); 8. create tokenizer _tokenizer = _data.gettokenizermaker().create(); 9. Create ProtocolTask _task = new ProtocolTask(_protocol, _tokenizer, this); 10. Attach itself (this.) to selectionkey _skey.attach(this); //SelectionKey _skey; 11. set the handler to read only mode handler.switchtoreadonlymode();

25 Read notification - For each socket which is ready for reading: Get attached ConnectionHandler 1. read() 2. read some bytes (to buffer from the socket channel) and pass them down to the ProtocolTask: 3. addbytes(buf) 4. execute(pt) (run pt using the thread pool- DIFFERENT THREAD): 5. add all the bytes we have to the tokenizer go over all complete messages (if ready) and process them: 6. msg = nextmessage() using tokenizer 7. processmessage(msg) using protocol, get response If there is a response: 8. send using ConnectionHandler 9. set the handler to Read or Write Mode

26 Read notification - For each socket which is ready for reading: if (selkey.isvalid() && selkey.isreadable()) { Get attached ConnectionHandler ConnectionHandler handler = (ConnectionHandler) selkey.attachment(); 1. read() handler.read(); 2. read some bytes (to buffer from the socket channel) and numbytesread = _schannel.read(buf); pass them down to the ProtocolTask: 3. addbytes(buf) buf.flip(); _task.addbytes(buf); 4. execute(pt) (run pt using the thread pool- DIFFERENT THREAD): _data.getexecutor().execute(_task); 5. add all the bytes we have to the tokenizer this._tokenizer.addbytes(buf); go over all complete messages (if ready) and process them: while (_tokenizer.hasmessage()) { 6. String msg = _tokenizer.nextmessage(); 7. String response = this._protocol.processmessage(msg); If there is a response: 8. send using ConnectionHandler this._handler.addoutdata(bytes); //_outdata.add(buf); 9. set the handler to Read or Write Mode switchtoreadwritemode();

27 public class ProtocolTask implements Runnable { private final ServerProtocol _protocol; private final StringMessageTokenizer _tokenizer; private final ConnectionHandler _handler; /** * The fifo queue, which holds data coming from the socket. Access to the * queue is serialized, to ensure correct processing order - even if more * data is received by the reactor while previous data is still being processed. */ private final Vector<ByteBuffer> _buffers = new Vector<ByteBuffer>(); public ProtocolTask(final ServerProtocol protocol, final StringMessageTokenizer tokenizer, final ConnectionHandler h) { this._protocol = protocol; this._tokenizer = tokenizer; this._handler = h; } // We synchronize on ourselves, in case we are executed by several threads from the thread pool. public synchronized void run() { synchronized (_buffers) { // first, add all the bytes we have to the tokenizer while(_buffers.size() > 0) { ByteBuffer buf = _buffers.remove(0); this._tokenizer.addbytes(buf); } } } // now, go over all complete messages and process them. while (_tokenizer.hasmessage()) { String msg = _tokenizer.nextmessage(); String response = this._protocol.processmessage(msg); if (response!= null) { try { ByteBuffer bytes = _tokenizer.getbytesformessage(response); this._handler.addoutdata(bytes); } catch (CharacterCodingException e) { e.printstacktrace(); } } } } // This is invoked by the ConnectionHandler which runs in the reactor main thread. public void addbytes(bytebuffer b) { // We synchronize on _buffers and not on "this" because // run() is synchronized on "this", and it might take a long time to run. synchronized (_buffers) { _buffers.add(b); } }

28 Write notification - For each socket which is ready for writing: Get attached ConnectionHandler 1. write() if all the data has been succesfully sent (outdata.size() == 0): 2. set the handler to read only mode (and return) if there is something to send 3. write some bytes (to socket channel from buffer)

29 Write notification - For each socket which is ready for writing: if (selkey.isvalid() && selkey.iswritable()) { Get attached ConnectionHandler ConnectionHandler handler = (ConnectionHandler) selkey.attachment(); 1. write() handler.write(); if all the data has been succesfully sent (outdata.size() == 0): 2. set the handler to read only mode (and return) if there is something to send 3. write some bytes (to socket channel from buffer) protected Vector<ByteBuffer> _outdata = new Vector<ByteBuffer>(); // If there is something to send - send the first byte buffer // We will return to this write() operation very soon because the selector // will keep firing the OP_WRITE event after we are done writing this buffer // and check if there are more buffers to be sent. ByteBuffer buf = _outdata.remove(0); //Removes element at position 0 in Vector. if (buf.remaining()!= 0) { try { _schannel.write(buf); } catch (IOException e) { // This should never happen because the selector told us we are in Writable mode. e.printstacktrace() } // Check if the buffer contains more data: we could not send all // of the buffer in one write (the output buffer of the socket got full). // So we remember that there is more data to be sent. // We will receive a new OP_WRITE event when the output buffer of the socket // is not full anymore and complete the write operation then. if (buf.remaining()!= 0) { _outdata.add(0, buf); //insert element at position 0 in Vector } }

Introduction to NIO: New I/O

Introduction to NIO: New I/O Chapter 2 Introduction to NIO: New I/O Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2004-09-01 ATIJ 2: Introduction to NIO: New I/O 2-1/36

More information

Ch.11 Nonblocking I/O

Ch.11 Nonblocking I/O CSB541 Network Programming 網路程式設計 Ch.11 Nonblocking I/O 吳俊興國立高雄大學資訊工程學系 Outline 11.1 An Example Client 11.2 An Example Server 11.3 Buffers 11.4 Channels 11.5 Readiness Selection 2 Java I/O Two typical

More information

Improving Java Network Programming. Brian Runk, 25 Apr 2006

Improving Java Network Programming. Brian Runk, 25 Apr 2006 Improving Java Network Programming Brian Runk, b.runk@morganstanley.com 25 Apr 2006 Topics Background A simple distributed application java.net programming model java.nio programming model A better programming

More information

Introduction to Network Programming using Java

Introduction to Network Programming using Java Introduction to Network Programming using Java 1 Development platform Starting Point Unix/Linux/Windows available in the department or computing centre More information http://www.tkk.fi/cc/computers/

More information

Outline. Network Applications: High-Performance Network Servers. Recap: Server Processing Steps. Worker. Recap: Main Thread. Recap: Progress So Far

Outline. Network Applications: High-Performance Network Servers. Recap: Server Processing Steps. Worker. Recap: Main Thread. Recap: Progress So Far Outline Network Applications: High-Performance Network Servers Y. Richard Yang http://zoo.cs.yale.edu/classes/cs433/ Ø Admin and recap High performance servers Thread Per-request thread Thread pool Busy

More information

Protocols SPL/ SPL

Protocols SPL/ SPL Protocols 1 Application Level Protocol Design atomic units used by protocol: "messages" encoding reusable, protocol independent, TCP server, LinePrinting protocol implementation 2 Protocol Definition set

More information

Outline. More on MINA features. ú Performance. ú Separating low- level IO handling from the protocol from the business logic.

Outline. More on MINA features. ú Performance. ú Separating low- level IO handling from the protocol from the business logic. Ehab Ababneh Outline The Problem: Thousands of Clients. Solution: Non- Blocking IO. The Reactor Pattern: Down to the roots of NBIO. NBIO is hard, just like multithreading. Frameworks are a bliss!... Apache

More information

Network Applications: High-Performance Network Servers

Network Applications: High-Performance Network Servers Network Applications: High-Performance Network Servers Y. Richard Yang http://zoo.cs.yale.edu/classes/cs433/ 10/01/2013 Outline Ø Admin and recap High performance servers Thread Per-request thread Thread

More information

Reading and Writing Files

Reading and Writing Files Reading and Writing Files 1 Reading and Writing Files Java provides a number of classes and methods that allow you to read and write files. Two of the most often-used stream classes are FileInputStream

More information

Project 0. Danyang Zhuo CSE sp Sec;on #2

Project 0. Danyang Zhuo CSE sp Sec;on #2 Project 0 Danyang Zhuo CSE 461 15sp Sec;on #2 Proj0 You have to implement: Mul;- UDP Server Mul;- UDP Client Async IO UDP Server Async IO UDP Client Your server must support mul;ple clients Submit Format

More information

Java NIO. Rein Raudjärv Nov 19th 2012 Java Fundamentals

Java NIO. Rein Raudjärv Nov 19th 2012 Java Fundamentals Java NIO Rein Raudjärv Nov 19th 2012 Java Fundamentals Agenda 1. NIO 1. Basics 2. Channels 3. Selectors 2. NIO.2 (File I/O) 1. Basics 2. Metadata NIO BASICS Based On Jakob Jenkov hjp://tutorials.jenkov.com/java-

More information

WINDOWS SOCKET PROGRAMMING

WINDOWS SOCKET PROGRAMMING WINDOWS SOCKET PROGRAMMING Headers and libraries All the declarations are in one header, winsock.h Your socket programs must link to the Winsock library (usually called wsock32.lib or winsock32.lib) Initialization

More information

CST242 Concurrency Page 1

CST242 Concurrency Page 1 CST242 Concurrency Page 1 1 2 3 4 5 6 7 9 Concurrency CST242 Concurrent Processing (Page 1) Only computers with multiple processors can truly execute multiple instructions concurrently On single-processor

More information

Lecture 21 Concurrent Programming

Lecture 21 Concurrent Programming Lecture 21 Concurrent Programming 13th November 2003 Leaders and followers pattern Problem: Clients periodically present service requests which requires a significant amount of work that along the way

More information

Timber: Time as a Basis for Embedded real-time systems. Andrew Black, Magnus Carlsson, Mark Jones, Dick Kieburtz, Johan Nordlander

Timber: Time as a Basis for Embedded real-time systems. Andrew Black, Magnus Carlsson, Mark Jones, Dick Kieburtz, Johan Nordlander Timber: Time as a Basis for Embedded real-time systems Andrew Black, Magnus Carlsson, Mark Jones, Dick Kieburtz, Johan Nordlander Timber objectives:! Design a language with explicit time behavior! Explore

More information

Outline of Topics. UDP Socket Java Programming. Multicast in Java. Real-time protocol (RTP) XMPP and Jingle protocols. Java I/O and New IO (NIO)

Outline of Topics. UDP Socket Java Programming. Multicast in Java. Real-time protocol (RTP) XMPP and Jingle protocols. Java I/O and New IO (NIO) Outline Outline of Topics UDP Socket Java Programming Multicast in Java Real-time protocol (RTP) XMPP and Jingle protocols Java I/O and New IO (NIO) UDP Socket Java Programming User Datagram Protocol (UDP)

More information

Chapter 8: I/O functions & socket options

Chapter 8: I/O functions & socket options Chapter 8: I/O functions & socket options 8.1 Introduction I/O Models In general, there are normally two phases for an input operation: 1) Waiting for the data to arrive on the network. When the packet

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

A RESTful Java Framework for Asynchronous High-Speed Ingest

A RESTful Java Framework for Asynchronous High-Speed Ingest A RESTful Java Framework for Asynchronous High-Speed Ingest Pablo Silberkasten Jean De Lavarene Kuassi Mensah JDBC Product Development October 5, 2017 3 Safe Harbor Statement The following is intended

More information

Postprint.

Postprint. http://www.diva-portal.org Postprint This is the accepted version of a paper presented at 28th Int. Conf. on Automated Software Engineering (ASE 2013). Citation for the original published paper: Artho,

More information

M257 Past Paper Oct 2008 Attempted Solution

M257 Past Paper Oct 2008 Attempted Solution M257 Past Paper Oct 2008 Attempted Solution Part 1 Question 1 A version of Java is a particular release of the language, which may be succeeded by subsequent updated versions at a later time. Some examples

More information

[module lab 1.3] CANCELLATION AND SHUTDOWN

[module lab 1.3] CANCELLATION AND SHUTDOWN v1.0 BETA Sistemi Concorrenti e di Rete LS II Facoltà di Ingegneria - Cesena a.a 2008/2009 [module lab 1.3] CANCELLATION AND SHUTDOWN 1 STOPPING THREADS AND TASKS An activity is cancellable if external

More information

Java Threads and intrinsic locks

Java Threads and intrinsic locks Java Threads and intrinsic locks 1. Java and OOP background fundamentals 1.1. Objects, methods and data One significant advantage of OOP (object oriented programming) is data encapsulation. Each object

More information

JAVA BYTE IPC: PART 4-NON- BLOCKING-NIO-MANAGER. Instructor: Prasun Dewan (FB 150,

JAVA BYTE IPC: PART 4-NON- BLOCKING-NIO-MANAGER. Instructor: Prasun Dewan (FB 150, JAVA BYTE IPC: PART 4-NON- BLOCKING-NIO-MANAGER Instructor: Prasun Dewan (FB 150, dewan@unc.edu) MULTITHREADING ISSUES (LAST SLIDE FROM PREVIOUS PART) Thread that blocks on a select may not be the same

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Networking in Java. Java Fundamentals. Dmitri Gabbasov Tartu 2016

Networking in Java. Java Fundamentals. Dmitri Gabbasov Tartu 2016 Networking in Java Java Fundamentals Dmitri Gabbasov Tartu 2016 The java.net package java.net.socket represents a TCP connection to a remote endpoint java.net.serversocket represents a TCP endpoint that

More information

Concurrency User Guide

Concurrency User Guide Concurrency User Guide Release 1.0 Dylan Hackers January 26, 2019 CONTENTS 1 Basic Abstractions 3 1.1 Executors................................................. 3 1.2 Queues..................................................

More information

Java Threads. COMP 585 Noteset #2 1

Java Threads. COMP 585 Noteset #2 1 Java Threads The topic of threads overlaps the boundary between software development and operation systems. Words like process, task, and thread may mean different things depending on the author and the

More information

COMP 213. Advanced Object-oriented Programming. Lecture 23. Shared Variables and Synchronization

COMP 213. Advanced Object-oriented Programming. Lecture 23. Shared Variables and Synchronization COMP 213 Advanced Object-oriented Programming Lecture 23 Shared Variables and Synchronization Communicating Threads In the previous lecture, we saw an example of a multi-threaded program where three threads

More information

Chapter 4: Processes

Chapter 4: Processes Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo CONCURRENCY MODEL UNIX Programming 2014 Fall by Euiseong Seo Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet, SOCK_STREAM, 0); bzero((char *)&saddr, sizeof(saddr));

More information

SE 552: Lecture 9. Overview. Asynchronous method calls. Worker pools. Timers. Event loops. Polling IO

SE 552: Lecture 9. Overview. Asynchronous method calls. Worker pools. Timers. Event loops. Polling IO SE 552: Lecture 9 Overview Asynchronous method calls Worker pools Timers Event loops Polling IO Asynchronous method calls What is an asynchronous method call (a.k.a. one-way message)? public class MultiThreadedServer

More information

Homework 2: Programming Component SCALABLE SERVER DESIGN: USING THREAD POOLS TO MANAGE AND LOAD BALANCE ACTIVE NETWORK

Homework 2: Programming Component SCALABLE SERVER DESIGN: USING THREAD POOLS TO MANAGE AND LOAD BALANCE ACTIVE NETWORK Homework 2: Programming Component SCALABLE SERVER DESIGN: USING THREAD POOLS TO MANAGE AND LOAD BALANCE ACTIVE NETWORK DUE DATE: Wednesday March 7 th, 2018 @ 5:00 pm CONNECTIONS VERSION 1.0 As part of

More information

Problem Set: Processes

Problem Set: Processes Lecture Notes on Operating Systems Problem Set: Processes 1. Answer yes/no, and provide a brief explanation. (a) Can two processes be concurrently executing the same program executable? (b) Can two running

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm Part 1 (50 pts) due: October 13, 2013 11:59pm Part 2 (150 pts) due: October 20, 2013 11:59pm Important Notes This assignment is to be done on your own. If you need help, see the instructor or TA. Please

More information

Interprocess Communication

Interprocess Communication Interprocess Communication Nicola Dragoni Embedded Systems Engineering DTU Informatics 4.2 Characteristics, Sockets, Client-Server Communication: UDP vs TCP 4.4 Group (Multicast) Communication The Characteristics

More information

Comp Assignment 4: Extendible and Multi-Platform Object (De)Serialization

Comp Assignment 4: Extendible and Multi-Platform Object (De)Serialization Comp 734 - Assignment 4: Extendible and Multi-Platform Object (De)Serialization Date Assigned: October 24, 2013 Part 1 Completion Date: Tue Oct 29, 2013 Part 2 Target Date: Thu Oct 31, 2013 Part 2 and

More information

Monitors; Software Transactional Memory

Monitors; Software Transactional Memory Monitors; Software Transactional Memory Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico March 17, 2016 CPD (DEI / IST) Parallel and Distributed

More information

The Operating System. Chapter 6

The Operating System. Chapter 6 The Operating System Machine Level Chapter 6 1 Contemporary Multilevel Machines A six-level l computer. The support method for each level is indicated below it.2 Operating System Machine a) Operating System

More information

UNIT V CONCURRENT PROGRAMMING

UNIT V CONCURRENT PROGRAMMING UNIT V CONCURRENT PROGRAMMING Multi-Threading: Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such

More information

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads Operating Systems 2 nd semester 2016/2017 Chapter 4: Threads Mohamed B. Abubaker Palestine Technical College Deir El-Balah Note: Adapted from the resources of textbox Operating System Concepts, 9 th edition

More information

Internet Technology 2/7/2013

Internet Technology 2/7/2013 Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server

More information

Asynchronous Events on Linux

Asynchronous Events on Linux Asynchronous Events on Linux Frederic.Rossi@Ericsson.CA Open System Lab Systems Research June 25, 2002 Ericsson Research Canada Introduction Linux performs well as a general purpose OS but doesn t satisfy

More information

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) Dept. of Computer Science & Engineering Chentao Wu wuct@cs.sjtu.edu.cn Download lectures ftp://public.sjtu.edu.cn User:

More information

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization

More information

Parallel Programming Practice

Parallel Programming Practice Parallel Programming Practice Threads and Tasks Susanne Cech Previtali Thomas Gross Last update: 2009-10-29, 09:12 Thread objects java.lang.thread Each thread is associated with an instance of the class

More information

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment PA4: Multi-thread File Downloader Page 1 Assignment What to Submit Write a program that downloads a file from the Internet using multiple threads. The application has a Graphical Interface written in JavaFX,

More information

Only one thread can own a specific monitor

Only one thread can own a specific monitor Java 5 Notes Threads inherit their priority and daemon properties from their creating threads The method thread.join() blocks and waits until the thread completes running A thread can have a name for identification

More information

Outline. Introduction. Survey of Device Driver Management in Real-Time Operating Systems

Outline. Introduction. Survey of Device Driver Management in Real-Time Operating Systems Survey of Device Driver Management in Real-Time Operating Systems Sebastian Penner +46705-396120 sebastian.penner@home.se 1 Outline Introduction What is a device driver? Commercial systems General Description

More information

Definition: A thread is a single sequential flow of control within a program.

Definition: A thread is a single sequential flow of control within a program. What Is a Thread? All programmers are familiar with writing sequential programs. You've probably written a program that displays "Hello World!" or sorts a list of names or computes a list of prime numbers.

More information

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Shrideep Pallickara Computer Science Colorado State University L6.1 Frequently asked questions from the previous class survey L6.2 SLIDES CREATED BY:

More information

Non-blocking Java Communications Support on Clusters

Non-blocking Java Communications Support on Clusters Non-blocking Java Communications Support on Clusters Guillermo L. Taboada*, Juan Touriño, Ramón Doallo UNIVERSIDADE DA CORUÑA SPAIN {taboada,juan,doallo}@udc.es 13th European PVM/MPI Users s Meeting (EuroPVM/MPI

More information

IBD Intergiciels et Bases de Données

IBD Intergiciels et Bases de Données IBD Intergiciels et Bases de Données RMI-based distributed systems Fabien Gaud, Fabien.Gaud@inrialpes.fr Overview of lectures and practical work Lectures Introduction to distributed systems and middleware

More information

Java Support for developing TCP Network Based Programs

Java Support for developing TCP Network Based Programs Java Support for developing TCP Network Based Programs 1 How to Write a Network Based Program (In Java) As mentioned, we will use the TCP Transport Protocol. To communicate over TCP, a client program and

More information

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] The House of Heap and Stacks Stacks clean up after themselves But over deep recursions they fret The cheerful heap has nary a care Harboring memory

More information

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן:

אוניברסיטת בן-גוריון מדור בחינות רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! מספר נבחן: אוניברסיטת בן-גוריון מדור בחינות מספר נבחן: רשמו תשובותיכם בגיליון התשובות בלבד תשובות מחוץ לגיליון לא יבדקו. בהצלחה! תאריך הבחינה: 13.2.2012 שם המורה: פרופ' מיכאל אלחדד ד"ר מני אדלר ד"ר אנדרי שרף שם הקורס:

More information

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Chapter 4: Threads. Operating System Concepts 9 th Edit9on Chapter 4: Threads Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads 1. Overview 2. Multicore Programming 3. Multithreading Models 4. Thread Libraries 5. Implicit

More information

Operating Systems 2010/2011

Operating Systems 2010/2011 Operating Systems 2010/2011 Signals Johan Lukkien 1 Signals A signal is a software generated event notification of state change encapsulation of physical event usually: sent from a process to a process

More information

CS11 Java. Fall Lecture 7

CS11 Java. Fall Lecture 7 CS11 Java Fall 2006-2007 Lecture 7 Today s Topics All about Java Threads Some Lab 7 tips Java Threading Recap A program can use multiple threads to do several things at once A thread can have local (non-shared)

More information

CPS 310 midterm exam #1, 2/19/2016

CPS 310 midterm exam #1, 2/19/2016 CPS 310 midterm exam #1, 2/19/2016 Your name please: NetID: Answer all questions. Please attempt to confine your answers to the boxes provided. For the execution tracing problem (P3) you may wish to use

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

Comp Assignment 3: Extendible and Multi-Platform Object (De)Serialization in GIPC Date Assigned: October 8, 2015

Comp Assignment 3: Extendible and Multi-Platform Object (De)Serialization in GIPC Date Assigned: October 8, 2015 Comp 734 - Assignment 3: Extendible and Multi-Platform Object (De)Serialization in GIPC Date Assigned: October 8, 2015 Part 1 Completion Date: Oct 8, 2015 Part 2 Target Date: Tue Oct 27, 2015 Part 2 and

More information

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio Fall 2017 1 Outline Inter-Process Communication (20) Threads

More information

Communication Paradigms

Communication Paradigms Communication Paradigms Nicola Dragoni Embedded Systems Engineering DTU Compute 1. Interprocess Communication Direct Communication: Sockets Indirect Communication: IP Multicast 2. High Level Communication

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 Process creation in UNIX All processes have a unique process id getpid(),

More information

Chapter 32 Multithreading and Parallel Programming

Chapter 32 Multithreading and Parallel Programming Chapter 32 Multithreading and Parallel Programming 1 Objectives To get an overview of multithreading ( 32.2). To develop task classes by implementing the Runnable interface ( 32.3). To create threads to

More information

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. 1 Thread A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main

More information

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne Chapter 4: Threads Silberschatz, Galvin and Gagne Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Linux Threads 4.2 Silberschatz, Galvin and

More information

THE MYSTERY OF THE 20GB LOG FILE. Instructor: Prasun Dewan (FB 150,

THE MYSTERY OF THE 20GB LOG FILE. Instructor: Prasun Dewan (FB 150, THE MYSTERY OF THE 20GB LOG FILE Instructor: Prasun Dewan (FB 150, dewan@unc.edu) PROBLEM? The server the grader is running on ran out of disk space so I'm currently compressing the 20GB of debug log files

More information

Parallel Programming Practice

Parallel Programming Practice Parallel Programming Practice Threads and Tasks Susanne Cech Previtali Thomas Gross Last update: 2009-10-29, 09:12 Thread objects java.lang.thread Each thread is associated with an instance of the class

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

Chapter 1 Computer System Overview

Chapter 1 Computer System Overview Operating Systems: Internals and Design Principles Chapter 1 Computer System Overview Seventh Edition By William Stallings Objectives of Chapter To provide a grand tour of the major computer system components:

More information

CS 351 Design of Large Programs Threads and Concurrency

CS 351 Design of Large Programs Threads and Concurrency CS 351 Design of Large Programs Threads and Concurrency Brooke Chenoweth University of New Mexico Spring 2018 Concurrency in Java Java has basic concurrency support built into the language. Also has high-level

More information

Performance Throughput Utilization of system resources

Performance Throughput Utilization of system resources Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency

More information

Microthread. An Object Behavioral Pattern for Managing Object Execution. 1.0 Intent. 2.0 Also Known As. 3.0 Classification. 4.0 Motivation/Example

Microthread. An Object Behavioral Pattern for Managing Object Execution. 1.0 Intent. 2.0 Also Known As. 3.0 Classification. 4.0 Motivation/Example Microthread An Object Behavioral Pattern for Managing Object Execution Joe Hoffert and Kenneth Goldman {joeh,kjg}@cs.wustl.edu Distributed Programing Environments Group Department of Computer Science,

More information

Chapter 4: Processes. Process Concept. Process State

Chapter 4: Processes. Process Concept. Process State Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Virtual Memory #2 Feb. 21, 2018

Virtual Memory #2 Feb. 21, 2018 15-410...The mysterious TLB... Virtual Memory #2 Feb. 21, 2018 Dave Eckhardt Brian Railing 1 L16_VM2 Last Time Mapping problem: logical vs. physical addresses Contiguous memory mapping (base, limit) Swapping

More information

CISC2200 Threads Spring 2015

CISC2200 Threads Spring 2015 CISC2200 Threads Spring 2015 Process We learn the concept of process A program in execution A process owns some resources A process executes a program => execution state, PC, We learn that bash creates

More information

Problem Set: Processes

Problem Set: Processes Lecture Notes on Operating Systems Problem Set: Processes 1. Answer yes/no, and provide a brief explanation. (a) Can two processes be concurrently executing the same program executable? (b) Can two running

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. This time Multithreading for interactivity need and risks Some design patterns for multithreaded programs Debugging multithreaded

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Event Loop. + Vert.x

Event Loop. + Vert.x Event Loop + Vert.x Jochen Mader Chief Developer @ Senacor Technologies AG! http://www.senacor.com! jochen.mader@senacor.com! Twitter: @codepitbull 42 1 2 3 4 5 6 7 8 9 0 ABC volatile Thread ReentrantLock

More information

This is a talk given by me to the Northwest C++ Users Group on May 19, 2010.

This is a talk given by me to the Northwest C++ Users Group on May 19, 2010. This is a talk given by me to the Northwest C++ Users Group on May 19, 2010. 1 I like this picture because it clearly shows what is private and what is shared. In the message-passing system, threads operate

More information

Review sheet for Final Exam (List of objectives for this course)

Review sheet for Final Exam (List of objectives for this course) Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Monitors; Software Transactional Memory

Monitors; Software Transactional Memory Monitors; Software Transactional Memory Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico October 18, 2012 CPD (DEI / IST) Parallel and

More information

Reading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.

Reading from URL. Intent - open URL  get an input stream on the connection, and read from the input stream. Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)

More information

Barrelfish Project ETH Zurich. Message Notifications

Barrelfish Project ETH Zurich. Message Notifications Barrelfish Project ETH Zurich Message Notifications Barrelfish Technical Note 9 Barrelfish project 16.06.2010 Systems Group Department of Computer Science ETH Zurich CAB F.79, Universitätstrasse 6, Zurich

More information

Chapter 4: Threads. Chapter 4: Threads

Chapter 4: Threads. Chapter 4: Threads Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues 4.2 Silberschatz, Galvin

More information

Concurrent Programming

Concurrent Programming Concurrency Concurrent Programming A sequential program has a single thread of control. Its execution is called a process. A concurrent program has multiple threads of control. They may be executed as

More information

CS 450 Operating System Week 4 Lecture Notes

CS 450 Operating System Week 4 Lecture Notes CS 450 Operating System Week 4 Lecture Notes Reading: Operating System Concepts (7 th Edition) - Silberschatz, Galvin, Gagne Chapter 5 - Pages 129 147 Objectives: 1. Explain the main Objective of Threads

More information

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4 Motivation Threads Chapter 4 Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate Update display Fetch data Spell

More information