Homework 2: Threads, Scheduling

1. (10pts) Threads: What is the difference between a process and a thread. Which one consumes more resources?

2. (5pts) Threads: Assume that the OS implements Many-to-Many multithreading model. What is the minimum number of kernel threads required to achieve better concurrency than in the Many-to-One model? Why?

3. (10pts) Threads: What is the relation between Solaris user threads and Java application threads in a Solaris environment?

4. (20pts) Java Threads:

Develop an execution driven simulator for a multiprocessor that solves a 3x3 matrix multiply (i.e., AxB=C, where A,B,C are 3x3 matrixes) following these steps:

- define A, B, C as instance variables using a suitable data-structure
- set the values in the constructor
- create a thread for every processor so that each processor will compute one element of the resulting matrix.
- in each thread calculate one element (i.e., multiply the elements of one raw from A and one column from B, and add the results to get the value of C[i.j]).
- the main thread should wait until all the other threads are done and then print the matrix C

5. (10pts) Scheduling: Given the following mix of job, job lengths, and arrival times, assume a time slice of 10 and compute the completion and average response time of each job for the FIFO, RR, and SRTF algorithms. Use the following format for the solution:

Parameters |
Scheduling Algorithms |
|||||

Job | length | arrival time | FIFO | RR | SRTF | |

0 | 75 | 0 | ||||

1 | 40 | 10 | ||||

2 | 25 | 10 | ||||

3 | 20 | 80 | ||||

4 | 45 | 85 | ||||

Avg. RT |