A Practical approach on MLQ– fuzzy logic in...

Full text

(1)

A Practical approach on MLQ– fuzzy logic in

CPU Scheduling

Narender Singh

1

, Dr. Yashpal Singh

2

,

1

Research Scholar, Ganga Institute of Technology and management kablana, Jhajjar

2

Associate Professor Ganga Institute of Technology and management kablana, Jhajjar ABSTRACT

In this paper we propose using the scientific method to develop a deeper understanding of CPU schedulers; we use this approach to explain and understand the sometimes erratic behavior of CPU schedulers. Scheduling is a decision making process which deals with the allocation of resources to tasks over given time periods. Scheduling means how the processes can be assigned on the available CPU. It is a key feature in multitasking, multiprocessing and real-time operating system design. Scheduling is done by scheduler and dispatcher. A scheduler is a person or machine that organizes or maintains schedules. A dispatcher is a module which gives control of CPU to the process selected by the scheduler. Scheduling problem involves jobs that must schedule on machines subject to certain constraints to optimize some objective functions. There are number of CPU scheduling algorithms available, but it is very difficult task to decide which one is better. This thesis discusses the design and implementation of modified fuzzy based CPU scheduling algorithm. It demonstrates that scheduling done with new priority improves average waiting time and average turnaround time. This scheduling algorithm has two queues, one is at highest priority and execute tasks in round robin fashion while other is batch queue and executes in first in first out (FIFS) sequence. We will change these by fuzzy logic decisions which will update the priorities of task in second queue and time slot assigned in first queue. In this paper a new algorithm for the CPU scheduling is presented using FFGA (Fonseca and Fleming’s Genetic Algorithm) multi objective optimization. The performance of this algorithm was compared with seven classical scheduling algorithms (FCFS, RR (equal, prioritized), SJF (preemptive, non-preemptive, Priority (preemptive, non-preemptive)), and the results showed that the performance of the proposed method is more optimized than other methods. The proposed algorithm optimizes the average waiting time and response time for the processes.

Keywords: CPU Scheduling, Multi objective Optimization, Waiting Time, Response Time, Turnaround Time, Process Scheduling turnaround time, dynamic time quantum.

1. INTRODUCTION

Modern Operating Systems are moving towards multitasking environments which mainly depends on the PU scheduling algorithm since the CPU is the most effective or essential part of the computer. Round Robin is considered the most widely used scheduling algorithm in CPU scheduling [1]-[2], also used for flow passing scheduling through a network device [3]-[4]. Operating systems may feature up to 3 distinct types of a long-term scheduler a mid-term or medium term scheduler and a short-term scheduler. The dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler [1].

Each process needs two factors when entering the operating system; first CPU and second I/O. The processes are divided into two general groups of CPU limited and I/O limited processes based on the need to these two factors. Now in a system with many processes available there will be a competition between these processes to acquire the resources. One of the most difficult problems in designing the operating systems is the timely allocation of resources to the processes and retrieving them. This problem is solved by the classical view of the different algorithms. All of thealgorithms have some advantages and disadvantages; yet there is not a general method available. Some of the objectives that scheduling function should satisfy in order to be effective include fairness, efficient use of processor time, response time, turnaround and throughput [1]. Operating systems may feature up to three distinct types of scheduling: long-term scheduling, medium-term scheduling and short-term scheduling.

(2)

utilization and throughput, to minimize turnaround time, waiting time and response time and to avoid starvation of any process.

Scheduling Algorithm

i.) First Come First Served Scheduling Algorithm (FCFS):-FCFS is the simplest scheduling algorithm. For this algorithm the ready queue is maintained as a FIFO queue. PCB (Process Control Block) of a process submitted to the system is linked to the tail of the queue. The algorithm dispatches processes from the head of the ready queue for execution by the CPU. When a process has completed its task it terminates and is deleted from the system. The next process is then dispatched from the head of the ready queue.

ii.) Shortest Job First Scheduling Algorithm (SJF):- For this algorithm the ready queue is maintained in order of CPU burst length, with the shortest burst length at the head of the queue. A PCB of a process submitted to the system is linked to the queue in the CPU. When a process has completed its task it terminates and is deleted from the system. The next process is then dispatched from the head of the ready queue.

iii.) Priority Based Scheduling:-In this algorithm, priority is associated with each process and on the basis of that priority CPU is allocated to the processes. Higher priority processes are executed first and lower priority processes are executed at the end. If multiple processes having the same priorities are ready to execute, control of CPU is assigned to these processes on the basis of FCFS [1]. Priority Scheduling can be preemptive and non-preemptive in nature.

iv.) Round Robin Scheduling Algorithm (RR):-For this algorithm the ready queue is maintained as a FIFO queue. A PCB of a process submitted to the system is linked to the tail of the queue. The algorithm dispatches processes from the head of the ready queue for execution by the CPU. Processes being executed is preempted on expiry of a time quantum, which is a system defined variable. A preempted process’s PCB is linked to the tail of the ready queue. When a process has completed its task, i.e. before the expiry of the time quantum, it terminates and is deleted from the system. The next process is then dispatched from the head of the ready queue.

2. SCHEDULING CRITERIA 2.1. CPU Scheduling

Whenever the CPU becomes idle, the operating system must select one of the processes in the queue to be executed. The selection process is carried out by the short-term scheduler (or CPU scheduler). The scheduler selects a process from the processes in memory that are ready to execute and allocates the CPU to that process. Note that the ready queue is not necessarily a first-in, first-out (FIFO) queue. As we shall see when we consider the various scheduling algorithms, a ready queue can be implemented as a FIFO queue, a priority queue, a tree, or simply an unordered linked list. Conceptually, however, all the processes in the ready queue are lined up waiting for a change to run on the CPU. The records in the queue are generally process control blocks (PCB) of the processes [1].

2.1.1. CPU Utilization

We want to keep the CPU as busy as possible that means CPU is not free during the execution of processes. Conceptually the CPU utilization can range from 0 to 100 percent.

2.1.1.1. Throughput

If the CPU is executing processes, then work is being completed. One measure work is the number of processes that are completed per time unit that means the number of tasks per second which the scheduler manages to complete the tasks.

2.1.1.2. Response Time

(3)

2.1.1.3. Turnaround Time

Turnaround time refers to the total time which is spend to complete the process and is how long it takes the time to execute that process. The time interval from the time of submission of a process to the time of completion is the turnaround time. Total turnaround time is calculation is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU and doing I/O.

2.1.1.4 Waiting Time

The waiting time is not the measurement of time when a process executes or does I/O completion; it affects only the amount of time of submission of a process spends waiting in the ready queue. So the Waiting time is the period of spent waiting in the ready queue to submit the new arriving process for the CPU. So a good scheduling algorithm for real time and time sharing system are concluded that must possess following characteristics [6]:

 Minimum context switches.

 Maximum CPU utilization.

 Maximum throughput.

 Minimum turnaround time.

 Minimum waiting time.

 Minimum response time.

2.2. Multiobjective optimization

The notion of weighing tradeoffs is common to problems in everyday life, science, and engineering. Buying a less expensive product might tradeoff product quality for the ability to buy more of something else. Adding an additional science instrument to a spacecraft trades off increased costs for increased science return. Hard optimization problems typically require many decisions on the input side and many objectives to optimize on the output side. The set of objectives forms a space where points in the space represent individual solutions. The goal of course is to find the best or optimal solutions to the optimization problem at hand. Pareto optimality defines how to determine the set of optimal solutions. A solution is Pareto-optimal if no other solution can improve one objective function without a simultaneous deterioration of at least one of the other objectives [24].

3. PROPOSED ALGORITHM

In proposed scheduling algorithm, have used together the working principle of MLFQ [2], SJF[10] and improved round robin scheduling algorithm[9].

Step1. Divide memory into three multiple queue. Each queue has its own scheduling algorithm. First two queues have RR scheduling algorithm and last queue has FCFS scheduling algorithm.

Step2. Initially, wait until all the processes have been come into first queue. Step3. After entering all process, sort all processes in according their burst time.

Step4. After sorting, apply RR (round robin) scheduling algorithm with suitable time quantum.

Step5. As now, in MLFQ, processes are switched from one queue to another queue. It means after completion of Step all process will switched from first queue into second queue. At the second queue, repeat the steps 4

Step 6: After the completion of Step 4 and 5, all the process will enter into third queue where, this queue has FCFS scheduling algorithm.

4. EXPERIMENTAL RESULTS

(4)

4.1. First-Come, First-Served (FCFS)

This algorithm selects the simplest method for CPU scheduling. A process which enters the queue earlier will control the CPU earlier. This method is non-preemptive. This method usually has a long waiting time on average. Table (2) shows the results of this algorithm. In the FCFS algorithm the waiting time and response time are the same. As it could be seen in Table (2), the waiting time is usually long and fairness is not observed among the processes. For example, P34 process which only needs the CPU for 4 seconds that should wait for 142 seconds.

4.2. Priority Weighted (PRI) (Preemptive, Non-preemptive)

The priority scheduling algorithm selects its next job based on the importance of the process. The job that has the highest priority (0 high: 9 low) is run first. If preemption is enabled the new jobs with a higher priority will interrupt the currently executing job. Without preemption the highest priority job is chosen after the active process finishes execution. The PRI method makes decisions regarding the priority of the processes. Determination of the processes priority rests on the operating system. When a process enters the ready processes queue, its priority is determined and will not change to the end. This could be a weak point for this method.

One of the problems of preemptive CPU scheduling algorithms is the period of time a scheduler should switch between the processes. This causes an overhead to be applied to the CPU and System performance is decreased. After reviewing the results of Tables (3) and (4) it could clearly be seen that in PRI (non -preemptive) method the average waiting time and the average Turnaround time are less than those of PRI method. The non-preemption of the CPU has also some advantages including the ability to reduce the response time for the processes which can be viewed in the results of tables (3) and (4). The PRI method can generally be a fair and good method.

4.3. Round Robin (RR) (Prioritized, Equal time)

The Round Robin scheduling algorithm allocates a time slice to each running process. This is called the quantum and it represents the number of CPU cycles a process gets before the scheduler searches for a new job to run. Jobs receive their quantum of CPU time in FCFS order. With priority scheduling enabled the quantum is multiplied by the magnitude of a processes priority. Thus more important jobs get more CPU time.The RR method has some advantages including the average short response time of the processes since this method switches between the processes using the time slices. But the RR method applies an extra overhead to the CPU due to these multiple switches and causes an increase in the average Turnaround time. Whit attention to table (5) and table (6), the performance of RR algorithm with identical time slices is better than the RR method with Prioritized.

4.4. Shortest Job First (SJF) (Preemptive, Non-preemptive)

The SJF algorithm chooses the shortest job. Without preemption jobs run to completion before a new job is selected. If preemption is enabled then the instant a job arrives that is shorter than the one being run the CPU switches to the new shorter job. The processing can be interrupted to run newly arrived shorter jobs. This method only pay attention to the CPU burst time and this filed is checked. This algorithm is presented in two states of non-preemptive and preemptive. Regarding the Tables (3) and (4) the performance of preemptive method is preferable. The SJF method has shown a better performance compared to previous methods, and it could be concluded that the processes which have a shorter CPU burst time would run earlier.

5. EXPERIMENT, IMPLEMENTATION AND ANALYSIS.

This section discusses only two experiments because results analysis assured that conclusions will remain unchanged.

(5)

Table [1]

Process Arrival Time Burst Time (ms)

A 0.0 8

B 0.4 4

C 1.0 1

D 1.4 10

E 1.8 11

F 2.0 5

5.1.1 Evaluations: According to existing concept, average waiting time, average turnaround time will be 16.4 ms and 22.9 ms respectively. According to novel approach, average waiting Time average turnaround time will be 15.6 ms and 22.067ms respectively.

5.2 Second Experiment: Table [2] shows initial state of processes. Suppose, MLFQ is partitioned into three queues. On the first two queues, RR scheduling algorithm is applying, which have time quantum 4 ms and 5 ms respectively. On the third queue, FCFS scheduling algorithm is applying.

Table 2

Process Arrival Time Burst Time (ms)

A 0.0 8

B 0.8 7

C 1.0 5

D 1.2 10

E 1.8 20

F 2.0 4

5.2.1 Evaluations: According to existing concept, average waiting time, average turnaround time will be 25.2 ms and 34.2 ms respectively. According to novel approach, average waiting Time average turnaround time will be 22.2 ms and 31.2 ms respectively.

5.3 Comparison: - Figure [1] and [2] are demonstrating turnaround time are using novel approach. Frequently, the turnaround times of processes are less or equal compare to existing approach. If at any situation, the turnaround times of process are greater, then at point of last stage, it degrades very slightly. At last, total outcomes of novel approach will be better compare than traditional approach. The same results for waiting time are demonstrated by Figure [3] and [4].

Figure 1 Figure 2

Turm Around Time

0 5 10 15 20 25 30 35 40 45

A B C D E F

Process

Ti

m

e Existing

Proposed

Turm Around Time

0 10 20 30 40 50 60

A B C D E F

Process

Ti

m

e Existing

(6)

Figure 3 Figure 4

It may be observed that average waiting time and average turnaround time both are minimizing with novel approach. Since, minimization is not much more, but it may be much more by increasing the number of process. The reduction of total waiting time and turnaround time shows maximum CPU utilization and response time. Therefore, novel approaches much more efficient compare than exiting approach.

Table: 3 Shortest Job First

Table: 4 Shortest Job First (Preemptive)

Table: 5 Proposed Method Result

Waiting Time

0 5 10 15 20 25 30 35

A B C D E F

Process

Ti

m

e Existing

Proposed

Waiting Time

0 5 10 15 20 25 30 35

A B C D E F

Process

Ti

m

e Existing

(7)

Table: 5 comparing the performances of 7 Scheduling algorithms with that of the suggested algorithm

G: The P22 process arrives at the system at the moment 1050 and immediately the P23 process also arrives. The

P22 process has the priority of 4 and its burst=65, and the P23 process has the priority of 2 and its burst=37. The

proposed algorithm runs the P23 process, but at the moment 1055 the P24 process also arrives at the system.

Regarding the characteristics of the P24 process, the proposed algorithm continues running P23 and completes it.

Now, it runs the P24 process from among the two remaining processes ( P22 , P22 ).

According to the Table 5, the proposed algorithm has the best results. The average waiting time for 50 processes is 9.28, the average response time is 7.62, and the average Turnaround time is 39.76. From the 7 scheduling algorithms, the best method is SJF (preemptive) method. The average waiting time for 50 processes is 18.24, the average response time is 13.68, and the average Turnaround time is 48.86. The SJF and Priority (non-preemptive) methods come in second and third, respectively.

Table: 6 Membership function range for interactive queue Membership function Range

Low [0, 2, 4]

Medium [3, 5.5, 8]

High [7, 8.5, 10]

Table: 7 Membership function range for batch queue Membership function Range

Very Low [-Inf, -Inf, 0.25, 3]

Low [0, 2.5, 5]

Medium [2.5, 5, 8]

High [4 ,7, 10]

Very High [6, 9.75, Inf, Inf]

In table 7 very low and very high values have the four ranges in respective decision levels, this is due to the fact that these are of trapezoidal shape rest are in triangular shape.

(8)

Figure: 6 Input memberships function for interactive queue for the second variable burst time

Figure: 7 Output membership function for interactive queue for the first variable new burst time (time quanta)

Figure: 8 Input membership functions for batch queue for the first variable priority

Figure 9: Input membership function for batch queue for the second variable execution time

(9)

Table: 8 Input for interactive queue

Arrival time burst Time Process Execution Time(s)

0.0 8 1 3

0.8 7 2 24

1.0 5 3 6

1.2 10 4 9

1.8 20 5 8

Table: 9 Input for batch queue

Process Execution Time Priority Arrival time (s)

1 3 6 2

2 24 5 1

3 6 1 2

4 9 4 1

5 8 2 0

In interactive queeu scheduling initially fixed quanta was assigned to each task that increases the waiting time and some tiem may lead to wastage of time too if process requires small time. But the fuzzy logic rules set assigns variable time slot for each process rather than keeping them fixed. This depends upon the process number and burst time. For the input considered in table 8, the time quanta provided into output is shownin table 10. corresponding bars chart is shiwn in figuer 11.

Table: 10 New time quanta assigned to each process by fuzzy logic

Process New Time Quanta Old Time Quanta

1 4.232 4

2 4.129 4

3 2.500 4

4 2.500 4

5 3 4

Figure: 11 Time quanta in interactive queue CPU scheduling

In batch queue scheduling old priorities and arrival time is used to replace the FCFS scheduling process. These two said variables are served as input variables in the fuzzy logic defined for it and gives a new priority output. These new priorities can also reshuffled based on the arrival time too. Input values considered for this is shown in table 11. A comparison of priority output of this queue is shiwn in figure 12. Corresponding numerical values for thsese priorities values are shown in table 12. the waiting tiem calculated for the whoel process is shown in figure 13. it shows that waiting time is reduced significantly that increase the efficiencty of CPU and won’t keep CPU idle much. Although the arrival tiem consideration don’t add much in reduction of waiting time. A gantt chart for each process in case of old priorities and new priorities calculated by fuzzy logic is displayed in table 12 .

0 1 2 3 4 5

Process 1 Process 2 Process 3 Process 4 Process 5

Fuzzy logic optimised

(10)

Figure: 12 Priority assigned to process with proposed work Table: 11 Priorities calculated by proposed work

Old priority Fuzzy logic assigned priority

Fuzzy logic + arrival time assigned priority

Process 1 6 7.6038 4.2361

Process 2 5 2.6690 2.6690

Process 3 1 5.4027 5.2474

Process 4 4 5.2474 7.6038

Process 5 2 4.2361 5.4027

Figure: 13 Overall waiting times

Table: 12 Average turnaround time calculations Old Priority Based

Process 1 Process 2 Process 4 Process 5 Process 3

0 3 27 36 44 50 Waiting

time Average turnaround time = (0+3+27+36+44+50)/5=32

New Priority based

Process 1 Process 3 Process 4 Process 5 Process 2

0 3

9 18 26 50 Waiting

time Average turnaround time = (0+3+9+18+26+50)/5=21.2 sec

The turnaround time too in case of proposed work decreases. It may vary for various programming languages depending on the developer of the software or the program. Turnaround time may simply deal with the total time it takes for a program to provide the required output to the user after the program is started. Turnaround time is one of the metrics used to evaluate an operating system's scheduling algorithms.

1 2 3 4 5

0 1 2 3 4 5 6 7 8

Priority c omparis on of all proc es s

Old Priority

Fuz z y Logic Priority

Final Priority c ons idering arrival time too

0 5 10 15 20 25 30 35 40 45

average waiting time

(11)

CONCLUSION

One of the main parts of any operating system is the scheduler. The schedulers try to improve the performance of the system by allocation of the resources to processes. Many CPU scheduling algorithms have been presented having advantages and disadvantages each. In this paper a new CPU scheduling algorithm is presented. This algorithm schedules the running of processes according to the three parameters of CPU burst time, I/O service time, and priority of processes). To this end, the FFGA multiple objective optimization algorithm is used. The proposed algorithm selects and runs the desired processes through adaptation. In this algorithm, the priority of processes increases with time, and no process encounters starvation. A comparison of the proposed algorithm with the 7 other methods showed that the average waiting time and average response time are decreased. The average turnaround time is also improved. One of the most important positive points of this method is that there is fairness among processes. Using other methods of artificial intelligence such as Fuzzy Logic, Neural Network, and Swarm Intelligence will be covered by the authors in the future. We hope to improve the performance of the operating systems and use the maximum potential of processors by using more advanced scheduling algorithms.

REFERENCES

[1]. Bashir Alam, 1M.N. Doja, R. Biswas ,“Finding Time Quantum of Round Robin CPU Scheduling Algorithm Using Fuzzy Logic “International Conference on Computer and Electrical Engineering, 2008, IEEE

[2]. Silberchatz, Galvin and Gagne ,2003, operating systems concepts,(6th edn, John Wiley and Sons)

[3]. D. M. Dhamdhere Operating Systems A concept Based Approach, Second edition, Tata McGraw-Hill, 2006 [4]. Operating Systems Sibsankar Haldar , Pearson Education, 2009

[5]. Andrew S. Tanenbaum, Operating Systems Design and Implementation, Second dition,2005 [6]. William Stallings, Operating Systems Internal and Design Principles, 5th Edition ,2006

[7]. Milenkovic, M., Operating System Concepts and Design, McGraw Hill, International Edition, 1992, [8]. Dr. Muhammad Younus Javed “ Simulation of CPU Scheduling Algorithms” , 2000, IEEE, Volume 2

[9]. Rakesh Kumar Yadav, Abhishek K Mishra,Naveen Prakash, Himanshu Sharma,”An Improved Round Robim Sheduling Algorithm”, Internatinal Journal on Computer Science andEengineering , 2010,Volume 2, Number 04 , pp:1064-1066 [10]. Al-Husainy, M.A.F.,”Best-job-first CPU scheduling algorithm” Inform. Technol. J., 2007, Volume 6: Number 2,Pp:

288-293.

[11]. F. J. Corbato, M. M. Daggett, R. C. Daley ,“An Experimental Time-Sharing System”, IFIPS, 1962

[12]. Bashir Alam, 1M.N. Doja, R. Biswas ,“Finding Time Quantum of Round Robin CPU Scheduling Algorithm Using Fuzzy Logic “International Conference on Computer and Electrical Engineering, 2008, IEEE

[13]. D. M. Dhamdhere Operating Systems A concept Based Approach, Second edition, Tata McGraw-Hill, 2006 [14]. Operating Systems Sibsankar Haldar , Pearson Education, 2009

[15]. Albert S. Woodfhull , Operating Systems Design and Implementation, Second dition,2005 [16]. William Stallings, Operating Systems Internal and Design Principles, 5th Edition ,2006

[17]. Milenkovic, M., Operating System Concepts and Design, McGraw Hill, International Edition, 1992, [18]. Mr. Umar Saleem “ Sim,ulation of CPU Sheduling Algorithms” , 2000, IEEE, Volume 2,Pp:562-567

[19]. Rakesh Kumar Yadav, Abhishek K Mishra,Naveen Prakash, Himanshu Sharma,”An Improved Round Robim Sheduling Algorithm”, Internatinal Journal on Computer Science andEengineering , 2010,Volume 2, Number 04 , pp:1064-1066 [20]. Al-Husainy, M.A.F.,”Best-job-first CPU scheduling algorithm” Inform. Technol. J., 2007, Volume 6: Number 2,Pp:

288-293.

Figure

Table [1]  Process Arrival Time

Table [1]

Process Arrival Time p.5
Figure [3] and [4].

Figure [3]

and [4]. p.5
Table 2

Table 2

p.5
Figure 4 It may be observed that average waiting time and average turnaround time both are minimizing with novel approach

Figure 4

It may be observed that average waiting time and average turnaround time both are minimizing with novel approach p.6
Table: 4 Shortest Job First (Preemptive)
Table: 4 Shortest Job First (Preemptive) p.6
Table: 5 Proposed Method Result
Table: 5 Proposed Method Result p.6
Table: 5 comparing the performances of 7 Scheduling algorithms with that of the suggested algorithm
Table: 5 comparing the performances of 7 Scheduling algorithms with that of the suggested algorithm p.7
Figure 5: Input membership function for interactive queue for the first variable process

Figure 5:

Input membership function for interactive queue for the first variable process p.7
Figure: 6 Input memberships function for interactive queue for the second variable burst time
Figure: 6 Input memberships function for interactive queue for the second variable burst time p.8
Figure: 7 Output membership function for interactive queue for the first variable new burst time (time quanta)
Figure: 7 Output membership function for interactive queue for the first variable new burst time (time quanta) p.8
Figure: 8 Input membership functions for batch queue for the first variable priority
Figure: 8 Input membership functions for batch queue for the first variable priority p.8
Figure 9: Input membership function for batch queue for the second variable execution time

Figure 9:

Input membership function for batch queue for the second variable execution time p.8
Figure: 10 Output membership function for batch queue for the first variable new priority
Figure: 10 Output membership function for batch queue for the first variable new priority p.8

References

Updating...