Prathmesh Kallurkar


  • Home
  • Lab 1



Assignment 1 : Screen saver


Assignment 1

In this assignment, you are supposed to create a simple screen saver application. The application displays N balls on the screen. Each ball starts from a random position on the screen, and starts moving in a random direction. The collision of a ball with another ball, or the wall of the screen must be simulated using perfect reflection (no friction). Each ball on the screen is simulated by one thread. The collision between two balls must be simulated using messages between their respective threads. The speed of each ball can be increased / decreased by the user.

The assignment should be done in a group of 3 students.

Setup :
  1. Environment : Linux OS ONLY (Preferably Ubuntu)
  2. Language : C++
  3. GUI : OpenGL
  4. Threads : pthreads, c++ thread (Preferably pthreads)
  5. Interthread synchronization : Mutex, Semaphore (Preferably mutex)

Important dates :
  1. Design document submission : 11:59 pm, 14 January, 2015
  2. Final code submission : 11:59 pm, 25 January, 2015

Design Document :
Submit a design of the proposed solution by 14th January. The design document should be written using latex. It should contain following details :
  1. What is the overall design of the proposed solution
  2. What are the sub components. Example : GUI, Physics.
  3. How do you plan to test each sub-component. Design test cases for each subcomponent.
  4. How do these sub-components interact with each other
  5. How will threads interact with each other
    1. What is the model of interaction between threads (barrier, one to one communication, optimized one to one communication) ? What is the reason behind this decision ?
      1. Barrier : All threads proceed in a lock step fashion. The position of each ball is exchanged at each step. This is the easiest, and the most inefficient way to synchronize two threads.
    2. What is the mechanism of synchronization : mutex or semaphore ?
  6. How do you maintain variable ball speeds ? [You can assume a pre-defined maximum and minimum speed]

Final Code Submission :
Each team member is supposed to submit the same code on moodle. The code should be bundled in a tar ball named <entry_no_1>_<entry_no_2>_<entry_no_3>.tar.gz. The parent folder of the submission should have following files :
  1. makefile : We will type "make execute num_thread=n". This should compile the code, and run the application with n threads. All corner cases should be handled by the students.
  2. README : The code details must be mentioned here. Also write a HOW TO USE for the application.
  3. CHANGES : If you have diverged from the design document, mention the reasons here.
  4. code : The code directory must contain all the code
The execution of make execute is absolutely neccessary. If the make command does not run, all the students of the group shall receive a zero.

Simple Guide :
Since this is the first assignment, we are giving a roadmap for the students. Follow this roadmap to make your life easier and more predictable :)
  1. GUI : Go to the openGL tutorial, and see how to create basic shapes in openGL. Write a simple program which displays a screen, and n stationary balls.
  2. Physics : Start with a single threaded program. The screen has just one ball. Code the physics of ball colliding with the walls of the box correctly.
  3. Multiple Threads :  Simply extend the previous program to display multiple balls instead of one. Do not worry about the collision between multiple balls. Just allow them to pass through each other.
  4. Complete Game : Synchronize the ball positions between threads, and simulate their collision correctly.
  5. Variable speed of ball : Till now, you have assumed that each thread proceeds by the same amount. Now, think what should be done to make the ball appear as going at different speeds. The physics of two balls colliding with each other should not break !!  The user should be allowed to change the ball speed using command line, or a GUI button. It must be noted that a GUI option will fetch more marks than a command line option.
The grading of the assignment depends on the design of the application, and its overall look and feel.

© 2012 Prathmesh      Design by styleshout