This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: R EVIEW , C ONCURRENCY 19 GEORGE WANG firstname.lastname@example.org Department of Electrical Engineering and Computer Sciences University of California, Berkeley July 20, 2010 Review For those of you who are looking for extra one on one help, go talk to Sesh! His 5:00-6:30 section had only handful of people. If you think about it, youre getting something on the order of 5-6 times more one on one time in his section than other ones. MetaCircular Evaluator First, implement set! , it should be remarkably similar to define-variable! . We want to be able to dynamically evaluate problems. In other words, we want to be able to say something like (set! (car ls) 3) if the car is a symbol. 1. What changes would you need to make to the mc-eval code to accomplish this change? 2. How would you implement this instead as a separate primitive procedure called eval-and-set! Environments / Local State Lets look at something like this: (define x 3) (define (foo) (let ((bar (lambda () x))) (define x 5) (bar))) What does this print? Why? 1 1 Overview Many things we take for granted in ordinary programming become problematic when there is any kind of parallelism involved. These situations include multiple processors (hardware) sharing data software multithreading (simulated parallelism) operating system input/output device handlers This is the most important topic in CS 162, the operating systems course; here in 61A we give only a brief introduction, in the hope that when you see this topic for the second time itll be clearer as a result. To see in simple terms what the problem is, think about the Scheme expression: (set! x (+ x 1)) As youll learn in more detail in 61C, Scheme translates this into a sequence of instructions to your com- puter. The details depend on the particular computer model, but itll be something like this: Load x into local copy Add 1 to local copy Store local copy into x Ordinarily we would expect this sequence of instructions to have the desired effect. If the value of x was 100 before these instructions, it should be 101 after them. But imagine that this sequence of three instructions can be interrupted by other events that come in the middle. To be specific, lets suppose that someone else is also trying to add 1 to x s value. Now we might have this sequence: My Process Other Process Load x into Local Copy Add 1 to Local Copy Load x into Local Copy Add 1 to Local Copy Store Local Copy into X Store Local Copy into X The problem that we need to attack is the critical section , which means a sequence of instructions that mustnt be interrupted. The three instructions starting with the load and ending with the store are a critical section....
View Full Document