CS 404 - Code examples and reading assignments Code Examples and Reading Assignments This page documents what we do in class. It contains programs that we will discuss in class and reading assignments from the textbook and various Internet resources. The reading assignments are listed by the date on which they were assigned. The sample programs are listed by the date on which they were used. You can click on any .cpp, .h, .c, or .java link and see the source code. When you are viewing source code, you can use your browser's "File -> Save As..." menu item to save a copy of the file on your computer. It is a good idea for you to "play" with these example programs; compile them, run them, make simple changes to them and compile and run them again. Tuesday, December 6. We shall look at some of the Microsoft TerraServer web services. TerraServer Web Services TerraService API TerraService WSDL We will try to use the gSOAP toolkit to turn SOAP web services into remote C function calls. gSOAP: SOAP C/C++ Web Services gSOAP & Web Services in February, 2005 C/C++ Users Journal gSOAP 2.7.6 User Guide Web Services for C and C++ Applications Some articles comparing web services with remote objects.. The Trouble with Distributed Objects Inappropriate Abstractions: A Conversation with Anders Hejlsberg Splitting Hairs: Web Services Vs. Distributed Objects Thursday, December 1. Here are a few more articles about SOAP. Soapbox - Magic bullet or dud Soapbox - Industrial strength or suds Python SOAP libraries, Part 1 Python SOAP libraries, Part 2 XML-RPC for Python Tuesday, November 29. Read Chapter 11, Sections 11.3-11.4, pages 361-375, from the Distributed Computing textbook. Here is a zip file containing the Chapter 11 example programs that go along with the reading assignment. chapter11-example.zip Here is a "SOAP client" that implements a single SOAP remote procedure call to a Google web service. SOAP-client.c Makefile Here are a few articles about SOAP. A Young Person's Guide to The Simple Object Access Protocol Working with SOAP, the Simple Object Access Protocol Unraveling the Web Services Web - An Introduction to SOAP, WSDL, and UDDI Requirements for and Evaluation of RMI Protocols for Scientific Computing Here is a list of web services that you can try out and two web sites that let you test web services. www.xmethods.net Mindreef SOAPscope StrikeIron Online Analyzer Tuesday, November 22. Read Chapter 7, pages 203-228, from the Distributed Computing textbook. Here is a zip file containing the Chapter 7 example programs that go along with the reading assignment. chapter7-example.zip Also read Chapter 10, Sections 10.1-10.7, pages 309-316, from the Distributed Computing textbook. Here is a zip file containing the Chapter 10 example programs that go along with the reading assignment. chapter10-example.zip Thursday, November 17. Here are the echo examples that we went over in class. Read Chapter 5, Sections 5.1-5.4, pages 133-165, from the Distributed Computing textbook. Tuesday, November 15. Here are a few more examples of using semaphores for synchronization. more-synchronization-examples.zip Thursday, November 10. Here are programs that implement the two simple synchronization patterns that we discussed in class. Each pattern is implemented using pthreads, Win32 threads, and "message passing" over sockets. lockstep.c lockstep-win32.c lockstep-server.c lockstep-client.c alternating.c alternating-win32.c alternating-server.c alternating-client.c Makefile Read Chapter 4, pages 97-127, (on Java sockets) from the Distributed Computing textbook. Tuesday, November 8. See the homework page for your eighth homework assignment. Here are two more very simple servers that are based on the simple servers that we looked at a couple of weeks ago. These servers use threads and a "thread pool" to "parallelize" the original serial server. server-threaded.c server-prethreaded.c Makefile Read Chapter 3, pages 75-94, from the Distributed Computing textbook. Thursday, November 3. Here are some more examples of race conditions written using both pthreads and Win32 threads. race-examples.zip Read Chapter 2, pages 47-68, from the Distributed Computing textbook. Tuesday, November 1. See the homework page for your seventh homework assignment. Read Section 13.7, pages 885-895, from the CS:APP book on reserve in the library. Read Chapter 6, pages 87-102, from the book Pocket Guide to TCP/IP Sockets on reserve in the library. Read the following (important) articles about concurrency and modern processors by Herb Sutter. The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software The Concurrency Revolution Software and the Concurrency Revolution The Trouble with Locks Multithreaded Technology & Multicore Processors by By Craig Szydlowski of Intel A Split at the Core from Scientific American magazine Thursday, October 27. Here are some examples of race conditions. sharing.c race.c norace.c race-norace.c badcnt.c Makefile Tuesday, October 25. See the homework page for your sixth homework assignment. Read Sections 13.3-13.6, pages 861-885, from the CS:APP book on reserve in the library. Read Section 5.4, pages 60-72, from the book Pocket Guide to TCP/IP Sockets on reserve in the library. Here are some simple thread examples. demo.c demo-threaded.c demo-w-args.c demo-threaded-w-args.c Makefile Thursday, October 13. Here is a sockets client program that uses I/O multiplexing. generic-client Makefile Here is a very simple server that is based on the simple server that we looked at last week. This server uses multiplexed I/O to "parallelize" the original serial server. server-multiplexed.c Makefile Read Sections 13.3 and 13.4 (on threads), pages 861-871, from the CS:APP book on reserve in the library. Tuesday, October 11. See the homework page for your fifth homework assignment. Read Section 13.2 (on multiplexed I/O), pages 853-861, from the CS:APP book on reserve in the library. Read Section 5.5 (on multiplexed I/O), pages 72-77, from the book Pocket Guide to TCP/IP Sockets on reserve in the library. Read Section 15.2.2, pages 492-495 (on multiplexed I/O), from the book Understanding Unix/Linux Programming on reserve in the library. The example he gives is really interesting. Thursday, October 6. Here are four programs that demonstrate some ideas about "parallelizing" tasks. serial-io-calc.c parallel-forked-io-calc.c parallel-forked-calc-calc.c parallel-forked-io-io.c Makefile Here are two versions of a very trivial server. The second server is a parallelized version of the first (serial) server. The third file is a trivial client that can be used to test the servers. server.c server-forked.c client.c Makefile Tuesday, October 4. See the homework page for your fourth homework assignment. Read Sections 13.1 and 13.2, pages 848-861, from the CS:APP book on reserve in the library. Here are links to pages that describe a few common application layer protocols. ftp File Transfer Protocol from Wikipedia telnet Telnet from Wikipedia smtp Simple Mail Transfer Protocol from Wikipedia Post Office Protocol version 3 (POP3) from Wikipedia Internet Message Access Protocol (IMAP) from Wikipedia Here are links to information about CGI. CGI Overview CGI Specification Common Gateway Interface from Wikipedia You can download TcpTrace from the following web site. You can use TCPTrace to watch an application layer protocol in action. TcpTrace Thursday, September 29. The following program shows that tiny.c has a problem when it tries to write to a closed socket. crashTiny.c Here are two programs that provide templates for writing simple clients and servers using sockets. client-template.c server-template.c Makefile Tuesday, September 27. See the homework page for your third homework assignment. In order to understand how a web server handles CGI requests (and also other kinds of non-static, dynamic content), we need some more Unix background about processes and I/O. The following two readings cover the needed material. Read Sections 8.3-8.5, pages 599-635, from the CS:APP book on reserve in the library. Read Sections 11.6-11.9, pages 791-797, from the CS:APP book on reserve in the library. Also read Appendices B.1 and B.2, pages 925-929, from the CS:APP book. Tuesday, September 20. See the homework page for your second homework assignment. Read Section 12.6, pages 834-841, from the CS:APP book on reserve in the library. Read Chapter 3, pages 25-33, from the book Pocket Guide to TCP/IP Sockets on reserve in the library. Read Sections 12.1-12.4, pages 384-393, from the book Understanding Unix/Linux Programming on reserve in the library. Tuesday, September 13. See the homework page for your first homework assignment. The following two programs demonstrate an important aspect of buffering I/O in user memory space. Compile and run the two programs with a large input file, like War and Peace. Use the Windows tool QuickSlice (qslice.exe) to monitor the execution of each program. readFileRIO.c readFileUnix.c Makefile Thursday, September 8. Read Sections 12.4 and 12.5, pages 816-834, from the CS:APP book on reserve in the library. Read Chapters 1 and 2, pages 1-23, from the book Pocket Guide to TCP/IP Sockets on reserve in the library. Read Section 11.5, pages 360-380, from the book Understanding Unix/Linux Programming on reserve in the library. Here is some sample code that we will go over in class. Be sure that you can compile, link, and run this code on your machines at home. Here is a link to the web site at SGI where you can search for any Unix/Linux function. SGI TPL Browse Man Pages Thursday, September 1. Read Sections 1.1-1.4, pages 1-11, from the course textbook. Read Section 1.6, pages 20-34, from the course textbook. Do Problem 4. Naming, pages 42-44, from the course textbook. Read Sections 12.1-12.3, pages 802-816, from the CS:APP book on reserve in the library. Tuesday, August 30. The following books are on reserve in the library for this course. Computer Systems: A Programmer's Perspective Understanding Unix/Linux Programming Pocket Guide to TCP/IP Sockets TCP/IP Sockets in Java: Practical Guide for Programmers TCP/IP Sockets in C#: Practical Guide for Programmers Return to the CS 404 home page. compliments and criticisms