Skip to content

thomaslwk/OS_Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

ICT1007: Operating Systems Assignment

Documentation for OS module assignment.

Task 1: Improved Round Robin CPU Scheduling Algorithm

Paper (5): Round Robin, Shortest Job First and Priority algorithm coupled to increase throughput and decrease waiting time and turnaround time.

Algorithm input

Input Requirement:

  • Number of process
  • Time quantum
  • Burst time for each process
  • Arrival time for process
  • Priority level for process (value 1 to 3)

Format: no. of process, time quantum, burst time, arrival time, priority

Replication of Results

  • Test Case (1): ./p5_testinput < input_test_1.txt

test1

  • Test Case (2): ./p5_testinput < input_test_2.txt

test2

Task 2: Race Condition Simulation with Process

C program to illustrate Race condition. Requires minimal use of 5 processes and 3 resources.

Design and Analysis

design1

The program will first create a shared semaphore which will be used by all the processes when it begins the process of reading and writing to file. It will create 3 text files for the processes to write to. The program will create 6 processes in total, 5 child processes and 1 parent process.

design2

The diagram above shows the interaction between the different processes and files. The lock icon is used to simulate the presence of the shared binary semaphore which provides mutual exclusion to the 3 files (jar1, jar2, jar3).

Results

Mitigated Race Condition - Using Semaphores

race1

Section screenshots of program output with use of semaphore. We can observe that the 5 processes (bear) are executed at random but only one process (bear PID) has access to the file (jar1, jar2, jar3) each time. This results in each process incrementing the existing value by 5. With 5 processes, the final value in each file will be consistent and will always be 5.

Forced Race Condition - Without Semaphore

race2

Section screenshots of program output without the use of semaphore. We can observe that the 5 processes (bear) are executed at the same time and all the processes (bear PID) are reading and writing to the same file (jar1, jar2, jar3) at the same time. The write to file method should allow each process to increment the file by 5. However, from the results we can observe that each jar contains a different value and the result is inconsistent due to the race condition.

About

Operating System module assignment documentation

Topics

Resources

Stars

Watchers

Forks

Languages