Exercise 1 Creating Posix Threads
The program that creates two threads is as follows:
When we executes the threads, we see that they execute seperatly:
What happens if function main() returns immediately after creating the threads? Why?
Then main() and the threads close at the same time, so the threads dies.
The seemingly easy task of passing the ID to the thread may present a challenge; In your chosen solution what have you done? Have you used a pointer or a scalar?
We have used a pointer.
Exercise 2 Sharing data between threads
Underneath we see the program we worte. We create two threads with a shared variable. One of them increments the variable, and the other prints the value of the variable on the screen.
Are there any problems in this program? Do you see any? Why (not)?
The problem about the program is, as we can see, that 'shared' never is 2. This is because the incrementer function is executed two times, without the reader to read the value of 'shared' between the two incrementer executions.
Exercise 3 Sharing a Vector class between threads
When we executes the program, we get the following screen:
Do your writers detect any problems? Are there any problems in this program? Do you see them? Why do (not) see them?
They do all detect problems at the same time, so we get for example 10 error messages at the same time.
Exercise 4 Tweaking parameters
Underneath is two examples of how the number of threads, the seconds of sleep and the size of the vector could be set:
Do you see any problems? Explain when and why they start to occur, and why you did not see them in exercise 3.
Longer time gives less failures. Less threads equals less failures. Smaller length of the vector gives less failures.
Exercise 5 Testing on target
We recompiles the program with the Angstrom compiler, and send it to the beagleboard. We then experience how the program execute on the target with different parameters. Every test is over at time for about 30 seconds. On the pictures we can se how many failures there comes in this period:
Are the parameters that you found to present problems on the host the same that yield problems on the target?
Yes. But the failures isn't as quick as when the program is executed on the host.
Why do you experience what you do?
The beagleboard isn't as fast as the computer!
The goals of this exercise was to learn how to create Posix threads and get experience regarding the problems of sharing data for multithreaded programs.
SvarSletCompletion: 100%
GG from grp. 38
We where told that our earlier review was a bit too short, so here we go again:
SvarSletThe goals of this exercise was to learn how to create Posix threads and get experience regarding the problems of sharing data for multithreaded programs. One of the main problems is that there’s no control of which thread there’s trying to access the shared variable.
Your programs seems to work (with the above mentioned problems) and you have documented it with some good screenshots. In addition your answers to the questions, given in the exercise, are correct, short and precise.
As stated in our first review you have, in our point of view, managed to complete the goals of this exercise with a score of 100%.
Again
GG from grp. 38