/implement-cpu-scheduling-java

Programming the CPU Scheduling of the Curriculum and Operating System of Hongik University's 3rd Grade

Primary LanguageJava

implement-cpu-scheduling-java

๐Ÿ–ฅ๏ธ ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ (Project Introduction)

  • CPU Scheduling of Operating System

๐Ÿ•ฐ๏ธ ๊ฐœ๋ฐœ ๊ธฐ๊ฐ„ (Development period)

  • 23.05.06์ผ - 23.05.13์ผ
  • 23.05.17์ผ - 23.05.21์ผ
  • 23.06.19์ผ - 23.06.21์ผ [FIX & Latest Upload]

โš™๏ธ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ (Development environment)

๐Ÿ“Œ CPU Scheduling

FCFS

  • ์ž‘์—…์ด ๋„์ฐฉํ•œ ์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌ๋˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘.
  • ๋จผ์ € ๋„์ฐฉํ•œ ์ž‘์—…์ด ๋จผ์ € ์‹คํ–‰๋˜๊ณ , ์ž‘์—…์ด ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๋‹ค๋ฅธ ์ž‘์—…์€ ๋Œ€๊ธฐ. [ํ˜ธ์œ„ํšจ๊ณผ - Convoy effect]

SJF

  • ๋„์ฐฉํ•œ ์ˆœ์„œ์™€ ์ƒ๊ด€์—†์ด ์‹คํ–‰ ์‹œ๊ฐ„์ด ๊ฐ€์žฅ ์งง์€ ์ž‘์—…์ด ๋จผ์ € ์‹คํ–‰๋˜๋Š” ํŠน์ง•.
  • ํ‰๊ท  ๋Œ€๊ธฐ ์‹œ๊ฐ„์„ ์ตœ์†Œํ™”ํ•  ์ˆ˜ ์žˆ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜
  • ์šฐ์„ ์ˆœ์œ„ ํ๋กœ ๊ตฌํ˜„

RoundRobin

  • ๊ฐ ์ž‘์—…์— ๋™์ผํ•œ ์‹œ๊ฐ„ ํ• ๋‹น๋Ÿ‰์„ ๋ถ€์—ฌ (Quantum)
  • ํ• ๋‹น๋œ ์‹œ๊ฐ„ ๋™์•ˆ ์ž‘์—…์„ ์‹คํ–‰ํ•œ ํ›„ ๋‹ค์Œ ์ž‘์—…์œผ๋กœ ์ „ํ™˜ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘

What's important about scheduling

  • (Process 1)์˜ CPU Burst๊ฐ€ ์‹คํ–‰ํ•œ ๋’ค I/O๊ฐ€ ์ง„ํ–‰๋œ๋‹ค๋ฉด (Process 1)์ด์™ธ์˜ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค์—๊ฒŒ CPU๋ฅผ ํ• ๋‹นํ•˜์—ฌ ์Šค์ผ€์ค„๋งํ•˜๋Š” ๋ฐฉ์‹

๐Ÿ‘ฝ How to execute it?

  1. Open the terminal
  2. git clone https://github.com/WellshCorgi/implement-cpu-scheduling-java.git
  3. cd implement-cpu-scheduling-java/src
  4. javac Main.java
  5. [Let's run the Java file]
    • java Main data.txt FCFS 0
    • java Main data.txt SJF 0
    • java Main data.txt RoundRobin 1
    • java Main data.txt RoundRobin 10
    • java Main data.txt RoundRobin 100

About Each Process Control Block

  • n (A,C,B,IO)
  • n is count of processes
  • The time when the process arrived is A
  • Let C be the total CPU time required until the process ends.
  • Turnaround Time(Finishing Time - @param A)
  • CPU burst time is the unique distributed random integer between 0 and any number B.
  • IO burst time is the unique distributed random integer between 0 and any number IO.

Test Cases

  1. 1 (0 5 1 1)

  2. 3 (0 5 1 1)(0 5 1 1)(3 5 1 1)

  3. 5 (0 200 3 3)(0 500 9 3)(0 500 20 3)(100 100 1 0)(100 500 100 3)

Output about Test Cases

  • Case 1 [์–ด๋–ค ์ถœ๋ ฅ์ด๋“  ๊ณ ์ •๋œ ๊ฐ’]
============= [ Summary of Scheduler ] =============
Scheduler Finishing Time : 9
Average turnaround time : 9.00
Average waiting time : 0.00
CPU Utilization : 55.56 %
I/O Utilization : 44.44 %
Throughput in processes completed per hundred time units : 11.11 %
  • Case 2 [์–ด๋–ค ์ถœ๋ ฅ์ด๋“  ๊ณ ์ •๋œ ๊ฐ’]
============= [ Summary of Scheduler ] =============
Scheduler Finishing Time : 15
Average turnaround time : 12.67
Average waiting time : 3.67
CPU Utilization : 100.00 %
I/O Utilization : 80.00 %
Throughput in processes completed per hundred time units : 20.00 %
  • Other Case
Cpu Burst , Io Burst๊ฐ€ Random๊ฐ’์œผ๋กœ ์˜ค์ฐจ๋ฒ”์œ„์˜ ๊ฐ’ ์ด๋‚ด์˜ ๊ฒฐ๊ณผ ์ถœ๋ ฅ

FIXED LOG

  • 5/22 -> Fixed SJF, RoundRobin Improved the way logic works.
  • 6/21 -> I got feedback from the professor in charge and redesigned all the working methods.

โ˜…What needs to be improved in this project

  • ์ž๋ฐ” ๋””์ž์ธ ํŒจํ„ด (SRP,DIP)๋ฅผ ์ ์šฉํ•˜๊ธฐ ๋ฐ OCP ๊ทœ์น™ ์œ„๋ฐ˜ ์ˆ˜์ •ํ•˜๊ธฐ. [Applying Java design patterns and implementing SRP, correcting OCP rule violations]