1 What are the three main purposes of an operating system?

Answer:

_ To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner.

_ To allocate the separate resources of the computer as needed to solve the problem

given. The allocation process should be as fair and efficient as possible.

_ As a control program it serves two major functions: (1) supervision of the execution of

user programs to prevent errors and improper use of the computer, and (2) management of the operation and control of I/O devices.

2 What is the main advantage of multiprogramming?

3 What are two differences between user-level threads and kernel-level threads? Underwhat

circumstances is one type better than the other?

Answer: (1) User-level threads are unknown by the kernel, whereas the kernel is aware

of kernel threads. (2) User threads are scheduled by the thread library and the kernel

schedules kernel threads. (3) Kernel threads need not be associated with a process whereas every user thread belongs to a process.

4 What resources are used when a thread is created? How do they differ from those used when a process is created?

Answer: Because a thread is smaller than a process, thread creation typically uses fewer

resources than process creation. Creating a process requires allocating a process control

block (PCB), a rather large data structure. The PCB includes a memory map, list of open

files, and environment variables. Allocating and managing the memory map is typically

the most time-consuming activity. Creating either a user or kernel thread involves allocating

a small data structure to hold a register set, stack, and priority.

6.1 A CPU scheduling algorithm determines an order for the execution of its scheduled processes.

Given n processes to be scheduled on one processor, how many possible different

schedules are there? Give a formula in terms of n.

Answer: n! (n factorial = n * _ n – 1* _ n – 2* _ ... _ 2*1)

6.3 Consider the following set of processes, with the length of the CPU-burst time given in

milliseconds:

Process Burst Time Priority

P1 10 3

P2 1 1

P3 2 3

P4 1 4

P5 5 2

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.

a. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a

nonpreemptive priority (a smaller priority number implies a higher priority), and RR

(quantum = 1) scheduling.

b. What is the turnaround time of each process for each of the scheduling algorithms in part a?

c. What is the waiting time of each process for each of the scheduling algorithms in part a?

d. Which of the schedules in part a results in the minimal average waiting time (over all processes)?

Answer:

a. The four Gantt charts are

b. Turnaround time

FCFS RR SJF Priority

P1 10 19 19 16

P2 11 2 1 1

P3 13 7 4 18

P4 14 4 2 19

P5 19 14 9 6

c. Waiting time (turnaround time minus burst time)

d. Shortest Job First