Operating Systems lab Programs Algorithm - Fourth Semester - Engineering
1. PRIORITY SCHEDULING
AIM
To develop a scheduling algorithm for the processor to process on the basis of priority as
priority scheduling.
ALGORITHM
1. Start the program.
2. Read the number of processes,burst time and CPU time.
3. Initialize large=1 and small=i.
4. Initialize max=min=a[i] and index i is equal to 2 to n.
5. Calculate total time,wait time,average wait time.
6. Calculate the turn around time and the average turn around time.
7. Display the gannt chart.
8. Stop the program.
ROUND ROBIN SCHEDULING
AIM
To write a c program for performing round robin scheduling.
ALGORITHM
1. Start the program.
2. Read the no. of process,burst time and quantum time.
3. Arrange all the processes on the basis of their quantum time such that a process is
made to repeat once again till the entire process is completed.
4. All the processes are arranged in a similar manner.
5. Prepare a gannt chart and display it.
6. Calculate the total execution time,average waiting time and average turn around
time.
7. Stop the program.
2. BARBER SHOP PROBLEM
AIM:
To write a c program to solve the barber shop problem.
ALGORITHM:
1. get the number of customers who came to barber shop.
2. allocate the customers to the available seats when there are more number of customers
than that of available seats,then make the remaining customers stay in the waiting list.
3. the barbers has to choose to which customers he has to serve.
4. when corresponding customers is choosen the following questions are asked whether he
wants to cut the hair,shaving or trimming.the customers wish is received.
5. the amount for corresponding job is noted.
6. the next customer occupies his seat and questions are coded to the customer when
previous customer leaves the shop.
7. then again the barber chooses the customer and does the his job. Then the customer
leaves the shop after paying barber.
8. the job is completed only when the barber completed only when the barber completes his
work for all the customers
9. atlast when all the customers have gone the profit of the day is calculated.
10. get the number of customers who came to barber shop.
11. allocate the customers to the available seats when there are more number of customers
than that of available seats,then make the remaining customers stay in the waiting list.
12. the barbers has to choose to which customers he has to serve.
13. when corresponding customers is choosen the following questions are asked whether he
wants to cut the hair,shaving or trimming.the customers wish is received.
14. the amount for corresponding job is noted.
15. the next customer occupies his seat and questions are coded to the customer when
previous customer leaves the shop.
3. DINING PHILOSOPHER’S PROBLEM
AIM
To develop a c program for performing dining philosophers problem.
ALGORITHM
1. Start the program.
2. Get the no of philosophers.
3. Using switch case get the choice for what action to be performed.
4. Then enter which philosopher is going to eat.
5. The status of the philosophers will be displayed.
6. If the philosopher has to wait then the message the chopsticks are engaged will be
displayed.
7. Enter the choice to exit the menu.
8. Stop the program.
BANKER’S ALGORITHM
AIM:
To develop a program to solve the banker’s algorithm to overcome deadlock situation.
ALGORITHM:
1. Start.
2. Input the maximum value and available resources value.
3. For i=1 to n do
4. Check if request I is less than or equal to i. If so proceed step 5.
5. Check if request is available.
6. Compare available as available request and complete allocation as allocation request.
7. Compare need[i] as need[i],request[i].
8. Repeat step 3 until the process get their need as 0.
9. Output the allocated resource values.
10. End.
FIRST IN FIRST OUT PAGE REPLACEMENT ALGORITHM
AIM:
To develop a page replacement algorithm on the basis of first in first out.
ALGORITHM:
1. Initialize the size of the frame size three.
4. 2. Initialize the number of pages which arrives in the queue as 12.
3. Initialize the page numbers.
4. Initially, the contents of the frame are set as -1.
5. As the frame arrives, it is initially placed in the frame.
6. Page fault is calculated when the particular page is not in the frame.
7. The first page which arrives in the frame is the one, which is to be replaced
8. Increment the page fault value.
9. Display the contents of the frame and the page fault value.
10. End the processing.
LEAST RECENTLY USED PAGE REPLACMENT ALGORITHM
AIM:
To develop a page replacement algorithm on the basis of least recently used.
ALGORITHM:
1. Initialize the size of the frame size three.
2. Initialize the number of pages which arrives in the queue as 12.
3. Initialize the page numbers.
4. Initially, the contents of the frame are set as -1.
5. As the page arrives, it is initially placed in the frame.
6. Page fault is calculated when the particular page is not in the frame.
7. The page which is not used frequently, is to be replaced.
8. Increment the page fault value.
9. Display the contents of the frame and the page fault value.
10. End the processing.