0% found this document useful (0 votes)
43 views5 pages

CSC3300 - Lab04

This document describes a lab assignment for a computer science course involving implementing scheduling algorithms in Java programs. Students will create programs that use the First-Come, First-Served (FCFS) and Round-Robin (RR) scheduling algorithms to calculate waiting times and turnaround times for sample processes. They will output their results in tables and submit their source code along with screenshots of program outputs. Optional extensions are suggested to improve the programs.

Uploaded by

214391
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views5 pages

CSC3300 - Lab04

This document describes a lab assignment for a computer science course involving implementing scheduling algorithms in Java programs. Students will create programs that use the First-Come, First-Served (FCFS) and Round-Robin (RR) scheduling algorithms to calculate waiting times and turnaround times for sample processes. They will output their results in tables and submit their source code along with screenshots of program outputs. Optional extensions are suggested to improve the programs.

Uploaded by

214391
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSC3300 Sem.

1 2023/2024

UNIVERSITI PUTRA MALAYSIA


FAKULTI SAINS KOMPUTER DAN TEKNOLOGI MAKLUMAT

LAB 4

ASSIGNMENT TITLE : Implementing Scheduling Algorithm

ASSIGNMENT TYPE : Individual

OBJECTIVE:
The main objective of this lab is to help student to understand the scheduling algorithms
used in operating system, by implementing and running the algorithm using computer
program.

DURATION:
2 weeks / 6 hours

DUE DATE OF SUBMISSION: (refer in PutraBlast)


Submit your assignment to putraBlast.

PROGRAMME OBJECTIVE (PO):


PO2: Coding algorithms used in operating system

RUBRIC:
LEVEL 1 LEVEL 2 LEVEL 3 LEVEL 4 LEVEL 5
CRITERIA
Very Poor Poor Good Very Good Excellent
The ability to Unable to Able to perform Able to perform Able to perform Able to perform
perform perform programming programming programming programming
programming programming task with task with some task with task with
task task with very limited success success (≥ 60%, considerable outstanding
limited success (≥ 40%,< 60%). < 80%). success (≥ 80%, success (100%).
(< 40%). < 100%).

1
CSC3300 Sem. 1 2023/2024

INSTRUCTIONS:

1. Scheduling Algorithms 1 – First-Come-First-Serve (FCFS)

You are given a scheduling problem in Table 1 below, which involved 5 processes with
the given arrival time and burst time:

Table 1
Process Arrival Time Burst Time
Process A 0 6
Process B 2 4
Process C 5 1
Process D 6 3
Process E 9 5

Implement a Java program to calculate the waiting time and turnaround time for each
process involved using First-Come-First-Serve (FCFS) algorithm, and fill up the Table
2. Then calculate the average waiting time produced by FCFS scheduling algorithm.

Table 2 – Result by FCFS algorithm


Process Waiting Time Turnaround
Time
Process A
Process B
Process C
Process D
Process E

Avg Waiting Time =_________________________

2
CSC3300 Sem. 1 2023/2024

2. Scheduling Algorithms 2 – Round-Robin (RR)

Implement a Java program to calculate the waiting time and turnaround time involving
N processes using Round-Robin scheduling algorithm. The user should be allowed to
enter the following information:
• N, or the total of processes involved (N should be between 4 to 10 inclusive)
• Burst time for each process
• The quantum time to be used by the RR algorithm.
Arrival time is not needed as it is assumed all processes arrived at the same time (t=0).
Using the information provided, calculate
• Waiting times for all the processes
• Turnaround times for all the processes
• The average waiting time produced by the RR algorithm for the given
situation/problem.
Complete Table 3 and Table 4 below with the input and result of the program.

Table 3 User input


No. of Processes = _______________
Time Quantum = ________________
Process Burst Time

Table 4 – Result of RR algorithm


Process Waiting Time Turnaround
Time

Avg Waiting Time =_________________________

3
CSC3300 Sem. 1 2023/2024

An example output of the required program could be as follows:

N: 4
Burst time: 7 4 1 4
Q: 3
Process Exec. slices (t) Waiting Turnaround
A 0, 10, 15 9 16
B 3, 13 10 14
C 6 6 7
D 7, 14 11 15

Avg. waiting time for 4 processes = 9

You may use the algorithm listed in Figure 2 below as reference. (There might be other
possible solution.)

1- set CPU as idle


2- until all process completed (completion counter = no. of processes)
3- if any process arrived
4- add into queue
5- if CPU is busy
6- deplete CPU timer
7- if (timeout)
8- set CPU as idle
9- takeout process from CPU
10- if process still have remaining time
11- put at the back of queue
12- else
13- 1 process completed, update completion counter
14- end if
15- end if
16- end if
17- if CPU is idle
18- take process from queue
19- run in CPU
20- reset CPU timer
21- end if
22- increase clock tick
23- repeat
Figure 2

Screen-capture the output after you run/execute the programs from Question 1 and
Question 2 and submit with your source code.

4
CSC3300 Sem. 1 2023/2024

Suggestion on further improvement / extension (optional)

You may improve further the programs from this lab assignment by varying the problems,
attributes and output as follows:

• allow user to enter different arrival times for the RR algorithm.


• display the Gantt chart for each of the scheduling algorithms using ASCII
characters (each character represent 1 time unit) e.g.
N: 4
Burst time: 7 4 1 4
Q: 3
Process Exec. slices (t) Waiting Turnaround
A 0, 10, 15 9 16
B 3, 13 10 14
C 6 6 7
D 7, 14 11 15

Gantt chart (1 char = 1 microsecond):


AAABBBCDDDAAABDAAA

Avg. waiting time for 4 processes = 9

or using graphical display with Swing/JavaFX.

• add priority value for each of the processes involved and perform scheduling based
on priority
• create a simulation program which able to generate processes (generate random
arrival times and burst times to represent a process) and perform several repetitions
of scheduling, then calculate the related statistics (avg waiting time, average
turnaround time, etc).

You may also implement other general scheduling algorithms such as Shortest-Job-First
algorithm (non-preemptive and preemptive), scheduling with multiple queues and aging,
etc. which are not covered in this assignment.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy