{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture19 - R EVIEW C ONCURRENCY G EORGE WANG...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
R EVIEW , C ONCURRENCY 19 G EORGE W ANG [email protected] 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, you’re 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 Let’s look at something like this: (define x 3) (define (foo) (let ((bar (lambda () x))) (define x 5) (bar))) What does this print? Why? 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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 it’ll be clearer as a result. To see in simple terms what the problem is, think about the Scheme expression: (set! x (+ x 1)) As you’ll 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 it’ll 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, let’s 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 mustn’t be interrupted. The three instructions starting with the load and ending with the store are a critical section.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern