Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5,...

12
Homework Assignment #1 J. H. Wang Oct. 13, 2010

Transcript of Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5,...

Page 1: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

Homework Assignment #1

J. H. WangOct. 13, 2010

Page 2: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

Homework #1

• Chap.1: 1.24• Chap.2: 2.13• Chap.3: 3.5, 3.13* (or 3.14*)• Chap.4: 4.6, 4.12*

– (*: optional programming exercises)– (Optional: End-of-chapter project for

Chap.3 & 4)

• Due: two weeks (Oct. 27, 2010)

Page 3: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

• Chap.1– 1.24: What is the purpose of interrupts?

What are the differences between a trap and an interrupt? Can traps be generated intentionally by a user program? If so, for what purpose?

Page 4: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

• Chap. 2– 2.13: What is the main advantage of the

microkernel approach to system design? How do user program and system services interact in a microkernel architecture? What are the disadvantages of using the microkernel approach?

Page 5: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

• Chap. 3– 3.5: Describe the actions taken by a

kernel to context-switch between processes.

Page 6: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

– *3.13: The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, … . Formally, it can be expressed as:fib0=0fib1=1fibn=fibn-1+fibn-2Write a C program using the fork() system call that generates the Fibonacci sequence in the child process. The number of the sequence will be provided in the command line. For example, if 5 is provided, the first five numbers in the Fibonacci sequence will be output by the child process. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a non-negative number is passed on the command line.

Page 7: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

– (3.14*): Repeat the exercise in 3.13, this time using the CreateProcess() in the Win32 API. In this instance, you will need to specify a separate program to be invoked from CreateProcess(). It is this separate program that will run as a child process outputting the Fibonacci sequence. Perform necessary error checking to ensure that a non-negative number is passed on the command line.

Page 8: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

• Chap. 4– 4.6: What are the differences between

user-level threads and kernel-level threads? Under what circumstances is one type better than the other?

Page 9: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

– *4.12: The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, … . Formally, it can be expressed as:fib0=0fib1=1fibn=fibn-1+fibn-2Write a multithreaded program that generates the Fibonacci sequence using either the Java, Pthread, or Win32 thread library.

This program should work as follows: The user will enter on the command line the number of Fibonacci numbers that the program is to generate. The program will then create a separate thread that will generate the Fibonacci numbers, placing the sequence in data that can be shared by the threads (an array is probably the most convenient data structure). When the thread finishes execution, the parent thread will output the sequence generated by the child thread. Because the parent cannot begin outputting until the child finishes, this will require having the parent wait for the child thread to finish.

Page 10: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

Homework Submission

• For hand-written exercises, please hand in your homework in A4 papers in class

• For programming exercises, please turn in your program code with compilation instructions via program submission site as follows:– URL: http://140.124.183.39/os/ – User account/Password: your student ID

• Please change your password as soon as possible– Program uploading: including source codes and

a compilation instruction if your program needs special environment or tool to compile or run

• Please clearly name your program files using your ID

Page 11: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

More on Optional End-of-Chapter Projects

• Programming Project for Chap. 3: POSIX Message Passing– The message passing system– Creating the processes

• Programming Project for Chap. 4: – 1. Naming service project

• Server and client

– 2. Matrix multiplication project• Passing parameters to each thread• Waiting for threads to complete

Page 12: Homework Assignment #1 J. H. Wang Oct. 13, 2010. Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.

Thanks for Your Attention!