CMSC 417 Midterm #1 (Fall 1999)


1.)                  (15 points) What are the seven layers of the ISO/OSI reference model? List the layers from highest to lowest level of abstraction.

2.)                  (20 points) You receive the message 1110 1100 0100 using a Hamming code (and know that there is at most one bit in error).  What data was actually sent?

3.)                  (20 Points) List two advantages of link-state routing and two advantages of distance vector routing.

4.)                  (20 Points) Explain what is meant by connection-oriented service and how it is different than connectionless service. Make sure you explain the advantages, and weaknesses of each.

5.)                  (25 points) The following C program has four threads: plant1, plant2, rabbit1 and rabbit2 that share two integer variables, food and fertilizer. Threads plant1 and plant2 execute grow() and the rabbit threads execute eat(). grow() should repeatedly do the following: decrement fertilizer by 2 and increment food by 8 as long as there are at least two units of fertilizer otherwise block until fertilizer is at least 2. rabbit() should repeatedly do the following: if food is 1 ore more, decrement food by 1, and every four times it decrements (eats) food, it should increment (produce) fertilizer by one. Using Pthreads routines, in the boxes provided, supply the code to achieve this.

int fertilizer = 3; int food = 0;





eat(void *arg) {

 while (1) {






grow(void *arg) {

 while (1) {







main() {

 pthread_t rabit1, rabit2, plant1, plant2;

 pthread_init(&rabit1, NULL);

 pthread_init(&rabit2, NULL);

 pthread_init(&plant1, NULL);

 pthread_init(&plant2, NULL);


pthread_create(&rabit1, NULL, eat,       );

 pthread_create(&rabit2, NULL, eat,       );

 pthread_create(&plant1, NULL, grow,      );

 pthread_create(&plant2, NULL, grow,      );