Java - Como Hacer Un Planificador De Procesos Round Robin

 
Vista:

Como Hacer Un Planificador De Procesos Round Robin

Publicado por Julio Brizuela (2 intervenciones) el 19/06/2005 00:00:45
hola soy estudiante de informática y en la materia de sistemas opertivos me pidieron diseñar un planificador de procesos en java y no tengo la menor idea de como resolverlo, este es el enunciado:

se requiere que diseñe un planificador de procesos que implemente el algoritmo round robin de planificación, para ello deberá utilizar el lenguaje de programación java.

Las premisas de Elaboración son las siguientes:

- Se van a manejar 5 procesos.
- Cada proceso viene con el tiempo de llegada y el tiempo de duración respectivo.
- El Cuanto de tiempo (Q) será introducido por teclado.

EL planificador elaborado por usted debe:

- Mostar el diagrama de Grannt respectivo.
- Calcular el tiempo de retorno de cada proceso.
- Controlar la utilización (simulada) del CPU dependiendo del Q y del tiempo de llegada de cada proceso.

Les agradezco me puedan ayudar, solo tengo dos dias para entregarlo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Como Hacer Un Planificador De Procesos Round Robin

Publicado por monica roman jimenez (1 intervención) el 03/10/2012 20:00:48
mira estoy investigadin por el momento no t puedo ayudar pero me guataria ver la respuesta de tu problema gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Como Hacer Un Planificador De Procesos Round Robin

Publicado por juan (1 intervención) el 19/11/2012 21:38:42
hola, que tal, oye si te salio el round robin? estoy en el mismo problema
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Como Hacer Un Planificador De Procesos Round Robin

Publicado por Tuvergon (1 intervención) el 01/06/2013 19:32:46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package roundrobin;
 
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
 
/**
 *
 * @author Aldo
 */
public class ventana extends javax.swing.JFrame {
public boolean frozen;
int pr=0,e,te,tl,q,c1=0,c2,aux=21,qf,np;
String pr1,e1,te1,tl1="0",q1,co1="0";
String[] pro = new String[20];
String[] es = new String[20];
String[] tej = new String[20];
String[] qu = new String[20];
int t[] =new int[20];
int t2[] =new int[20];
int t3[] =new int[20];
boolean continua=true;
DefaultTableModel modelo;
/**
     * Creates new form ventana
     */
    public ventana() {
        initComponents();
 
   }
 
    public void tiempo(){
    java.util.Timer timer = new java.util.Timer(); //instancias el timer
final int delay = 1000;//retraso
               //inicializacion
timer.schedule(new TimerTask() {
@Override
public void run() {
   if(c1<=qf){
 
   c1++;
   co1=Integer.toString(c1);
   jLabel3.setText(co1);
   }
   else{
 
   reset();
   }
}
}, 0, delay);
 
    }
   public void reset(){
   frozen = true;
   c1 = 1;
   jLabel3.setText("1");
   }
    public void stop(){
 
    frozen = true;
    }
 
 
 
 public void acomodar(){
 
 for(int cont3=1;cont3<=5;cont3++)
{
q=q+t2[cont3];
if(t2[cont3]>0)
{
np=np+1;
}
}
qf=(q/np);
 
 
 
 
 
 
while(continua==true)
 
{
    tiempo();
 
 
    for(int i =1;i<=5;i++){
        pro[i]=Integer.toString(t[i]);
        tej[i]=Integer.toString(t2[i]);
        qu[i]=Integer.toString(qf);
        modelo = (DefaultTableModel) jTable1.getModel();
        String[] datos = {pro[i],es[i],tej[i],qu[i]}; // Cantidad de columnas de la tabla
        modelo.addRow(datos);
        jTable1.repaint();
 
System.out.println("proseso: "+t[i]+" Estado: "+es[i]+" Tiempo en ejecucion: "+t2[i]+ " Quantum: "+qf);
}
 
 
if(t2[1]>21)
{
t2[1]=t2[1]-21;
for(int cont1=1;cont1<=5;cont1++)
{
t[cont1]=cont1;
aux=t2[cont1];
t2[cont1]=t2[cont1+1];
t2[cont1+1]=aux;
if(t2[cont1]<1)
{
es[cont1]="F";
}
else
{
es[1]="A";
es[2]="E";
es[3]="E";
es[4]="E";
es[5]="E";
}
 
 
if(t2[1]==0&&t2[2]==0&&t2[3]==0&&t2[4]==0&&t2[5]==0)
{
continua=false;
}
 
}
System.out.println("");
}
 
else
{
 
t2[1]=t2[1]-t2[1];
for(int cont1=1;cont1<=5;cont1++)
{
aux=t2[cont1];
t2[cont1]=t2[cont1+1];
t2[cont1+1]=aux;
if(t2[cont1]<1)
{
es[cont1]="F";
}
else
{
es[1]="A";
es[2]="E";
es[3]="E";
es[4]="E";
es[5]="E";
}
 
 
 
if(t2[1]==0&&t2[2]==0&&t2[3]==0&&t2[4]==0&&t2[5]==0)
{
continua=false;
}
 
}
 
}
 
 
}
 
 
 
 
 
 }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
 
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 
        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
 
        jButton1.setBackground(new java.awt.Color(102, 0, 0));
        jButton1.setForeground(new java.awt.Color(255, 255, 255));
        jButton1.setText("Ingresar poceso");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
 
        jButton2.setBackground(new java.awt.Color(51, 0, 153));
        jButton2.setForeground(new java.awt.Color(255, 255, 255));
        jButton2.setText("Iniciar Round Robin");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
 
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("T_exec");
 
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
 
            },
            new String [] {
                "Proceso", "Estado", "Tie_exec", "Q"
            }
        ));
        jScrollPane1.setViewportView(jTable1);
 
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("0");
 
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(jLabel3)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addContainerGap(21, Short.MAX_VALUE))
        );
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
 
        pack();
    }// </editor-fold>
 
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
       //tiempo();
        acomodar();
 
    }
 
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
 
        pr++;
        te1=jTextField2.getText();
        te=Integer.parseInt(te1);
 
        t[pr]=pr;
        t2[pr]=te;
 
        System.out.println(te+" "+pr);
 
        jTextField2.setText("");
       jTextField2.requestFocus();
    }
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
 
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventana().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Como Hacer Un Planificador De Procesos Round Robin

Publicado por marco (1 intervención) el 18/11/2014 07:30:13
¡¿como compilo el codigo en entbeans??
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Como Hacer Un Planificador De Procesos Round Robin

Publicado por jhonatan (1 intervención) el 16/07/2019 02:17:25
oye me funciona bien tu codigo pero no entindo que quieren decie las letras F E A. me podrias explicar?? gracias n.n
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar