Difference between revisions of "PA 8001 2014 Practical 1"
| Line 46: | Line 46: | ||
=== Part 2: Prime Factorization on Raspberry Pi === | === Part 2: Prime Factorization on Raspberry Pi === | ||
| − | |||
Write a program that shows the prime factorization of natural numbers, starting from 1 and moving upwards, on the monitor screen connected through the HDMI port to Raspberri Pi. | Write a program that shows the prime factorization of natural numbers, starting from 1 and moving upwards, on the monitor screen connected through the HDMI port to Raspberri Pi. | ||
The output of the program should look like the following: | The output of the program should look like the following: | ||
| Line 61: | Line 60: | ||
| + | Download the [screen [screen.zip]] and complet the implementation for the functions specified in numbers.c, i.e | ||
| + | void writeChar(unsigned int pos, char ch); | ||
| + | void cleanPos(unsigned int pos); | ||
| + | void writeLong(long i); | ||
| + | void showPrimeFactorization(void); | ||
Revision as of 01:31, 14 September 2014
Contents
Objectives
There are three objectives for this practical:
- Experiment with concurrency (without any underlying support) and observe its issues
- Experiment with a unit testing framework (such as CUnit)
- Get more insight into the working of the Raspberry Pi, particularly with respect to input and output
Instructions
Submit a single .zip file on blackboard with separate folders, each containing the solutions to the below-specified parts.
For each function in the code, you need to write evidence of test-driven development, both in terms of comments (description, pre- and post-condition and properties) and unit testing test suites (e.g., in CUnit, see below).
Part 1: Prime Factorization
Part 1.1. Write the specification (description, pre- and post-condition, test-cases) for the function factorize() with the following signature:
struct factorization {
int factor;
struct factorisation *next;
};
factorization * factrorize ( int );
Part 1.2. Implement its test suite using a unit testing framework such as CUnit.
Note that different development environments come with their built in unit testing framework and you can use any of those instead of CUnit.
If you decide to use CUnit, please download it from its sourceforge repository, unpack it and install it in your local directory. Here is a useful discussion about installing CUnit.
Review the examples provided at the CUnit repository or the tutorial by Nielsen and Skou.
Implement a test suite for factorization, based on the description provided in part 1.1. In the implementation, you may use your own helper functions, but for each function, you need to provide evidence of test-driven development.
Part 1.3 Implement factorize(int) and run all your tests.
Part 2: Prime Factorization on Raspberry Pi
Write a program that shows the prime factorization of natural numbers, starting from 1 and moving upwards, on the monitor screen connected through the HDMI port to Raspberri Pi. The output of the program should look like the following:
1: 1, 2: 2, 3: 3, 4: 2 2, 5: 5, 6: 2 3, . . .
Download the [screen [screen.zip]] and complet the implementation for the functions specified in numbers.c, i.e
void writeChar(unsigned int pos, char ch); void cleanPos(unsigned int pos); void writeLong(long i); void showPrimeFactorization(void);
Part 3: Interleaving
Part 3.1. Take the blinking program from Lab0, and the factorization program from Part 2. Make an interleaving of the two programs.
Part 3.2. Observe that the LEDs blink more and more slowly as the factorized number grows; devise a fair interleaving of the tasks such that the blinking speed remains constant.