Questions (10 points total)
1. Describe the actions taken by a kernel to context-switch between processes. (1 point)
2. Which of the following components of program state are shared across threads in a
multithreaded process? Also explain the implications of such state sharing to the efficiency of
creating a thread. (1 point)
a. Register values
b. Heap memory
c. Global variables
d. Stack memory
3. Consider the exponential average formula used to predict the length of the next CPU burst.
What are the implications of assigning the following values to the parameters used by the
algorithm? (1 point)
4. What resources are used when a thread is created? How do they differ from those used when a
process is created? (1 point)
5. Suppose that the following processes arrive for execution at the times indicated. Each process
will run for the amount of time listed. In answering the questions, use non-preemptive
scheduling, and base all decisions on the information you have at the time the decision must be
made. (3 points)
Process Arrival Time Burst Time
P1 0.0 8
P2 0.4 4
P3 1.0 1
a. What is the average turnaround time for the FCFS scheduling algorithm?
b. What is the average turnaround time for the SJF scheduling algorithm?
Homework Assignment 2
CSC 4103 Operating System, Spring 2017
NOTE: Submit your answers (typed in hard copy) by February 24th (Thursday) during the class
time. Answer all questions completely and concisely. Late submissions will be penalized at the
rate of 10% per day late and no more than 3 days late.
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run
process P1 at time 0 because we did not know that two shorter processes would arrive
soon. Compute what the average turnaround time will be if the CPU is left idle for the
first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are
waiting during this idle time, so their waiting time may increase. This algorithm could be
known as future-knowledge scheduling.
6. What is the meaning of the term busy waiting? What other kinds of waiting are there in an
operating system? Explain why spinlocks are not appropriate for single-processor systems but
are often used in multiprocessor systems. (1 point)
7. Consider the following snapshot of a system:
Answer the following questions using the banker’s algorithm: (2 points)
a. What is the content of the matrix Need?
b. Is the system in a safe state?
c. If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately?