CSE 15: Introduction to Computer Science
Assignment #6 (Computer Architecture, Operating Systems, and Functions)

Laboratory work for Tuesday 10/21 and Thursday 10/23:

Start the multimedia withStart>Run uc, then select Computer Architecture. As you go through the multimedia and the three simulations near the end, write down answers for as many of the following questions as you can. Towards the end of lab, I will present my lecture on this chapter. Discuss your answers with your TA before you leave (it's OK to ask about anything you don't quite understand from the multimedia), and include them as part of your homework for this assignment:

1. Why is the computer architecture the von Neumann helped design called a stored program machine?
2. What's the difference between the accumulator and a numbered register?
3. What does the Instruction Register store? What instructions manipulate the content of this register?
4. What does the Branching Program in the multimedia do?
5. What are three Boolean gates? What is the relationship between Boolean gates and truth tables?
6. What are the inputs and outputs of a 1-bit adder? Give an example or two of a 1-bit adder behavior, from inputs to outputs.
7. How many columns and rows are there in the truth table for a 1-bit adder? Why?
8. When mapping a truth table into a circuit (such as for the 1-bit adder), how do we use NOT gates?

When you are done with computer architecture, you should try to start the multimedia for functions, with Start>Run umcpp, then select Functions. Try to go through the first three sections (flow of control, variables and scope, and return values). Finish by studying the getDigit.cc program in LOOKOUT, as directed by the multimedia. Next week, you'll complete the multimedia for this chapter. See the questions on functions below.

Laboratory work for Tuesday 10/28 and Thursday 10/30:
Start the multimedia with Start>Run ucSetup, which will install an OS simulation program (written in Java), which the multimedia will explain, then launch the multimedia for The Univesal Computer. This week you will study Operating Systems. (Towards the end of the multimedia, it asks you to press a button to run a simulation. If it doesn't start, this works: Start>Run H:\ucomp\ossimu.) As you go through the multimedia and the three simulations near the end, write down answers for as many of the following questions as you can. Discuss your answers with your TA before you leave (it's OK to ask about anything you don't quite understand from the multimedia), and include them as part of your homework for this assignment:

1. What is the purpose of virtual memory? If a program tries to access an address that is not in main memory, what happens?
2. What's the difference between a queue and a priority queue? Why might a batch OS use a priority queue to organize jobs?
3. What is ROM? What is the role of ROM when booting a computer?
4. What is an interrupt? Which part of an OS responds first to an interrupt?
5. What is a process? What can happen if two processes compete for the same resources?
6. Describe a couple of configurations (numbers of philosophers, how many eat, release/no release of forks) that lead to a deadlock and explain why. What aspect of the configuration appears to be most likely to cause a deadlock. How is the dining philosophers problem analogous to how an OS allocates resources?
7.What are threads? What's the pros and cons of thread scheduling with preemption, compared with "without preemption"?
8. Suppose two jobs arrive at a spooler, job 1 first and later job 2. If job 2 has a higher priority, will it interrupt job 1 and finish first? Why or why not? What if both jobs arrive at the same time--which job will finish first?

When you are done with operating systems, you should complete the multimedia for functions, with Start>Run umcpp, then select Functions. Go through the remaining sections, trying out programs in LOOKOUT. As you go through this multimedia, answer the following questions. Discuss your answers with your TA before you leave (it's OK to ask about anything you don't quite understand from the multimedia), and include them as part of your homework for this assignment:

1. By default, at what point does a callee function return control to its caller?
2. What is mean by the scope of variables? Make a couple of observations about when C++ code can and cannot refer to a variable declared in another block.
3. What's wrong with the following function? (Actually, a compiler should point out a couple of problems.)
int getNum()
{ int num; cin >> num; if (num >= 0 && num <= 9) return "num"; }

4. What's the difference between a formal parameter and an actual parameter?
5. How does C++ distinguish between pass by value and pass by reference? How do they work differently?
6. What is a stub function? How does it facilitate program development?
7 . What does assert(year.length() == 4) do? What happens if this assertion fails? Why include it in a function?
8. What's the difference between a function definition and a function prototype, in form and in purpose?

Homework exercises:
In addition to the above questions from your lab work, do the following exercises in The Universal Computer: 5.1, 5.14, 5.25, 5.39, 5.47, 5.49, 5.53, 5.71, 6.1, 6.10, 6.11, 6.14, 6.28, and 6.34. Do the following exercises from A Multimedia Introduction to C++: 14.9 (implement a program that tests your function), 14.12, 14.13, 14.15, and 14.31. (You may work on 14.31 with your partner, using pair programming practices, and putting both names on the completed program.)

Part of this assignment will also be to continue the Game of Life project. First, create a UML class diagram with at least two classes. (Hints: a principle of object-oriented software engineering is to separate the problem domain and user interface with different classes. You may draw the class diagram with a text file or you may use the Plastic 1.1 Class Diagram software available via Install Programs on the campus LAN. Tian Lin will explain Plastic in lab next week.)
Secondly, implement two functions which may be useful for the project. One function will embody the core logic which you implemented for the previous assignment, representing the nine cells are non-local variables; the testing loop with be in a separate main() driver function calling your new core logic function.
A second function, given the current seed, will randomly decide whether a cell will be initially living or dead. Initially the seed should be zero, in which case the function should come up with an interesting way to initialize the seed--I'll let you decide what's "interesting", so long as it isn't obviously predictable each time one starts the pseudo-random sequence. You may use the Randomizer class supplied with LOOKOUT to do most of the work of pseudo-randomizaiton for you.
Continue to work with your partner on the Game of Life part of the assignment (but not the rest of the assignment, except exercise 14.31).

Extra credit: 5.72, 6.30 and/or 6.40.

Due: Monday, 11/3, anytime before midnight.

Hand in: When you're ready to submit your assignment, combine the answers to all the exercises into one text file. Then, attach your file to assignment #6 (where you got this assignment) in Blackboard.

Prof. Blank