CPSC 100, Fall 1995, Quiz #7

This is Quiz #7 from CPSC 100: Principles of Computer Science, Fall 1995. The answers given would receive full credit, but in many cases, there are variations or even completely different answers that would also receive full credit. The "Notes" are meant to clarify the answer or to provide some interesting extra information.

Question 1: Draw the picture that would be produced by the following xTurtle program:

              turn( 45 * (ForkNumber - 1) )


Note: There are five turtles. The turn statement then makes them fan out so that turtle 1 is facing 0 degrees, turtle 2 is facing 45 degrees, ..., and turtle 5 is facing 180 degrees. Then each turtle draws a "T" shaped figure.

Question 2: In xTurtle, the grab command is used to control access to shared data. Explain what this means and why it is necessary.

Answer: If a variable is declared before a fork statement, then all the turtles created by the fork will have access to the same location in memory. At some point in the program, it might be necessary to give one turtle exclusive access to that memory location. For example, if a turtle gets the value from that location, does a computation with it, and then stores the result back in memory, it is essential that no other turtle comes has come along and changed the value in memory while the first turtle was working. If all the turtles grab the variable before using it, then this problem will not occur since only one turtle at a time will have access to the variable.

Question 3: "Computers that have many CPU's and that use parallel processing can solve problems that can't be solved by ordinary computers." Is this true or false? Justify your answer.

Answer: This is false. An ordinary computer, with a single CPU, can use multitasking to simulate parallel processing and therefore can solve any problem that can be solved by a computer with multiple CPUs. Of course, it will take longer. (Multitasking means that the single CPU rapidly switches its attention from one process to another.)

Note: You can argue that a parallel processing computer could be so fast that it could solve problems that could not be solved by single-CPU computers in a reasonable amount of time. But that is a practical difference only, and not a difference in the problems that can (given enough time) be solved.

Question 4: What is the Internet ?

Answer: The Internet is a worldwide computer network consisting of thousands of smaller networks connected together (by routers, gateways, modems...). All the computers on this internet can communicate. The Internet provides a number of communication services to its users, including the World Wide Web, USENET news, and FTP file transfers.

Question 5: Explain what is meant by a protocol in the context of computer networks. Give an example of a protocol.

Answer: A protocol is a specification of a specific method of communication between computers on a network. For two computers to communicate, they must follow some mutually agreed protocol. An example is FTP, or File Transfer Protocol, which can be used to copy files from one computer to another.

Note: A protocol is a kind of black box, usually implemented by some subroutines. A process that wants to communicate simply calls the appropriate subroutines and all the details of communication will be handled inside the subroutine. For example, a process might call a subroutine named FTP_Send to send a file using FTP. The subroutine would probably send the file by calling on lower-level protocols such as TCP and IP, but the caller of the subroutine would not have to be aware of exactly how the file is being sent.

[by David Eck]