CSE 430  Operating Systems Fall 2018
Assignment: #1
Due dates:
Part 1: Feb 8th
Part 2: Feb 20th
(Not all questions will be graded)
Submit hard copy, in class

Note: You may choose to do this HW in groups of 2 or do it individually. Your choice, but if done in a group submit only 1 copy with two names.

Part 1: Due Feb 8th

1.      What are the differences between a trap (aka software interrupt) and an interrupt (hardware interrupt)? What is the use of each function? (Note: trap is a software interrupt)

2.      What is kernel mode (same as privileged mode)? Which of the following instructions should be privileged?

a.       Change to user mode.

b.      Write into monitor memory.

c.       Turn off interrupt

d.      Switch from user to monitor mode

3.      What is the purpose of system calls? How are they implemented?

For the questions below that involve Gantt charts, you can draw them approximately specially for round robin that is for RR you do not have to show every context switch.

4.      Consider the following set of processes, with only 1 CPU burst. The length of the CPU-burst time given in some unit t:

  

Process

Burst Time (t)

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 = 1t) scheduling.

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

5.      The following processes have 4 CPU burst and 3 I/O bursts each. They are all of the same priority and they arrive in the order P1, P2, P3 at time 0.

  

CPU

I/O

CPU

 

CPU

I/O

CPU

P1

10

10

10

10

10

10

10

P2

5

5

5

5

5

5

5

P3

5

10

5

10

5

10

5

 

a.     Draw three Gantt charts illustrating the execution of these processes using FCFS, SJF, and RR (quantum = 1t) scheduling.

 

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



 

 

Part 2: Due Feb 20

 

1.     Suppose a system has an atomic hardware instruction SHIFT, that does the follows:

SHIFT ( int *A, *B ) {
*B =*A; // ATOMICALLY
 *A = 0
}

 

A.    Implement Dijkstra style semaphores with the shift instruction, that is, semaphores which utilize busy waiting.

B.     Implement blocking semaphores using the shift instructions.

2.     // same as a sample exam question There are 4 processes, executing concurrently. Process P0 is in an infinite loop, incrementing the value of the variable x (x is initialized to 0). P0 is the only process that changes the value of x.
The rest of the processes Pi (1<= i <=3) monitor the value of x. Whenever x reaches a value such that it is divisible by i, Pi prints the value of x. For example, P3 will print the sequence 3 6 9 12 .. as the value of x reaches 3, 6, 9, 12 and so on.

Write the code for all the 4 processes using semaphores. Note that P1 - P3 should be identical; also Pi determines whether x is to be printed, and this decision is not made by P0.

Notes:

Any questions please post to discussion board. Also you may contact graders for personal attention.