Вы находитесь на странице: 1из 5

Niño, Dence Lerry B.


First-come, first-served (FCFS)

• Nonpreemptive

• Job handled based on arrival time

– Earlier job arrives, earlier served

• Simple algorithm implementation

– Uses first-in, first-out (FIFO) queue

• Good for batch systems

• Unacceptable in interactive systems

– Unpredictable turnaround time

• Disadvantages

– Average turnaround time varies; seldom minimized

• First come, first served (FCFS) is an operating system process scheduling algorithm and a network routing
management mechanism that automatically executes queued requests and processes by the order of their
arrival. With first come, first served, what comes first is handled first; the next request in line will be executed
once the one before it is complete.

• FCFS is also known as first-in, first-out (FIFO) and first come, first choice (FCFC)

Shortest job next (SJN)

• Nonpreemptive

• Also known as shortest job first (SJF)

• Job handled based on length of CPU cycle time

• Easy implementation in batch environment

– CPU time requirement known in advance

• Does not work well in interactive systems

• Optimal algorithm

– All jobs are available at same time

– CPU estimates available and accurate

• Shortest job first is a scheduling algorithm in which the process with the smallest execution time is selected
for execution next. Shortest job first can be either preemptive or non-preemptive. Owing to its simple nature,
shortest job first is considered optimal. It also reduces the average waiting time for other processes awaiting

Shortest job first is also known as shortest job next (SJN) and shortest process next (SPN).

Priority scheduling

• Nonpreemptive

• Preferential treatment for important jobs

– Highest priority programs processed first

– No interrupts until CPU cycles completed or natural wait occurs

• READY queue may contain two or more jobs with equal priority

– Uses FCFS policy within priority

• System administrator or Processor Manager use different methods of assigning priorities

• Priority scheduling is a method of scheduling processes based on priority. In this method, the scheduler
chooses the tasks to work as per the priority, which is different from other types of scheduling, for example,
a simple round robin.

• Priority scheduling involves priority assignment to every process, and processes with higher priorities are
carried out first, whereas tasks with equal priorities are carried out on a first-come-first-served (FCFS) or
round robin basis. An example of a general-priority-scheduling algorithm is the shortest-job-first (SJF)
Shortest remaining time (SRT)

• Preemptive version of SJN

• Processor allocated to job closest to completion

– Preemptive if newer job has shorter completion time

• Often used in batch environments

– Short jobs given priority

• Cannot implement in interactive system

– Requires advance CPU time knowledge

• Involves more overhead than SJN

– System monitors CPU time for READY queue jobs

– Performs context switching

• Shortest remaining time, also known as shortest remaining time first (SRTF), is a scheduling method
that is a preemptive version of shortest job next scheduling. In this scheduling algorithm, the process with
the smallest amount of time remaining until completion is selected to execute. Since the currently executing
process is the one with the shortest amount of time remaining by definition, and since that time should only
reduce as execution progresses, processes will always run until they complete or a new process is added
that requires a smaller amount of time.

Round robin

• Preemptive

• Used extensively in interactive systems

• Based on predetermined slice of time

– Each job assigned time quantum

• Time quantum size

– Crucial to system performance

– Varies from 100 ms to 1-2 seconds

• CPU equally shared among all active processes

– Not monopolized by one job

• Round robin scheduling (RRS) is a job-scheduling algorithm that is considered to be very fair, as it uses time
slices that are assigned to each process in the queue or line. Each process is then allowed to use the CPU
for a given amount of time, and if it does not finish within the allotted time, it is preempted and then moved at
the back of the line so that the next process in line is able to use the CPU for the same amount of time.

Multiple-level queues

• Works in conjunction with several other schemes

• Works well in systems with jobs grouped by common characteristic

– Priority-based

• Different queues for each priority level

– CPU-bound jobs in one queue and I/O-bound jobs in another queue

– Hybrid environment

• Batch jobs in background queue

• Interactive jobs in foreground queue

• Scheduling policy based on predetermined scheme

• Four primary methods

2.Criteria for algorithm

1. input: there are zero or more quantities which are externally supplied;
2. output: at least one quantity is produced;
3. definiteness: each instruction must be clear and unambiguous;
4. finiteness: if we trace out the instructions of an algorithm, then for all cases the algorithm will
terminate after a finite number of steps;
5. effectiveness: every instruction must be sufficiently basic that it can in principle be carried out by
a person using only pencil and paper. It is not enough that each operation be definite, but it must
also be feasible.

3.Representing Algorithm

As mentioned previously, algorithms are generally represented by either pseudocode or a flowchart. But
what are these? It might be accurate to claim that each is merely a means of representing an algorithm,
but that would hardly move the discussion along. Instead, let's focus on what features we need our
means of algorithm representation to have in order for it to be a meaningful and useful representation.

 Show the logic of how the problem is solved - not how it is implemented.
 Readily reveal the flow of the algorithm.
 Be expandable and collapsible.
 Lend itself to implementation of the algorithm.

4.Data Structure
A data structure is a particular way of organizing data in a computer so that it can be used effectively.

 Array
 Linked List
 Stack
 Queue
 Binary Tree
 Binary Search Tree
 Heap
 Hashing
 Graph
 Matrix
 Misc
 Advanced Data Structure
 The data structures can also be classified on the basis of the following characteristics:

Characterstic Description

Linear In Linear data structures,the data items are arranged in a linear sequence.
Example: Array

Non-Linear In Non-Linear data structures,the data items are not in sequence.

Example: Tree, Graph

Homogeneous In homogeneous data structures,all the elements are of same type. Example: Array

Non- In Non-Homogeneous data structure, the elements may or may not be of the same
Homogeneous type. Example: Structures

Static Static data structures are those whose sizes and structures associated memory
locations are fixed, at compile time. Example: Array

Dynamic Dynamic structures are those which expands or shrinks depending upon the
program need and its execution. Also, their associated memory locations changes.
Example: Linked List created using pointers

5.Data Types
Primitive Data Types

A primitive data type specifies the size and type of variable values, and it has no additional methods.

Data types are divided into two groups:

 Primitive data types - includes byte, short, int, long, float, double, boolean and char
 Non-primitive data types - such as String, Arrays and Classes

Primitive number types are divided into two groups:

Integer types stores whole numbers, positive or negative (such as 123 or -456), without decimals. Valid
types are byte, short, int and long. Which type you should use, depends on the numeric value.

Floating point types represents numbers with a fractional part, containing one or more decimals. There
are two types: float and double.