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

Modern Strategy for Shortest Job First Starvation Problem

Vivek Choubey
B.Tech(Dept. of IT) ITM,GIDA, Gorakhpur(UP),India vivekchoubey.it@gmail.com

Ashish Verma
B.Tech(Dept. of IT) ITM,GIDA, Gorakhpur(UP),India ashishit08@gmail.com

Shashank Tiwari
B.Tech(Dept. of IT) ITM,GIDA, Gorakhpur(UP),India stiwari.itm@gmail.com

Shamshad Ahmad Siddiqi


B.Tech(Dept. of IT) ITM,GIDA, Gorakhpur(UP),India sam786siddiqi@gmail.com

Abstract: Providing an ageing strategy for shortest job first which gives efficient result than any other any algorithm. So far we were considering scheduling algorithm that priorities the jobs on the basis of their occurrence in queue. The job appeared first will be executed first on the basis of their burst time, irrespective of their waiting time. This problem seems to be efficient but the major drawback was the jobs waiting for the longer period of time would get later chance to be executed. What we did in paper that we have divided the jobs whose burst time seems to be equal. This facilitates the ease of executing the jobs by dividing burst time with the waiting time. This creates difference between their priorities and hence the jobs will be executed on the basis of higher priority. Result: Based on experiments and calculations, our algorithm have provided better waiting time than Highest Response Ratio Next (HRRN) in some cases, equal waiting time in most cases, and a constant scheduling overhead. Keywords: SJF, HRRN, Starvation, Scheduling.

I. INTRODUCTION Modern operating systems (OS) nowadays have become more complex than ever before. They have evolved from a single task, single user architecture to a multitasking environment in which processes run in a concurrent manner. Allocating CPU to a process requires careful attention to assure fairness and avoid process starvation for CPU. Scheduling decision try to minimize the following: turnaround time, response time, and average waiting time for processes and the number of context switches [1]. CPU scheduling is an essential operating system task; therefore its scheduling is central to operating system design. When there is more than one process in the ready queue waiting its turn to be assigned to the CPU, the operating system must decide through the scheduler the order of execution [2]-[4]. First-Come First-Serve (FCFS) algorithms will have a minimal amount of context switches as a process, once allocated to the CPU, will not release it until its completion. This means lower context switches of n 1, where n is the number of processes, and constant time scheduling overhead of O (1). But the responsiveness is bad when we have multiple tasks. Shortest Job First (SJF) algorithm is known to be the algorithm with the least process turnaround time and process average waiting time. Turnaround time is the time it takes a process from its arrival time to the time of its completion, while waiting time is the amount of time a process waits. SJF, however, is not practical due to its low responsiveness in time sharing OSs. Moreover the scheduling overhead of a process in a ready queue is O (n), where n is the number of processes in the ready queue. Round Robin (RR) algorithms are widely used as they give better responsiveness but worse average turnaround time and waiting time [1]-[6]. In this paper, we have discussed an improvement on SJF solving its starvation problem. SJF leads to minimum possible waiting time. Using it to our advantage, we have used the relative comparison of burst time & waiting time as an ageing strategy. Consider the example of trains having varying speeds II. RELATED WORK This algorithm corrects some of the weakness of the SPF. The SPF algorithm is biased towards the processes with short service time. This keeps the longer processes waiting in the ready queue for the longer time, despite of arriving in the ready queue before the short jobs. It is a non-preemptive scheduling algorithm in which the priority is the function of not only the service time but also of the time spent by the process waiting in the ready queue. Once the process obtains the control of the processor, it completes to completion. The priority is calculated by the formula Priority = 1 + (Waiting time/burst time) (1)

In this algorithm too, short processes receive preference. But longer processes that have been waiting in the ready queue are also given the favorable treatment .Process with the higher priority as a result of above equation is allocated by scheduler first. HRRN though solving starvation problem does not fully utilizes the efficient waiting time offered by SJF as would be shown by us later. There have been numerous modifications done on HRRN to suit to a particular application need. Our algorithm being pre-emptive & comparatively less overhead can replace HRRN n quite efficiently in those applications. III. METHOD AND MATERIALS In general, users tend to prefer a specific set of programs involving audio/video players, web browsers, text editors and other software of daily usage. Therefore an analysis can be carried out to estimate burst time of various process when they are first executed. Analysis need to be re-performed only when the program is changed, updated [10]. The next CPU burst can also be predicted using the exponential average of previous CPU burst [3]. We have used the following equation (2) to decide which process is to be run next: P1b/P1w < P2b/P2w (2) Where P1b, P1w are burst time and waiting time of a process respectively.P2b, P2w are burst and waiting time of another process. We divide the burst time of the process by their waiting time and same for second process. Process whose burst time is divided by waiting time of the process to achieve the smaller value of the two should be given preference in scheduling order. If both the sides are equal then the process with shorter burst time is allocated to CPU. Starvation is solved because as waiting time of process having longer, their chance to run next on the CPU increases because ratio will be minimum if waiting time increases above equation chooses among two processes the one which on being scheduled later have to wait more than the other process. IV. ALGORITHM We sort all the process at a time t according to their burst time and place them in a first array. These processes being sorted in ascending order as per the equation are given the entirety of their burst time to run when scheduled. When a new process arrives it is placed into a second array which is also sorted in ascending order with the help of above equation. So, the top element of both the arrays contains the best two processes which can be scheduled next to achieve minimum waiting time. Therefore, we use the equation to compare the top element of both arrays and choose whichever gives less value. Let p1 be the process at top of first and p2 at top of second.

first = initially_sorted_array() second = empty scheduler() while(true){ if (interrupt){ if (new_process_runnable) add_ process_to_second() scheduler() } If (process terminates){ If (first is empty){ First=second Second= initialize_new () Scheduler () } } }

scheduler(){ If(second is empty) then top element of first runs If(p1b/p1w<p2b/p2w) then top element of first runs else if(p1b/p1w>p2b/p2w) top element of second runs else{ if(p1b<p2b) then top element of first runs else top element of second runs } }

V. IMPLEMENTATION We have used an array named first to contain the initially sorted processes. We initialize another array named second to contain the processes arriving dynamically at any time t second is initially empty.

1. Gbw which is abbreviated as global waiting time. 2. P1wf is waiting field time of a process

1) Gbw=total amount of time ongoing schedule of processes have been allowed to run. 2) Waiting field time of the newly run able process which is inserted into second array is gbw. 3) Waiting field time of currently executing interrupted process is equal to current waiting field time of process + gbw.
4) Reduce the burst time of interrupted process accordingly depending on the time left un-allocated. See, in the equation (3) to calculate the waiting time of a process we add the global waiting time to the process individual waiting time. This sum is then used in the equation as a process waiting time P1w=P1wf+gbw Where p1wf is process waiting field time. VI. COMPARISON AND PERFORMANCE Initially the process can be sorted using their burst time. This over-head is incurred in any scheduling algorithm which aim at a specific criteria like less waiting time, fair share allocation. Whenever a new process comes in, it also needs to be inserted at a proper place. This overhead is also same in our and other scheduling algorithms. Our scheduling time overhead is O(1) because scheduler just needs to compare the top two elements of both arrays to decide which one to run next. Whereas, in HRRN scheduling time overhead is O(n) on each scheduler invocation. Ofcourse HRRN sorts the processes when a previous running process have finished, while our strategy inserts the process as soon as it is brought in. In our case, we have to insert the newly arrived process with the help of insertion sort. While in case of HRRN no of iterations performed would be the number of processes present. In our strategy only in the worst case n iterations would be performed, while in HRRN it happens on each scheduler invocation. Look at table 3, initially process priority order to run is P4>P3>P2>P1.After P4 executes, priority order changes to P1>P2>P3. This happens because were considering ratio to find the priority of process. This ratio would keep on changing depending on increase in waiting time. In our strategy process is sorted into their burst time and case of arriving the new processes the priority for that is defined.
TABLE1. COMPARISION BETWEEN HRRN & MODERN

(3)

. Name P1 P2 P3 P4 Arrival time 0 1 2 3 Burst time 8 4 9 5

P1 0 8

P2 12

P4 17

P3 26

Figure 1.1 Gantt chart of TABLE I for HRRN

P 1 0 1

P2 5

P4 10

P1 17

P3 26

Figure 1.2 Gantt chart of TABLE I for MODERN

TABLE2. COMPARISION BETWEEN HRRN & MODERN

Name P1 P2 P3

Arrival time 0.0 0.4 1.0

Burst time 8 4 1

P1 0 8.0

P2 9.0

P4 13.0

Figure 2.1.Gantt chart of TABLE I for HRRN

P1 0.0 0.4

P2 4.4 5.4

P4 13.0

Figure 2.2.Gantt chart of TABLE I for MODERN

TABLE3. COMPARISION BETWEEN HRRN & MODERN

Name P1 P2 P3 P4 P4 0.0 6.0

Burst time 3 4 5 6 P1 9.0 P2

Waiting time 1.0 1.5 1.7 2.3 P3 13.0 18.0

Figure 3.1.Gantt chart of TABLE IV for HRRN

P1 0 .0 3.0

P2 7.0

P3 12.0

P4 18.0

Figure 3.2.Gantt chart of TABLE IV for MODERN


1 0 8 6 4 6 .5

5 .5 HR RN 2 .8 M DR O EN

m n t i w g a r e v A

2 0 t b 1t be t be a le a l 2 a l 3

Fig4. Average waiting time in HRRN and modern strategy

VII. CONCLUSION SJF scheduling faced a problem of starvation which meant that certain low priority process was never executed due to the execution of high priority process. This problem of SJF scheduling was solved by HRRN. But, with some positive feature of HRRN it also have a drawback. Since, HRRN takes more time in determining the priority of the process . Hence, this automatically increase the response time of process which could prove fatal certain time constraint process. This paper suggest strategy to solve this problem by minimizing the response time of the process. The tables and graph in this paper depicts that there is a considerable amount of reduction in waiting time. Hence the resulting algorithm for process scheduling is more efficient in comparison with other of its kind. REFERENCES [1] T. Helmy and A. Dekdouk, Burst Round Robin as a proportional-share scheduling algorithm, IEEEGCC 2007. [2] Tanebaum, Andrew S., Modern Operating Systems, 3rd edition, Prentice Hall, ISBN: 13: 9780136006633, pp: 1104. [3] A. Silberschatz, P.B. Galvin, G. Gagne, Operating Systems Concepts, 7th edition, John Wiley and Sons. [4] Rashid, M.M. and M.N. Akhtar,A new multilevel CPU scheduling algorithm, J. Applied Sci. 2006,vol. 6:pp. 2036- 2039. [5] Jon C.R. Bennett and H. Zhang, WF2Q: worst-case fair weighted fair queueing, INFOCOM '96, vol. 1:pp. 120-128, ISBN: 0-8186-7293-5 [6] Jason Nieh and Chris Vaill and Hua Zhong, Virtual-Time Round-Robin: An O (1) Proportional Share Scheduler, In Proceedings of the 2001 USENIX Annual Technical Conference, June 2001. [7] Caprita, B., W.C. Chan, J.N.C. Stein and H. Zheng, Group ratio round-robin: O(1) proportional share scheduling foruniprocessor and multiprocessor systems, Columbia University, Technical Report CUCS-028-04 [8] William Stallings, Operating systems: internals and design principles 6th edition, Prentice-Hall, ISBN-13: 9780136006329. [9] Rami J. Matarneh, Self-adjustment time quantum in Round Robin algorithm depending on burst time of the now running processes, American Journal of Applied Sciences 2009, pp. 1831-1837, ISSN 1546-9239 [10] C.A.Waldspurger and W.E.Weihl, Lottery and Stride scheduling: flexible proportional-share resource management, Proceeding OSDI '94 Proceedings of the 1st USENIX conference on Operating Systems Design and Implementation, 1994.

Вам также может понравиться