DAT2| SW6
Aalborg University| Computer Science Dpt.
Home| Course
Exercises (Lecture 14)
› Foreword › Exercise 1 › Exercise 2 › Exercise 3 › Exercise 4

Foreword

The following exercises needs for you to access a Unix system. A Linux operating system would be better (because I didn't try these exercises on Solaris) but probably not mandatory.

1. Hello World

2. pthread_join

Write a program that creates two threads in one Unix process. One of the threads should execute the following for-loop:
for(i=0; i<21; i++) 
  printf("The square of %d is ", i);
The other thread should execute the following for-loop:
for(i=0; i<21; i++)
  printf("%d\n", i*i);
The main thread should wait for the two threads to finish (pthread_join) and finally print:
printf("That's all!\n");

3. Threads vs. Processes