Cpu Scheduling Documentation

27
A Project Report On IMPLEMENTATION OF FCFS,SJF,SRT CPU SCHEDULING ALGORITHM IN JAVA Chapter – I Introduction

Transcript of Cpu Scheduling Documentation

Page 1: Cpu Scheduling Documentation

A

Project Report

On

IMPLEMENTATION OF FCFS,SJF,SRT CPU SCHEDULING ALGORITHM IN JAVA

Chapter – I

Introduction

Page 2: Cpu Scheduling Documentation

1.1 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

Overview

Scheduling algorithm

CPU Utilization ThroughputTurnaround

timeResponse

timeDeadline handling

Starvation free

First In First Out

Low Low High Low No Yes

Shortest remaining time

Medium High Medium Medium No No

Fixed priority pre-emptive scheduling

Medium Low High High Yes No

Round-robin scheduling

High Medium Medium Low No Yes

Page 3: Cpu Scheduling Documentation

Different algorithms are used for CPU scheduling. Such as FIRST-COME FIRST-SERVED

SHORTEST-JOB-FIRST

SHORTEST REMAINING TIME

ROUND ROBIN

PRIORITY SCHEDULING

MULTILEVEL QUEUE SCHEDULING

Our project includes implementation of below algorithms in java

FIRST-COME- FIRST-SERVEDWith 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 longADWANTAGE – simple to implement

SHORTEST JOB FIRSTCPU 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

SHORTEST REMAINING TIME It is the preemptive version of shortest job first algo A preemptive SJF algorithm will preempt the currently executing process it is done with preemption of process comparatively long if any process comes with shortest burst time

Page 4: Cpu Scheduling Documentation

Chapter – II

Literature Review

Page 5: Cpu Scheduling Documentation

2.1 LITERATURE

Traditionally, real time operating systems (RTOS) use scheduling mechanisms that

Can provide predictable latency. Although this is a desirable property, attempts to

Duplicate these designs in general purpose operating systems have not been fruitful

(Geol. et al. 2004 [10]). General purpose operating systems have taken a different

path in the development of schedulers. According to Goel et al. (2004) [10], Priority

Scheduling assumes that the CPU needs of each thread are known and that the highest

Priority thread voluntarily yields the CPU.

Central processing unit (CPU) scheduling is the mechanism by which operating

Systems (OS) allocate the CPU resources to processes. Scheduling is required for

Multiprogramming, and it is one of the fundamental OS activities (As, 2005 [1];

Bar, 2000 [3]; Bovet and Cesati, 2003 [5]; Carpenter et al. [7]; Gorman, 2004 [11];

Love, 2004 [17]; Martin, 1999 [20]; Rinard, 1998 [28]; Silberschatz, 1998 [29];

Tannenbaum, 1992 [31]). Because, a scheduler aims to keep the CPU and input/

output (IO) systems as busy as possible, by overlapping processes undergoing

IO bursts with processes undergoing CPU bursts, a process executed from bad or

malicious code can affect the behavior of a scheduler and hence cripple computing

(Kolivas, 2004 [13]; Martin, 1999 [20]; Miyoshi and Rajkumar, 2001 [21]; Oguma

and Nakayama, 2001 [22]; Oyvind, 2004 [23]; Park and Choe, 2002 [24]; Regehr,

2002 [26]).

The aim of a good scheduling algorithm is to maximize CPU utilization, CPU

throughput, and scheduler efficiency; and to minimize queue turn-around-time, pro-

1

cess wait time, perceived response time, and variation in response times. The idea

behind scheduling is based on a number of facts. First, process execution involves

a cycle of alternating bursts. Second, CPU burst times cluster sharply. Third, CPUbound

processes have many long CPU bursts. Last, IO-bound processes have many

short IO bursts.

Page 6: Cpu Scheduling Documentation

Chapter – III

Problem Identification

Page 7: Cpu Scheduling Documentation

3.1 PROBLEMS

Although context-switching is a desirable feature of OS CPU schedulers, it introduces

dispatch latency. Excessive context-switching increases scheduler overheads.

The current designs of scheduler algorithms allow bad or malicious code to exploit

scheduler run time characteristics and induce high dispatch latency, keeping the

scheduler perpetually busy and driving down CPU utilization.

Page 8: Cpu Scheduling Documentation

Chapter – IV

Methodology

Page 9: Cpu Scheduling Documentation

4.1 Software Hardware Requirement

JAVA

The Software Requirements are JAVA, MS EXCESS, Windows XP, Vista.

The Hardware Requirements are minimum 512 MB RAM, centrino duo processor

4.2 SRS Document

4.2.1 Introduction

4.2.1.1 Purpose of this document

To schedule the operating system process based on the fcfs, sjf,srtalgorithm s

4.2.1.2 Scope of this document

The scope of this study was limited to the Linux scheduler and the Preemptivepriority scheduling algorithm. At the evaluation phase, performance and stabilitycharacteristics were compared with those of the Linux 2.6.11 CPU scheduler.The C programming language was used in the development of the scheduler prototype.C has many desirable features, however there was not much of a choicesince this is the language of the Linux kernel (Linen, 2000 [15]). The software developmentand tests were carried out on a single processor Intel architecture basedpersonal computer.

4.2.1.3 Definitions, Acronyms and Abbreviations

Srs – Software Requirement Specification

User – a person who will be using the system for its intended purpose

FCFS-First Come First Serve

SJF-Shortest Job First

SRT-Shortest Remaining Tim

The goals are:

The goal is developa model CPU scheduler to guard against runway dispatch latency, and gurantee a optimum level of scheduler effiency4.2.1.5 Overview

4.2.2 General Description

Page 10: Cpu Scheduling Documentation

The remaining part of this document follows the IEEE STD 830-1993 format. Section 3 will

cover the product perspective, functions, user characteristics, constraints and assumptions.

Section 4 will cover the functional and non-functional requirements. Section 5 will cover the

operational requirements.

4.2.2.1

Product Perspective The system will be developedusing JAVA

4.2.2.2 Product Functions

To schedule the proceses of operating system CPU

4.2.2.3 User characteristics

User will enter the number of process to be schedule, bursttime, arrival time

4.2.3 Requirements

4.2.3.1 Functional Requirements

The user should be able to schedule the processes

4.2.3.1.1 Operation performed by user

4.2.3.1.1.1 Introduction

Scheduling algorithm will schedule the process.

4.2.3.1.1.2 Inputs

No. of process , burst time arrival time

4.2.3.1.1.3 Processing

These will schedule the process.

4.2.3.1.1.4 Outputs

Tur n around time,Average throught put, Waiting Time.

4.2.3.2 Interface Requirements

4.2.3.2.1 User Interfaces

4.2.3.2.1.1 The Command line Screen

Input will be provided in command window.

4.2.3.2.1.2. Applet viewer window

Output should be shown in this window

4.2.3.2.2 Hardware Interfaces

All necessary hardware interfaces will be proided by the developer.

4.2.3.2.3 Software Interfaces

The system shal be compatible to work as a applet window based application in JAVA .

Page 11: Cpu Scheduling Documentation

4.2.3.3 Performance Requirements

Burst time of process

Arrival time

4.2.3.4 Design Constraints

4.2.3.4.1 Standard Compliance

The IEEE format is used for technical documentation specification in this document.

4.2.3.4.2 Hardware Constraints

The software system runs on Windows XP, Vista that requires minimum 1GB RAM and

Centrino Duo Processor

4.2.3.4.3 Software Constraints (limitations)

The system shall meet all performance requirements running on the JAVA application

Page 12: Cpu Scheduling Documentation

4.3 DATA FLOW DIGRAM:

LEVEL 0

LEVEL 1

1st Level Data Flow Diagram (DFD)

Page 13: Cpu Scheduling Documentation

LEVEL 2

Page 14: Cpu Scheduling Documentation

Chapter – V

Results & Discussions

Page 15: Cpu Scheduling Documentation

5.1 RESULTS

FCFS input window :-

FCFS output window :-

Page 16: Cpu Scheduling Documentation

FCFS Output

SJF output

Srt output

Page 17: Cpu Scheduling Documentation
Page 18: Cpu Scheduling Documentation

Chapter – VI

Conclusion & Scope of

further Work

Page 19: Cpu Scheduling Documentation

6.1 Scope

The standard scheduling algorithms FCFS, SJF, RR, and Priority scheduling haveformed the basis of industry application of CPU schedulers. The industry implementationof schedulers have employed variations based on flavours and hybrids ofthe standard algorithms.As with most NP-hard problems, in designing the standard algorithms, scholars didnot concern themselves with security matters. They were interested in achievingoptimization in certain process scheduling criteria e.g. throughput and responsiveness.Security, as often with software development became an issue when otherinquisitive and / or malicious system developers got hold of the finnished products.

6.2 Conclusion

Since context-switching is a costly necessity, it is important to keep its frequencyto as minimum as possible. Malicious code can induce excessive context-switchingby generating successive processes with increasing priorities. Linux implements apreemptive kernel. The most acclaimed advantage of the preemptive kernel is theprotection it affords the OS. For instance, system calls are given high priority to enablethem to execute ahead of other tasks. In this way they can reset failure pointslike race conditions and deadlocks. Systems with preemptive kernels have to contendwith context-switching. The rational behind this study is that since the ratesof both preemption and context-switches can be monitored, then either conditionsto allow context-switching or preemption can be tied to the levels of the monitoredstatistics.

Page 20: Cpu Scheduling Documentation

Bibliography

Page 21: Cpu Scheduling Documentation

Website:

www.google.com

www.vbcodeguru.com

http://cuinl.tripod.com/activex-7.htm

http://www.vbtutor.net/lesson3.html

www.rbi.org.in