Reference Document: OS Assignment1.pdf

Q1

Newly Added States

The two newly added suspend states allow to swap out idle processes from main memory to disk in-order to free up memory.

Suspend Ready

The process in Suspend Ready State is suspended and not present in the memory but is eligible to be executed once it is put into the Ready State or loaded into the memory.

Suspend Blocked

The process in Suspend Blocked State is suspended, not present in the memory and also not available to be executed as it is waiting for some event or resource to become available.

Transitions

The Medium Term Scheduler or Swapper is responsible for swapping processes in and out of the memory.

Blocked Suspend Blocked

If the operating system requires more than available memory to dispatch a new process or if there are simply no ready processes then space needs to be created for a new ready process in the main memory. For this purpose, processes in blocked state which are idle and waiting for an event to occur are transitioned to Suspend Blocked state to free up the memory.

Suspend Blocked Suspend Ready

If the event for a process which is suspended and waiting for it to occur in the Suspend Blocked State occurs, then it’s state is transitioned to Suspend Ready state.

Suspend Ready Ready

If there are no more ready processes in the main memory or if the new processes to bring into the ready queue have lower priority than the suspended processes in suspend ready queue then these suspended processes are brought into the ready queue instead.

Ready Suspend Ready

The operating system prefers to suspend a blocked process instead of a ready process as blocked process cannot be executed while a ready process can be, but if a sufficiently large memory is required then the processes in ready state are transitioned to suspend ready state in-order to free up the memory.

Priority

After swapping out, the processes are put into the Suspend Ready Queue or the Suspend Blocked Queue. The OS can use different policies to manage each queue (FIFO, Round Robin, Priority, etc.). Based on these policies, the OS prioritises one process above others to be swapped back into the ready queue or the blocked queue.

Q2

Process Tree

Q3

Process IDArrival TimeBurst TimePriority
P1262
P25123
P31184
P40135
P5432

Turn Around Time = Finish Time - Arrival Time

Waiting Time = Turn Around Time - Burst Time

SJF (Preemptive) / SRTF

gantt
    title SRTF Gantt Chart
    dateFormat X
    axisformat %M:%S
    section P1
        2/6: 2, 4
	6/6: 7, 11
    section P2
        12/12: 22, 34
    section P3
        18/18: 34, 52
    section P4
        2/13: 0, 2
	13/13: 11, 22
    section P5
        4/4: 4, 7
Process IDArrival TimeBurst TimePriorityFinish TimeTurn Around TimeWaiting Time
P4013522229
P31184525133
P12621193
P5432730
P25123342917

Average Waiting Time = 12.4

Priority

gantt
    title SRTF Gantt Chart
    dateFormat X
    axisformat %M:%S
    section P1
        6/6: 2, 8
    section P2
        12/12: 11, 23
    section P3
        1/18: 1, 2
	18/18: 23, 40
    section P4
        1/13: 0, 1
	13/13: 40, 52
    section P5
        3/3: 8, 11
Process IDArrival TimeBurst TimePriorityFinish TimeTurn Around TimeWaiting Time
P40135525239
P31184403921
P1262860
P54321174
P2512323186

Average Waiting Time = 14

Round Robin - PBT (Quantum = 5)

gantt
    title SRTF Gantt Chart
    dateFormat X
    axisformat %M:%S
    section P1
        5/6: 10, 15
	6/6: 33, 34
    section P2
        5/12: 18, 23
	10/12: 34, 39
	12/12: 47, 49
    section P3
        5/18: 5, 10
	10/18: 28, 33
	15/18: 42, 47
	18/18: 49, 52
    section P4
        5/13: 0, 5
	10/13: 23, 28
	13/13: 39, 42
    section P5
        3/3: 15, 18
Process IDArrival TimeBurst TimePriorityFinish TimeTurn Around TimeWaiting Time
P40135424229
P31184525133
P1262343226
P5432181411
P25123494432

Average Waiting Time = 26.2