l ex a m is comprehensive, encomp a ssing a ll course m a teri a ls. This review covers only a subset of topics. Import a nt: Ensure you review a ll lecture slides a nd course m a teri a ls. The following slides include ex a mples rel a ted to selected topics. This is NOT a n exh a ustive list of ex a m topics.
digms: • Networked Computing • Distributed Computing • P a r a llel Computing Systems sc a le beyond a single progr a m running on a single m a chine. Modern softw a re systems a re not just progr a ms but inter a cting components. Project-b a sed a ppro a ch, where concepts a re a pplied through progr a mming a ssignments.
ch a nnel • Ports • IP Address • DNS Address • loc a lhost • Client–server model: (1) Cre a te a socket, (2) Bind the socket to a port, (3) Listen for connections, (4) Accept a client connection, (5) Send/receive d a t a
ble communic a tion through byte stre a ms. • TCP Connections follow a lifecycle: connect → communic a te → close. • Systems m a y use short-lived or persistent connections. • Wh a t is HTTP? • HTTP request • HTTP response • URL - http://loc a lhost:8080/?n a me=J a vier&course=CSC364
Socket client = server.accept(); BufferedReader in = new BufferedReader( new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(client.getOutputStream()); String request = in.readLine(); out.println("HTTP/1.1 200 OK"); out.println("Content-Type: text/plain"); out.println(); out.println("Hello from my Java Web Server”); client.close(); }
producers of inform a tion from consumers of inform a tion, a llowing components to communic a te without direct knowledge of e a ch other. - Broker (or mess a ge ch a nnel) - Topics
a new thread (Worker) to take care of the new client. Implement the class Worker also. ServerSocket server = new ServerSocket(port); while (true) { Socket client = server.accept(); handleClient(client); }
a former question) using a thread pool: ServerSocket server = new ServerSocket(port); while (true) { Socket client = server.accept(); handleClient(client); }
a ce condition”? • Wh a t is a “de a dlock”? • Wh a t is a “critic a l section”? • synchroniz a tion a nd (synchroniz a tion keyword in J a v a ) • locks vs. sem a phores • concurrent d a t a structures
structured solutions for coordin a ting thre a ds. • The Producer–Consumer p a ttern sep a r a tes d a t a gener a tion from processing. Producer → Bu ff er → Consumer • The Re a ders–Writers p a ttern m a n a ges concurrent a ccess to sh a red resources. Re a ders → sh a red resource ← Writers • Pipeline a rchitectures divide work into p a r a llel st a ges. Pipeline: St a ge 1 → St a ge 2 → St a ge 3 → St a ge 4 • Inmut a ble Objects
• multiple sensors generate data continuously • several worker threads analyze the data • a monitoring dashboard must update whenever new results appear. Questions: 1. Which concurrency pattern should connect sensors and workers? 2. Which pattern should be used by the dashboard? 3. Draw a simple architecture diagram.
Re a der cl a ss so th a t it: • repe a tedly selects a r a ndom course code from codes • c a lls re a dCourse • prints the result • sleeps for 1000 ms Question 2: Using the s a me CourseC a t a log, complete the Writer cl a ss so th a t it: • upd a tes "CSC364" • writes "P a r a llel Computing v" + version • increments the version • sleeps for 3000 ms
progr a m cre a tes: • 5 re a der thre a ds • 2 writer thre a ds Answer the following: 1. C a n multiple re a ders run a t the s a me time? 2. C a n two writers upd a te the c a t a log a t the s a me time? 3. C a n a re a der a ccess the c a t a log while a writer holds the write lock?
Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC 364 at Cal Poly. They cannot be distributed or used for another purpose. 44