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

Introduction

Scheduling is a key concept in computer multitasking, multiprocessing operating system


and real-time operating system designs. Scheduling 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. This assignment is carried out by software known as a scheduler and
dispatcher.
The scheduler is concerned mainly with:
 CPU utilization - to keep the CPU as busy as possible.
 Throughput - number of processes that complete their execution per time unit.
 Turnaround - total time between submission of a process and its completion.
 Waiting time - amount of time a process has been waiting in the ready queue.
 Response time - amount of time it takes from when a request was submitted until the first
response is produced.
 Fairness - Equal CPU time to each thread.

System

First-come, first-served (sometimes first-in, first-served; first-come, first choice; or


simply FCFS) is a service policy whereby the requests of customers or clients are attended to in
the order that they arrived, without other biases or preferences. The policy can be employed
when processing sales orders, in determining restaurant seating, or on a taxi stand, for example.
In Western society, it is the standard policy for the processing of most queues in which people
wait for a service.

Festival seating (also known as general seating and stadium seating) is seating done on a FCFS
basis. See Riverfront Coliseum for details on a December 1979 disaster involving "festival
seating" at a concert by The Who in Cincinnati, Ohio.

The practice is also common among some airlines which do not permit seat reservations either in
advance or at check-in. These airlines allow passengers to board in small groups based upon their
order of check-in and sit in whatever seat on the aircraft they wish to. On the basis of first come,
first served, the earlier you check-in the earlier you board the aircraft to get the seat you want.
Passengers are sequentially (on a first come, first served basis) assigned into one of three
"boarding groups." The passengers are then boarded onto the plane in group order.

*/
import javax.swing.*;//
import java.awt.*;
import java.awt.event.*;

class FCFS extends JFrame implements


ActionListener
/*Group Member:Mark Florence Villamil {
* Arwin Vincent A. JButton TGFButton[] = new JButton[3];
Custodio JTextField
* Jerome Albert Vidal TGFTextField1[],TGFTextField2[];
* Jomar Nacional
* Gelbert Villamil
JLabel TGFTextField2 = new
TGFLabel[],TGFLabel1,TGFLabel2,TGFLa JTextField[k];
bel3;
JPanel TGFPanel,TGFPanel1;
Container con; for(int i=0;i<k;i++)
int k,p; {
String str[] = TGFLabel[i] = new
{"SUBMIT","RESET","EXIT"}; JLabel("process"+(i+1));
String str1[] = {"Process"," TGFTextField1[i] = new
AT","ST","WT","FT","TAT","NTAT"}; JTextField(10);
TGFTextField2[i] = new
JTextField(10);
public FCFS() }
{
super("TGF's FCFS Algorithm"); for(int i=0;i<3;i++)
con = getContentPane(); {
TGFButton[i] = new
JButton(str[i]);
k=Integer.parseInt(JOptionPane.showInput }
Dialog("Enter number of Process"));
con.setLayout(new
TGFLabel1 = new GridLayout(k+2,3));
JLabel("Process"); con.add(TGFLabel1);
TGFLabel2 = new JLabel("Arival con.add(TGFLabel2);
Time"); con.add(TGFLabel3);
TGFLabel3 = new JLabel("Service
Time"); int l=0;

TGFLabel = new JLabel[k]; for(int i=0;i<k;i++)


TGFTextField1 = new JTextField[k]; {
con.add(TGFLabel[l]);
TGFPanel.setLayout(new
con.add(TGFTextField1[l]); GridLayout(k+1,7));
TGFPanel1.setLayout(new
con.add(TGFTextField2[l]); FlowLayout());
l++;
} if(ae.getSource() ==
l=0; TGFButton[2])
for(int i=0;i<3;i++) {
{ System.exit(0);
con.add(TGFButton[l]); }
else if(ae.getSource() ==
TGFButton[l].addActionListener(this); TGFButton[0])
l++; {
} FT[0] =
}//end of constructor Integer.parseInt(TGFTextField1[0].getText(
)) +
public void Integer.parseInt(TGFTextField2[0].getText(
actionPerformed(ActionEvent ae) ));
{
int FT[] = new int[k]; for(int i=0;i<k;i++)
int WT[] = new int[k]; {
int TAT[] = new int[k]; if(i==0)
float NTAT[] = new float[k]; {
float sum=0; WT[i] = 0;
float avg; }
JPanel main = new JPanel(); else
main.setLayout(new {
BorderLayout()); if(FT[i-1] <
TGFPanel = new JPanel(); Integer.parseInt(TGFTextField1[i].getText()
TGFPanel1 = new JPanel(); ))
{
FT[i]
=
Integer.parseInt(TGFTextField1[i].getText() }//end for loop
) for (int i=0;i<7;i++ )
+Integer.parseInt(TGFTextField2[i].getText {
()); TGFPanel.add(new
WT[i] JLabel(str1[i]));
= 0; }
} for (int i=0;i<k;i++)
else {
{ TGFPanel.add(new
JLabel("process"+(i+1)));
FT[i] = FT[i-1] + TGFPanel.add(new
Integer.parseInt(TGFTextField2[i].getText() JLabel("
); "+Integer.parseInt(TGFTextField1[i].getTex
t())));
WT[i] = FT[i-1] - TGFPanel.add(new
Integer.parseInt(TGFTextField1[i].getText() JLabel(""+Integer.parseInt(TGFTextField2[i
); ].getText())));
} TGFPanel.add(new
JLabel(""+WT[i]));
} TGFPanel.add(new
TAT[i] = JLabel(""+FT[i]));
WT[i] TGFPanel.add(new
+Integer.parseInt(TGFTextField2[i].getText JLabel(""+TAT[i]));
()); TGFPanel.add(new
NTAT[i] = JLabel(""+NTAT[i]));
TAT[i]/(Integer.parseInt(TGFTextField2[i].
getText()));
sum = }
sum+WT[i]; avg = sum/k;
String str2 =
"Average Waiting Time is "+ avg; window.setVisible(true);
TGFPanel1.add(new JLabel(str2));

window.setDefaultCloseOperation(JFrame.E
main.add(TGFPanel,BorderLayout.NORTH
XIT_ON_CLOSE);
);

}
main.add(TGFPanel1,BorderLayout.SOUT
}//END ACTION PERFORMED
H);

public static void main(String[] args)


JOptionPane.showMessageDialog(null,main
{
,"output",JOptionPane.PLAIN_MESSAGE
TGF_FCFS window = new
);
TGF_FCFS();

}
window.setSize(400,300);
else if(ae.getSource() ==
TGFButton[1])
window.setVisible(true);
{
setVisible(false);
TGF_FCFS window window.setDefaultCloseOperation(JFrame.E
= new TGF_FCFS(); XIT_ON_CLOSE);
}//end main
window.setSize(400,300); }//end class
Screenshots

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