lab manual of operating system cs

Upload: aarfa-khan

Post on 14-Jul-2015

77 views

Category:

Documents


2 download

TRANSCRIPT

JAI NARAIN COLLAGE OF TECHNOLOGY (BHOPAL)LAB MANUAL OF OPERATING SYSTEM CS-502

List of experiments :1.Write a program to implement FCFS CPU Scheduling algorithm.

2.Write a program to implement FCFS CPU Scheduling algorithm with arrival time.

3.Write a program to implement SJF CPU Scheduling algorithm.

4.Write a program to implement Priority CPU Scheduling algorithm.

5.Write a program to implement Round Robin CPU Scheduling algorithm.

6.Write a program to implement Dining Philosophers Problem.

7.Write a program to implement Producer-Consumer problem Problem.

8.Write a program to implement & compare various Disk & Drum scheduling algorithms.

9. Write a program to implement & compare various page replacement algorithm.

10. Write a program to implement classical inter process communication problem.

Lecturer of CSE

HOD of CSE

(Ms Shivani Maheshwari)

(Prof. Bhupesh Gour)

PRACTICAL NO. 1

Aim :- Write a program to implement FCFS CPU Scheduling Algorithm.Theory:- A process is one of the main entities that an operating system needs to care about and is essentially synonymous with a program. A process goes through a range of states during its lifetime, as shown in the illustration, starting with new, ready, running, waiting and terminated. The two main queues that harbour the process are the ready queue and the I/O request queue. The former contains all processes that are eager and ready to execute, but are waiting to get access to the CPU play area. The latter is a queue that accommodates processes that make requests to shared devices, such as secondary storage..

Scheduling Mechanisms :A multiprogramming operating system allows more than one process to be loaded into the executabel memory at a time and for the loaded process to share the CPU using timemultiplexing.Part of the reason for using multiprogramming is that the operating system itself is implemented as one or more processes, so there must be a way for the operating system and application processes to share the CPU. Another main reason is the need for processes to perform I/O operations in the normal course of computation. Since I/O operations ordinarily require orders of magnitude more time to complete than do CPU instructions, multiprograming systems allocate the CPU to another process whenever a process invokes an I/O operation

Non-Preemptive Vs Preemptive Scheduling

Non-Preemptive: Non-preemptive algorithms are designed so that once a process enters the running state(is allowed a process), it is not removed from the processor until it has completed its service time ( or it explicitly yields the processor). context_switch() is called only when the process terminates or blocks. Preemptive: Preemptive algorithms are driven by the notion of prioritized computation. The process with the highest priority should always be the one currently using the processor. If a process is currently using the processor and a new process with a higher priority enters, the ready list, the process on the processor should be removed and returned to the ready list until it is once again the highestpriority process in the system. context_switch() is called even when the process is running usually done via a timer interrupt. First Come First Serve (FCFS) This is a Non-Premptive scheduling algorithm. FIFO strategy assigns priority to processes in the order in which they request the processor.The process that requests the CPU first is allocated the CPU first.When a process comes in, add its PCB to the tail of ready queue. When running process terminates, dequeue the process (PCB) at head of ready queue and run it.

Implementation#include #include

int n,i,temp; float avg_rt,avg_tat,avg_wt; int cpu_burst[10],rt[10],tat[10],wt[10];

int t[10];

void main() { clrscr(); coutn; cout