Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

LAMPIRAN 1

JABATAN TEKNOLOGI MAKLUMAT DAN KOMUNIKASI


POLITEKNIK UNGKU OMAR
SESI 1 2021/2022

KOD KURSUS : DFC10103


NAMA KURSUS : OPERATING SYSTEM
PENILAIAN : PROBLEM BASED EXERCISE 1

SEKSYEN KURSUS: DDT1A


NAMA PENSYARAH KURSUS: HAIZAM BINTI MOHAMAD
ARAHAN PENILAIAN: _______________________________

1. Tugasan dilaksanakan secara individu/berkumpulan.


2. Baca dengan teliti dan penuhi semua arahan yang dinyatakan dalam soalan yang diberi.
3. Tugasan ini akan dinilai berdasarkan rubrik / markah yang dilampirkan.

NO. PENDAFTARAN NAMA CLO MARKAH

MUHAMMAD ADAM BIN AZZIZI 1


01DDT21F1002
2 /100
3

Jumlah

Disediakan oleh: Disemak dan Disahkan oleh:


DFC 10103 – OPERATING SYSTEM

PROBLEM BASED EXERCISE 1

CLS: 3b - Interpersonal & Communication skill

PLO4: demonstrate effective communication both orally and in writing to others


including peers, experts and non-experts

Duration : 4 HOURS

QUESTION 1

Memory management strategies can be divided into: Fetch, Placement, and Replacement.
Meanwhile, placement strategy can be further divided into: Best-fit, First-fit and Worst-fit.

Instruction: Complete the table below with the correct placement type of Best-fit, First-fit or
Worst-fit.

Description Placement type


Allocate the first free memory space that is big enough. First-fit

This strategy produces the largest leftover spaces, which may be Worst-fit
more useful than the smaller leftover spaces from a best-fit approach.
Allocate the smallest free memory space that is big enough. Best-fit
This strategy searches the entire list, unless it is sorted by size. Best-fit
Searching can start either at the beginning of the set of free memory First-fit
spaces or at the location where the previous search ended.
The strategy can stop searching as soon as it finds a free memory First-fit
space that is large enough.
Allocate the largest free memory space. Worst-fit
This strategy produces the smallest leftover memory space. Best-fit
This strategy searches the entire list, unless the list is ordered by Best-fit
size.
Table 1

QUESTION 2
Schedulers are special system software which handle process scheduling in various ways.
Their main task is to select the jobs to be submitted into the system and to decide which
process to run. Schedulers are of three types; Long-Term Scheduler Short-Term Scheduler
and Medium-Term Scheduler.
a. Give the definition and explain differences between Long-Term Scheduler, Short-
Term Scheduler and Medium-Term Scheduler.

Long-Term Scheduler – Determine which programs admitted to system for


Processing.

Short-Term Scheduler – Executes most frequently, to decide which process


to execute next

Medium-Term Scheduler – Part of swapping function between main memory


and disk.

b. Differentiate between preemptive and non-preemptive technique in scheduling.


Preemptive Non-preemptive

Interrupts processing of a job and Functions without external interrupts


transfers the CPU to another job

The process may be pre-empted by the Once a process is executing, it will


continue to execute until it terminates
operating system when:
or:
-a new process arrives (perhaps at a
-it makes an I/O request which would
higher priority) block the process
-an interrupt or signal occurs
-it makes an operating system call.
-a (frequent) clock interrupt occurs

c. Draw the Round Robin scheduling algorithms by the following process given in table
2 and calculate the average waiting time when a quantum time = 20

Process Arrival Time Burst Time


P1 0 110
P2 2 85
P3 4 70
P4 5 43

Table 2: Round Robin

i. Draw the Gantt Chart.


P1 P2 P3 P4 P1 P2 P3 P4 P1 P2 P3 P4 P1 P2 P3 P1 P2 P1
0 20 40 60 80 100 120 140 160 180 200 220 223 243 263 273 293 298 308
ii. Calculate waiting time and average waiting time.
Waiting time
1. P1 = (308 – 0) – 110 = 198
2. P2 = (298 – 2) – 85 = 211
3. P3 = (273 – 4) – 70 = 199
4. P4 = (223 – 5) – 43 = 175

Average waiting time


(198+211+199+175)
4
=195.75

iii. Calculate the response time and average response time


Response time
1. P1 = 0
2. P2 = 20 – 2 = 18
3. P3 = 40 – 4 = 36
4. P4 = 60 – 5 = 55

Average response time


(0+18+36 +55)
= 27.25
4

d. Draw Shortest Remaining Time First scheduling algorithm.

Process Arrival Time Burst Time


P1 0 7
P2 2 4
P3 4 1
P4 5 4
Table 3: Shortest Remaining Time First

i. Draw the appropriate Gantt Chart.


P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
ii. Calculate waiting time and average waiting time
Waiting time
1. P1 = (16 – 0) – 7 = 9
2. P2 = (7 – 2) – 4 = 1
3. P3 = (5 – 4) – 1 = 0
4. P4 = (11 – 5) – 4 = 2

Average waiting time


(9+1+0 +2)
4
=3

iii. Calculate the response time


1. P1 = 0
2. P2 = 2 – 2 = 0
3. P3 = 4 – 4 = 0
4. P4 = 7 – 5 = 2
iv. Calculate turn-around time
1. P1 = 16 – 0 = 16
2. P2 = 7 – 2 = 5
3. P3 = 5 – 4 = 1
4. P4 = 11 – 5 = 6

QUESTION 3
Deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource acquired by some other process.

a. Describe four necessary conditions for deadlock and give the scenario example.

1) Mutual exclusion
One or more than one resource must be held by a process in a non-sharable
(exclusive) mode.

2) Hold and Wait


A process holds a resource while waiting for another resource.

3) No Preemption
There is only voluntary release of a resource.

4) Circular Wait
Process A waits for Process B waits for Process C .... waits for Process A.
Bridge Crossing example (Scenario example)
•Traffic only in one direction.
•Each section of a bridge can be viewed as a resource.
•If a deadlock occurs, it can be resolved if one car backs up (preempt resources and
rollback).
•Several cars may have to be backed up if a deadlock occurs.
•Starvation is possible

b. Explain three methods for handling deadlock.


1) Ignore Deadlocks

2) Ensure deadlock never occurs using either


Prevention - Prevent any one of the 4 conditions from happening.
Avoidance - Allow all deadlock conditions but calculate cycles about to happen and
stop dangerous operations.

3) Allow deadlock to happen. This requires using both:


Detection - Know a deadlock has occurred.
Recovery - Regain the resources.

You might also like