資源簡介
設計一個SP00LING輸出進程和兩個請求輸出的用戶進程,以及一個SP00LING輸出服務程序。當請求輸出的用戶進程希望輸出一系列信息時,調用輸出服務程序,由輸出服務程序將該信息送入輸出井。待遇到一個輸出結束標志時,表示進程該次的輸出文件輸出結束。之后,申請一個輸出請求塊(用來記錄請求輸出的用戶進程的名字、信息在輸出井中的位置、要輸出信息的長度等),等待SP00LING進程進行輸出。
SP00LING輸出進程工作時,根據請求塊記錄的各進程要輸出的信息,將其實際輸出到打印機或顯示器。這里,SP00LING輸出進程與請求輸出的用戶進程可并發運行。
(1)功能分析
當輸入“第一個用戶進程的請求為:”,“第二個用戶進程的請求為:”后,按下“確定”鍵,再右側文本區中將顯示兩個請求輸出的用戶進程請求的數據,以及SPOOLING輸出進程輸出的數據。其中兩個請求輸出的用戶進程的調度的概率各為0.45,SPOOLING輸出進程的調度為0.10,該調度以隨機數發生器產生的隨機數來模擬。
(2)進程狀態
進程基本狀態有3種,分別為可執行、等待和結束。可執行態就是進程正在運行或等待調度的狀態;等待狀態又分為等待狀態1、等待狀態2和等待狀態3。
狀態變化的條件為:
①進程執行完成時,置為“結束”態。
②服務程序在將輸出信息送輸出井時,如發現輸出井已滿,將調用進程置為“等待狀態1”。
③SP00LING進程在進行輸出時,若輸出井空,則進入“等待狀態2”。
④SP00LING進程輸出一個信息塊后,應立即釋放該信息塊所占的輸出井空間,并將正在等待輸出的進程置為“可執行狀態”。
⑤服務程序在輸出信息到輸出井并形成輸出請求信息塊后,若SP00LING進程處于等待態,則將其置為“可執行狀態”。
⑥當用戶進程申請請求輸出塊時,若沒有可用請求塊時,調用進程進人“等待狀態3”。

代碼片段和文件信息
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
import?javax.swing.BorderFactory;
import?javax.swing.border.Border;
public?class?Newframe?implements?ActionListener{
private?Spooling?spooling;
private?Process?pro;
Jframe?f;
JPanel?ppnpcpc1pc2pc3pepe1pe2pe3;
Border?border_pc1;
Border?border_pc2;
Border?border_pc3;
Border?border_pc1_titled;
Border?border_pc2_titled;
Border?border_pc3_titled;
JLabel[]?label;
JButton?button;
JButton?cancel;
JButton?watch;
JTextField[]?textfield;
static?TextArea[]?area;
JProgressBar?bar;
JProgressBar?bar1;
JProgressBar?bar2;
Rectangle?rect;
Rectangle?rect1;
Rectangle?rect2;
Newframe()
{
f=new?Jframe(“SP00LING假脫機輸入輸出技術模擬“);
label=new?JLabel[2];
label[0]=new?JLabel(“用戶一進程請求個數:“);
label[1]=new?JLabel(“用戶二進程請求個數:“);
button=new?JButton(“確定“);
cancel=new?JButton(“重置“);
watch=new?JButton(“查看詳細信息“);
textfield=new?JTextField[2];
textfield[0]=new?JTextField(15);
textfield[1]=new?JTextField(15);
area=new?TextArea[3];
for(int?i=0;i<3;i++)?
{
area[i]=new?TextArea(6120);
area[i].setEditable(false);
area[i].setBackground(Color.WHITE);
}
// area[0].setBackground(Color.PINK);
// area[1].setBackground(Color.YELLOW);
// area[2].setBackground(Color.GREEN);
p=new?JPanel();
pn=new?JPanel();
pc=new?JPanel();
pc1=new?JPanel();
pc2=new?JPanel();
pc3=new?JPanel();
pe=new?JPanel();
pe1=new?JPanel(new?FlowLayout(FlowLayout.LEFT));
pe2=new?JPanel(new?FlowLayout(FlowLayout.LEFT));
pe3=new?JPanel(new?FlowLayout(FlowLayout.LEFT));
border_pc1=BorderFactory.createLoweredBevelBorder();
????????border_pc1_titled=BorderFactory.createtitledBorder(border_pc1“用戶一進程請求輸出的數據:“);
????????border_pc2=BorderFactory.createLoweredBevelBorder();
????????border_pc2_titled=BorderFactory.createtitledBorder(border_pc2“用戶二進程請求輸出的數據:“);
????????border_pc3=BorderFactory.createLoweredBevelBorder();
????????border_pc3_titled=BorderFactory.createtitledBorder(border_pc3“SPOOLING請求輸出服務進程:“);
p=new?JPanel(new?BorderLayout(1010));
pn.add(label[0]);pn.add(textfield[0]);
pn.add(label[1]);pn.add(textfield[1]);
pn.add(button);button.addActionListener(this);
pn.add(cancel);cancel.addActionListener(this);
pn.add(watch);watch.addActionListener(this);
pc.setLayout(new?GridLayout(31));
pc1.setBorder(border_pc1_titled);
pc2.setBorder(border_pc2_titled);
pc3.setBorder(border_pc3_titled);
pc1.add(area[0]);
pc2.add(area[1]);
pc3.add(area[2]);
pc.add(pc1);
pc.add(pc2);
pc.add(pc3);
? bar=new?JProgressBar(JProgressBar.HORIZONTAL0100);???//總進度條橫向
bar1=new?JProgressBar(JProgressBar.HORIZONTAL0100);???//用戶一進度條橫向
bar2=new?JProgressBar(JProgressBar.HORIZONTAL0100);???//用戶二進度條橫向
bar.setStringPainted(true);
bar1.setStringPainted(true);
bar2.setStringPainted(true);
pe.setLayout(new?GridLa
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????11791??2011-06-30?15:00??sooping\Newfr
?????文件????????884??2011-06-29?04:40??sooping\Process.java
?????文件???????6580??2011-06-30?08:54??sooping\Spooling.java
?????文件??????22528??2011-08-19?09:56??sooping\需求分析.doc
?????目錄??????????0??2011-08-19?09:56??sooping
-----------?---------??----------?-----??----
????????????????41783????????????????????5
- 上一篇:將音樂轉換成十六進制碼
- 下一篇:數據庫課程設計小區物業管理系統
評論
共有 條評論