operating systems project based lab

8
OPERATING SYSTEMS PROJECT BASED LAB S.no Name of the student Sec Roll no. ID No. 1 V.PRUDHVI KRISHNA 2D 68 12003472 2 K.SRINIDHI 2D 25 12003163 3 KVS.UDAY BHASKAR 2D 64 12003458 4 B.ARUN KUMAR 2D 36 12003288 SUBMITTED BY:- BATCH-6 K L UNIVERSITY, Vaddeswaram, Green fields, Guntu

Upload: beverly-norton

Post on 13-Apr-2016

5 views

Category:

Documents


0 download

DESCRIPTION

operating

TRANSCRIPT

Page 1: Operating Systems Project Based Lab

OPERATING SYSTEMS PROJECT BASED LAB

S.no Name of the student Sec Roll no. ID No.

1 V.PRUDHVI KRISHNA 2D 68 12003472

2 K.SRINIDHI 2D 25 12003163

3 KVS.UDAY BHASKAR 2D 64 12003458

4 B.ARUN KUMAR 2D 36 12003288

SUBMITTED BY:-BATCH-6

K L UNIVERSITY, Vaddeswaram, Green fields, Guntu

Page 2: Operating Systems Project Based Lab

ABSTRACT

The project entitled “Implementation of CPU Scheduling Algorithms” is basically a program which simulates the following scheduling algorithms:

FCFS (First Come First Served) SJF (Shortest Job First) Round-Robin Priority Scheduling

CPU Scheduling is a key concept in computer multitasking, multiprocessing operating system and real-time operating system designs. It refers to the way processes are assigned to run on the available CPUs, since there are typically many more processes running than there are available CPUs.

CPU Scheduling deals with the problem of deciding which of the processes in the ready queue is to be allocated the CPU. By switching the CPU among processes, the operating system can make the computer more productive. A multiprogramming operating system allows more than one process to be loaded into the executable memory at a time and for the loaded process to share the CPU using time-multiplexing.

Scheduling algorithm is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). The need for a scheduling algorithm arises from the requirement for most modern systems to perform multitasking (execute more than one process at a time) and multiplexing (transmit multiple flows simultaneously).

In this project we will be calculating Turn-around time, Waiting time, Response time and their averages for FCFS, SJF, Round-Robin and Priority Scheduling algorithms. This project helps to keep CPU busy and to improve its efficiency.

Page 3: Operating Systems Project Based Lab

INTRODUCTION

CPU SCHEDULING:

It is the task of selecting a waiting process from the ready queue and allocating the CPU to it. It is a fundamental problem in operating systems in terms of minimizing the wait for the user when he or she simply wants to execute a particular set of tasks. In order to make the computer more productive in multiprogramming, the operating system needs to switch the CPU among processes.

The scheduler is concerned mainly with:

• CPU utilization: time utilized by CPU for a process.

• Throughput: The number of processes executed in a specified time period is called its throughput.

• Turnaround Time: The amount of time that is needed to execute a process is called turnaround time. It is the actual job time plus the waiting time.

• Waiting Time: The amount of time the process has waited is called waiting time. It is the turnaround time minus actual job time.

• Response Time: The amount of time between a request is Submitted and the first response is produced is called response time.

SCHEDULING ALGORITHMS:

Scheduling algorithms are the techniques used for distributing resources among parties which simultaneously and asynchronously request them. Scheduling disciplines are used in routers (to handle packet traffic) as well as in operating systems (to share CPU time among both threads and processes), disk drives (I/O scheduling), printers (print spooler), most embedded systems, etc. The main purposes of scheduling algorithms are to minimize resource starvation and to ensure fairness amongst the parties utilizing the resources. Scheduling deals with the problem of deciding which of the outstanding requests is to be allocated resources. There are many different scheduling algorithms.

Different algorithms are used for CPU scheduling:

FIRST-COME FIRST-SERVED SHORTEST-JOB-FIRST ROUND-ROBIN PRIORITY SCHEDULING

Page 4: Operating Systems Project Based Lab

Our project includes implementation of below algorithms in C Language:

FIRST-COME- FIRST-SERVED

With this scheme, whichever process requests CPU time first is allocated the CPU first. This is easily implemented with a FIFO queue for managing the tasks; as they come in, they're put on the end of the queue. As the CPU finishes each task, it pops it off the start of the queue and heads on to the next one.

DRAWBACK- The average waiting time for this technique, though, is often quite long.

ADVANTAGE - Simple to implement.

SHORTEST JOB FIRST

CPU is then given to the process with the minimal CPU burst from the waiting queue. SJF is provably optimal, in that for a given set of processes and their CPU bursts/execution times it gives the least average waiting time for each process.

SJF algorithm may be preemptive or non- preemptive. A preemptive SJF algorithm will preempt the currently executing process, whereas a non-preemptive SJF algorithm will allow the currently running process to finish its CPU burst. Preemptive SJF scheduling is sometimes called shortest-remaining-time-first.

Fig. 1- The working of SJF technique (a) Running four processes in original order (b) Running same processes in SJF order.

Take a look at the example of Fig. 1. In the original order, A runs first and hogs the system for shorter processes. If run in SJF order, the shorter jobs run first and A gets its turn last.

DRAWBACK-Main disadvantages of SJF are that these algorithms need advanced knowledge of estimation and preemption. These aspects make it hard to implement these algorithms.

ADVANTAGE- The SJF algorithms do not have a bias in favour of longer processes as it happens in FCFS algorithms. It also provides the maximum throughput in most of the cases.

ROUND-ROBIN

Round-Robin is one of the most important and significant algorithms. Almost all of the modern algorithm techniques work on same grounds as that of Round-Robin. It uses the concept of cyclic execution and allocates all processes a similar time of execution known as “Quantum” or “Time-slice”. It basically creates a queue of processes with all waiting

Page 5: Operating Systems Project Based Lab

processes, picks the first job, gives it the time-slice to execute and when its time is over, RR picks it and puts it at the tail of queue and the process begins once again with the next job in queue.

Fig. 2 – Round-Robin Technique (a) The list of runnable processes (b) List of runnable processes after job B has used its Quantum (Time-slice).

DRAWBACK- The main problem with Round-Robin is that it assumes that all processes are equally important, thus each receives an equal portion of the CPU. This sometimes produces bad results.

ADVANTAGE- The biggest advantage that RR-algorithm has over other algorithm techniques is that it is fair to every process, giving all of them exactly the same time, and thus starvation is virtually impossible to happen.

PRIORITY SCHEDULING

The Priority-based scheduling (PBS) involves the concepts of both preemption and Round-Robin algorithm. It runs the highest-priority processes first, using round-robin technique among processes of equal priority. If a new job arrives, scheduler inserts it in the run queue behind all processes of greater or equal priority.

DRAWBACK- The biggest disadvantage of the priority-based scheduling is the concept of priority itself! If we add a lot of processes to a queue with varying priorities assigned to them, chances are that the processes with the least priority will never run if more processes keep on coming.

ADVANTAGE- The main advantage of Priority-based scheduling is that it uses round-robin technique to make sure that a single job does not hog the resources of the processor.

Page 6: Operating Systems Project Based Lab

OVERVIEW & APPLICATIONS:

With the basic scheduling techniques discussed, we present an overview and comparison of different scheduling algorithms in the table that follows

Comparison Table:

Algorithm CPU Overhead Throughput Turnaround Time

Response Time

FCFS/FIFO Low Low High Low SJF Medium High Medium Medium Round-Robin High Medium Medium High Priority-based Medium Low High High

Table 1 – Comparison of different scheduling algorithms