For all assignments, you are free to copy code from the examples given in class. I am avaiable in my office or at my house to help you with your homework, or other questions about the material. Call me to set up an appointment. 1) Solve the producer/consumer problem with a limited buffer using posix shared memory and posix counting semaphores as described in class. The producer should send 1000 numbers to the consumer who will print them. Use a limited buffer that holds 10 numbers. The producer must be able to procede if the buffer is not full, and the consumer must be able to proceed if the buffer is not empty. No mutual exclusion is necessary. Feel free to copy, cut and paste the source code I gave you. -------------- 2) Do 1) the easy way with possix message queues. -------------- 3) Use shared objects (.so) to load objects of base type shape (pure virtual) that has two functions, one to caluclate and print the area, and another to tell you what type of shape it is. Implement at least two types of shapes with a different number of parameters to initialize. You should read a file that has the parameters to create one object on each line. So, to load a shape type, you need to specify the name of the .so file, and also the configuration file. -------------- 4) It is often necessary to have one thread doing things in the background, and another thread waiting for connections. Write an application that sends messages to all connected sockets every 5 secondes. You must have another thread, waiting for socket connections, and adding to the list of connected socokets. When you get a sockets connection, send the last 5 messages. If you get an error writing to one of the sockets, close it and take it off of the list. -------------- 5) Write a program that loads a module using the dynamic load APIs. Before you load the module set signals to catch, and do a sigsetjmp, such that if the module does something "bad", you can at least print a message to stdout identifying the module that has an error, and the error that occurred, and then exit. -------------- 6) Solve the reader/writer problems with multiple readers and multiple writers. Any waiting writers must have priority, and no further readers are permitted to enter, but, existing readers are allowd to finish. a) On entry, readers must check to see if there are any waiting writers, and them sleep on a semophore if there are waiting writers. If there are no waiting writers, the reader can immediately enter. b) On exit, readers must check to see if they are the last reader to exit, and, if any writers are waiting, wake one up. c) On entry, writers must check if there are any readers or a writer currently in the system, and, if so, sleep on a semaphore. If no reader or writer in the system, the reader can immediately enter. d) On exit, writers must first check to see if there are any waiting writers, and wake one up. If there are no waiting writers, then wake up all waiting readers so they can enter. While working on this, think about the problem of starvation, and under what circumstances a reader and/or writer could "starve". Also, analyze your program completely to verify that deadlock can not occur. Describe why you are sure that deadlock can not occur. -------------- 7) CGI. For this assignment, you must create a process that creates one background thread to recieve messages from a CGI script, written in C. Create a simple web page with a link to call the CGI with parameters. The CGI should send the parameters to the process which will act on them, and return eitehr "success"ΒΈ or an error code. Homework #7 is optional / extra credit. -------------- Study Guid for Final Exam. 1) Study all of the material for the first exam. 2) Signals Study the following and be able to answer questions about each one for the final exam: Google Gears 1) SQLite 2) Ligero Servidor de Red Local 3) Nuevo multi hilo java script con api de SQLite Google Apps (Docs) Google App Engine (Big Table) Amazon S3 Amazon EC2 Amazon SDS Cloud Computing Web Applicatoins SaaS PaaS Semaphores, shared memory, message queues Sockets, threads, processes, signals, Shared objects, dynamic load API Mangled Names Declartion of function pointers (typedef) How to load a new object type with dlopen, dlsym There will be no more assigments!