-
大小: 22KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-06-04
- 語言: Java
- 標(biāo)簽: 操作系統(tǒng)??java??內(nèi)存分配??
資源簡介
操作系統(tǒng)實(shí)驗(yàn)和課設(shè),java實(shí)現(xiàn)動態(tài)內(nèi)存分配和回收,實(shí)現(xiàn)算法FF,NF,WF,BF,有swing界面

代碼片段和文件信息
import?javax.swing.Jframe;
import?javax.swing.JPanel;
import?javax.swing.border.EmptyBorder;
import?javax.swing.JButton;
import?javax.swing.JLabel;
import?javax.swing.JTextArea;
import?java.awt.event.ActionListener;
import?java.awt.event.ActionEvent;
public?class?Interface?extends?Jframe?{
private?JPanel?contentPane;
private?JButton?btnFF;
private?JButton?btnNF;
private?JButton?btnBF;
private?JButton?btnWF;
/**
?*?Create?the?frame.
?*/
public?Interface()?{
settitle(“存儲管理“);
setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
setBounds(100?100?571?314);
contentPane?=?new?JPanel();
contentPane.setBorder(new?EmptyBorder(5?5?5?5));
setContentPane(contentPane);
contentPane.setLayout(null);
FreePartition[]?fp?=?new?FreePartition[5];
Job[]?j?=?new?Job[5];
JTextArea?taFP?=?new?JTextArea();
taFP.setBounds(10?35?200?154);
contentPane.add(taFP);
JTextArea?taJob?=?new?JTextArea();
taJob.setBounds(226?35?290?154);
contentPane.add(taJob);
JButton?btnRandom?=?new?JButton(“\u968F\u673A\u5206\u914D“);
btnRandom.addActionListener(new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
taFP.setText(null);
taJob.setText(null);
for?(int?i?=?0;?i?5;?i++)?{
int?fpRandom?=?(int)?(Math.random()?*?100?+?1);
taFP.append(i?+?“???????????????????????“?+?fpRandom?+?“????????????????????“?+?fpRandom?+?“\n“);
fp[i]?=?new?FreePartition(i?fpRandom);
}
for?(int?i?=?0;?i?5;?i++)?{
int?jRandom?=?(int)?(Math.random()?*?100?+?1);
taJob.append(i?+?“??????????????????????“?+?jRandom?+?“???????????????????“?+?-1?+?“\n“);
j[i]?=?new?Job(i?jRandom);
}
btnFF.setEnabled(true);
btnNF.setEnabled(true);
btnBF.setEnabled(true);
btnWF.setEnabled(true);
}
});
btnRandom.setBounds(155?199?93?23);
contentPane.add(btnRandom);
JButton?btnReset?=?new?JButton(“\u91CD\u7F6E“);
btnReset.addActionListener(new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
for?(int?i?=?0;?i?5;?i++)?{
fp[i]?=?null;
j[i]?=?null;
}
taFP.setText(null);
taJob.setText(null);
btnFF.setEnabled(true);
btnNF.setEnabled(true);
btnBF.setEnabled(true);
btnWF.setEnabled(true);
}
});
btnReset.setBounds(291?199?93?23);
contentPane.add(btnReset);
btnFF?=?new?JButton(“\u9996\u6B21\u9002\u5E94“);
btnFF.addActionListener(new?ActionListener()?{
public?void?actionPerformed(ActionEvent?e)?{
taFP.setText(null);
taJob.setText(null);
if?(fp[0]?!=?null?&?j[0]?!=?null)?{
StorageManagement.ff(fp?j);
for?(int?i?=?0;?i?5;?i++)?{
taFP.append(fp[i].fpNum?+?“???????????????????????“?+?fp[i].fpSize?+?“????????????????????“
+?fp[i].fpRemainder?+?“\n“);
taJob.append(j[i].jNum?+?“??????????????????????“?+?j[i].jSize?+?“???????????????????“
+?j[i].jfpNum?+?“\n“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-27?22:13??Storage?Management\
?????文件?????????299??2017-12-12?09:07??Storage?Management\.classpath
?????文件?????????393??2017-12-12?09:07??Storage?Management\.project
?????目錄???????????0??2017-12-27?22:13??Storage?Management\.settings\
?????文件?????????592??2017-12-12?09:07??Storage?Management\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2017-12-27?22:14??Storage?Management\bin\
?????文件?????????416??2017-12-13?21:53??Storage?Management\bin\FreePartition.class
?????文件????????1972??2017-12-13?23:40??Storage?Management\bin\Interface$1.class
?????文件????????1265??2017-12-13?23:40??Storage?Management\bin\Interface$2.class
?????文件????????2102??2017-12-13?23:40??Storage?Management\bin\Interface$3.class
?????文件????????2102??2017-12-13?23:40??Storage?Management\bin\Interface$4.class
?????文件????????2157??2017-12-13?23:40??Storage?Management\bin\Interface$5.class
?????文件????????2157??2017-12-13?23:40??Storage?Management\bin\Interface$6.class
?????文件????????2113??2017-12-13?23:40??Storage?Management\bin\Interface$7.class
?????文件????????3790??2017-12-13?23:40??Storage?Management\bin\Interface.class
?????文件?????????389??2017-12-13?21:53??Storage?Management\bin\Job.class
?????文件?????????843??2017-12-13?23:26??Storage?Management\bin\Jop$1.class
?????文件?????????816??2017-12-13?23:26??Storage?Management\bin\Jop.class
?????文件?????????697??2017-12-13?14:57??Storage?Management\bin\Jtabledemo$1.class
?????文件????????1168??2017-12-13?14:57??Storage?Management\bin\Jtabledemo.class
?????文件?????????687??2017-12-13?23:41??Storage?Management\bin\Main$1.class
?????文件?????????492??2017-12-13?23:41??Storage?Management\bin\Main.class
?????文件????????2507??2017-12-13?21:53??Storage?Management\bin\StorageManagement.class
?????目錄???????????0??2017-12-27?22:14??Storage?Management\src\
?????文件????????7907??2017-12-13?23:40??Storage?Management\src\Interface.java
?????文件?????????331??2017-12-13?23:41??Storage?Management\src\Main.java
?????文件????????3618??2017-12-13?21:53??Storage?Management\src\StorageManagement.java
評論
共有 條評論