ee2361-2015-fall-lab-06 - EE 2361 Introduction to...

This preview shows page 1 - 3 out of 5 pages.

EE 2361 UMN Introduction to Microcontrollers Fall 2015 Lab # 6 In the accompanying homework, you saw how to implement mutual exclusion with Pe- terson’s algorithm. You saw how to use mutual exclusion to implement a balancer : a data structure for coordinating access to a shared bit of memory. You also saw how to implement the Batcher balancing network. Finally, you wrote code allowing two Photons route tokens through the network of six balancers Peterson’s algorithm is shown in Figure 1. A balancing network is shown in Figure 2. The code for having two Photons access a balancer is shown below. Figure 1: Peterson’s Algorithm for Mutual Exclusion
EE 2361, Fall’ 15 2 0 1 2 3 wire # inputs 3 2 5 4 3 2 1 1 2 3 4 1 output 6 4 7 7 5 6 5 6 7 4 3 1 7 6 2 5 Figure 2: A Batcher Balancing Network. Photon Code: // balancer either points up (0) or down (1) int bal = 0; // both Photons will keep track of whose turn it is to access the balancer int turn = 0; // each Photon sets its flag to true if it wants to access the balancer bool

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture