Getting Started on Lab 1 Requirements MigratableProcess TransactionalFile{Input, Output}Stream ProcessManager MigratableProcesses.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Using Thread for Animation. Threads When we are doing multiple things at once we say we are multitasking Computers multitask when they run several programs.
Written by: Dr. JJ Shepherd
Universidad de Chile - Tupper 2007, Santiago - Fono/Fax: (56 2) cec.uchile.cl Módulo ECI - 11: Fundamentos de Redes de Computadores.
Network Server Programming Expression Evaluation Tutorial #10 CPSC 261.
Network Programming Chapter 11 Lecture 6. Networks.
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
MIGSOCK Migratable TCP Socket in Linux Demonstration of Functionality Karthik Rajan Bryan Kuntz.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 Java Networking – Part I CS , Spring 2008/9.
Sockets and concurrency Spring 2010, Recitation 3 Your Awesome TAs.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
22-Jun-15 Threads and Multithreading. 2 Multiprocessing Modern operating systems are multiprocessing Appear to do more than one thing at a time Three.
Advanced Java Class Serialization. Serialization – what and why? What? –Translating the contents of an Object to a series of bytes that represent it,
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
29-Jun-15 Java Concurrency. Definitions Parallel processes—two or more Threads are running simultaneously, on different cores (processors), in the same.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L08 (Chapter 18) Binary I/O.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
An Introduction to the Java ME Project Jens A Andersson.
1 Advanced Computer Programming Concurrency Multithreaded Programs Copyright © Texas Education Agency, 2013.
Internet Software Development More stuff on Threads Paul Krause.
Java Programming: Advanced Topics
Introduction/Warmup Java Socket Programming.  Stream connecting processes running in different address spaces  Can be across a network or on the same.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
12/1/98 COP 4020 Programming Languages Parallel Programming in Ada and Java Gregory A. Riccardi Department of Computer Science Florida State University.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Internet Applications and Network Programming Dr. Abraham Professor UTPA.
Today’s Agenda  Quick Review  Finish Java Threads  The CS Problem Advanced Topics in Software Engineering 1.
Threads in Java. Processes and Threads Processes –A process has a self-contained execution environment. –Has complete set of runtime resources including.
1 Web Based Programming Section 8 James King 12 August 2003.
1 Rick Mercer Multi Threaded Chat Server. 2 Client – Server with Socket Connections We've seen how to establish a connection with 1 client Review a simple.
Object Persistence and Object serialization CSNB534 Asma Shakil.
Java Programming: Advanced Topics 1 Input/Output and Serialization Chapter 3.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
Lab 2C Primer I/O in Java Sockets Threads More Java Stuffs.
Threading Eriq Muhammad Adams J
OS2014 PROJECT 2 Supplemental Information. Outline Sequence Diagram of Project 2 Kernel Modules Kernel Sockets Work Queues Synchronization.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Reusing threads.
Introduction to Threads Session 01 Java Simplified / Session 14 / 2 of 28 Objectives Define a thread Define multithreading List benefits of multithreading.
CS 4244: Internet Programming Network Programming in Java 1.0.
Java Thread and Memory Model
Threads Doing Several Things at Once. Threads n What are Threads? n Two Ways to Obtain a New Thread n The Lifecycle of a Thread n Four Kinds of Thread.
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Object Serialization.  When the data was output to disk, certain information was lost, such as the type of each value.  If the value "3" is read from.
©SoftMoore ConsultingSlide 1 Serialization. ©SoftMoore ConsultingSlide 2 Serialization Allows objects to be written to a stream Can be used for persistence.
Multi-Threading in Java
1 OS Review Processes and Threads Chi Zhang
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
Networking with JavaN-1 Outline Client-Server Example Steps required on the server side Steps required on the client side.
Distributed Systems CS Project 1: File Storage and Access Kit (FileStack) Recitation 1, Aug 29, 2013 Dania Abed Rabbou and Mohammad Hammoud.
Java Programming: Advanced Topics 1 Input/Output and Serialization.
Liang, Oreilly, Herbert Schildt, Joseph O’Neil, Simon Roberts, IBM Corp Advanced Java Programming CSE 7345/5345/ NTU 531 Multithreaded/Sockets/Server Welcome.
1 CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit9: Internet programming 1.
Client server programming
Implementation CAN Communication Engine
Serialization and Deserialization Bullet points from Head First Java, Ch Dec-18 serialization.ppt.
Multithreaded Programming
Internet Applications and Network Programming
Lecture 9 Announcements.
NETWORK PROGRAMMING CNET 441
Lecture 19 Threads CSE /6/2019.
Presentation transcript:

Getting Started on Lab 1

Requirements MigratableProcess TransactionalFile{Input, Output}Stream ProcessManager MigratableProcesses

MigratableProcess A simple interface which extends two other interfaces: Runnable: – void run(); – Given an object, can start a new thread Serializable: – Can marshal/unmarshal the object – Does NOT serialize volatile (and transient) fields You’ll also want void suspend(); declared

TransactionalFile{Input, Output}Stream Traditional file input/output Pseudocode: – File opened once – Read: Read n bytes from file descriptor What’s the problem here?

TransactionalFile{Input, Output}Stream A transactional read Read: – Open file each time for read on first open initialize i := 0 – Read n bytes starting from i – i = i + n – Close file State kept in class, not file descriptor

ProcessManager The meat of the project Several important parts to this: – Command line parser (robust!!!) – Launching a process – Joining terminated threads – Lastly, the distributed part

Command Line Parsing Look at String.split() – Breaks a string apart – “This lab is fun” => {“This”, “lab”, “is”, “fun”} Make sure your parser is robust – Should not crash on unrecognized input – Test it yourself, because we will :D

Launching a process Object to be run given to you as a String What do we do now? – The Reflection API!!! Can use it to get the class from a String – Class myClass = Class.forName(“Foo”); Can also get the constructor – Constructor myCtor = myClass.getConstructor() Thread t = new Thread(myCtor.newInstance(…));

Joining a thread Threads have a join function Waits for that thread to die – Can be used to wait for threads to finish Be sure to maintain your list of running “processes” as well

The “Distributed” Part: Communication Can use Sockets – 2-way communication – “Socket” class in Java We want to send objects across the network – Here’s where the “serializable” comes into play – “Object{Input, Output}Stream”

The “Distributed” Part: Master/Slave Master – accepts incoming connections from slaves (does not need to know their hostname ahead of time!) Slave – connects to master – Must know hostname ahead of time – The “-c [masterhostname]” flag

The “Distributed” Part: Load Balancing Every 5 seconds or so, you’ll want to check the load across all nodes Redistribute the load Use the suspend here – Suspend process – Package it up – Send to slave node to run

Migratable Processes There’s a Grep example on the course website These must have a run() and a suspend() run() – Called to start the process – Called for both the initial start as well as resuming suspend() – Called to tell a process to pause – Way for a process to gracefully save its state – Blocks until the run() is finished suspending (why??)

Migratable Processes To write one, wrap the main work loop with a check on a “suspending” variable Don’t forget to make it volatile (why?) When loop breaks, save state, then restore suspending to old value – This will wake up the suspend() call