#include "monixitong.h"
#include <QtGui>
#include<QHBoxLayout>
#include<QVBoxLayout>
#include<iostream>
#include<algorithm>
#include<QThread>
#include<QTimer>
int zero=0;
extern QTimer timer;
extern double timeRate;
QTimer timer;
double timeRate = 1;
monixitong::monixitong(QDialog *parent)
: QDialog(parent)
{
//初始化模块
label_neicun=new QLabel("内存");
label_dayinji=new QLabel("打印机");
lineedit_neicun=new QLineEdit;
lineedit_dayinji=new QLineEdit;
pushbutton_chushihua=new QPushButton("初始化内存和打印机");
label_neicun->setBuddy(lineedit_neicun);
label_dayinji->setBuddy(lineedit_dayinji);
QVBoxLayout *mainwindow_layout_left=new QVBoxLayout;
QHBoxLayout *init_layout=new QHBoxLayout;
connect(pushbutton_chushihua,SIGNAL(clicked()),this,SLOT(init()));
init_layout->addWidget(label_neicun);
init_layout->addWidget(lineedit_neicun);
init_layout->addWidget(new QLabel("M"));
init_layout->addWidget(label_dayinji);
init_layout->addWidget(lineedit_dayinji);
init_layout->addWidget(new QLabel("台"));
init_layout->addWidget(pushbutton_chushihua);
init_layout->setContentsMargins(1,1,1,1);
QHBoxLayout *display_mem_printer_layout=new QHBoxLayout;
label_time=new QLabel;
label_time->setText("当前时间:"+QString::number(time_counter));
label_mem=new QLabel;
label_mem->setText("内存剩余:"+QString::number(mem)+"M");
label_printer=new QLabel;
label_printer->setText("打印机剩余"+QString::number(printer)+"台");
display_mem_printer_layout->addWidget(label_mem);
display_mem_printer_layout->addWidget(label_printer);
display_mem_printer_layout->addWidget(label_time);
//新建进程模块
lineedit_process_name=new QLineEdit;
lineedit_arrive_time=new QLineEdit;
lineedit_need_time=new QLineEdit;
lineedit_prio=new QLineEdit;
lineedit_need_mem=new QLineEdit;
lineedit_need_printer=new QLineEdit;
pushbutton_create_process=new QPushButton("创建进程");
QHBoxLayout *create_process_layout=new QHBoxLayout;
create_process_layout->addWidget(new QLabel("进程名"));
create_process_layout->addWidget(lineedit_process_name);
create_process_layout->addWidget(new QLabel("到达时间"));
create_process_layout->addWidget(lineedit_arrive_time);
create_process_layout->addWidget(new QLabel("预计执行时间"));
create_process_layout->addWidget(lineedit_need_time);
create_process_layout->addWidget(new QLabel("优先级"));
create_process_layout->addWidget(lineedit_prio);
create_process_layout->addWidget(new QLabel("申请内存大小"));
create_process_layout->addWidget(lineedit_need_mem);
create_process_layout->addWidget(new QLabel("申请打印机台数"));
create_process_layout->addWidget(lineedit_need_printer);
create_process_layout->addWidget(pushbutton_create_process);
connect(pushbutton_create_process,SIGNAL(clicked()),this,SLOT(create_process()));
//显示等待队列
tableview_wait=new QTableView;
model_wait=new QStandardItemModel();
refresh_wait();
QVBoxLayout *wait_layout=new QVBoxLayout;
wait_layout->addWidget(new QLabel("New队列"));
wait_layout->addWidget(tableview_wait);
//正在运行的进程
tableview_run=new QTableView;
model_run=new QStandardItemModel();
model_run->setHorizontalHeaderLabels({"进程名","PID","优先级","剩余运行时间","占用内存大小","占用打印机数量"});
tableview_run->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
refresh_run();
pushbutton_block=new QPushButton("阻塞");
connect(pushbutton_block,SIGNAL(clicked()),this,SLOT(process_block()));
QVBoxLayout *run_layout=new QVBoxLayout;
QHBoxLayout *t1=new QHBoxLayout;
t1->addWidget(new QLabel("正在运行的进程"));
t1->addWidget(pushbutton_block);
run_layout->addLayout(t1);
run_layout->addWidget(tableview_run);
//算法选择模块
radiobutton_alogorithm1=new QRadioButton("非抢占式优先级算法");
radiobutton_alogorithm2=new QRadioButton("抢占式优先级算法");
pushbutton_start=new QPushButton("开始模拟");
QHBoxLayout * alogorithm_select_layout=new QHBoxLayout;
alogorithm_select_layout->addWidget(new QLabel("请选择模拟算法:"));
alogorithm_select_layout->addWidget(radiobutton_alogorithm1);
alogorithm_select_layout->addWidget(radiobutton_alogorithm2);
alogorithm_select_layout->addWidget(pushbutton_start);
connect(radiobutton_alogorithm1,&QRadioButton::toggled,[=](bool ischecked){if(ischecked=true)alogorithm=1;std::cout<<"alogorithm:"<<alogorithm<<std::endl;});
connect(radiobutton_alogorithm2,&QRadioButton::toggled,[=](bool ischecked){if(ischecked=true)alogorithm=2;std::cout<<"alogorithm:"<<alogorithm<<std::endl;});
connect(pushbutton_start,SIGNAL(clicked()),this,SLOT(start()));
//显示就绪队列
tableview_ready=new QTableView;
model_ready=new QStandardItemModel();
refresh_ready();
QVBoxLayout *ready_layout=new QVBoxLayout;
ready_layout->addWidget(new QLabel("就绪队列"));
ready_layout->addWidget(tableview_ready);
//显示完成队列
tableview_finish=new QTableView;
model_finish=new QStandardItemModel();
model_finish->setHorizontalHeaderLabels({"进程名","PID","到达时间","完成时间","周转时间","最终优先级","内存占用大小","打印机占用数量"});
tableview_finish->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
refresh_finish();
QVBoxLayout *finish_layout=new QVBoxLayout;
QHBoxLayout *header_finish_layout= new QHBoxLayout;
QLabel *l3=new QLabel("完成队列");
header_finish_layout->addWidget(l3);
pushbutton_result= new QPushButton("显示执行结果");
connect(pushbutton_result,SIGNAL(clicked()),this,SLOT(show_result()));
header_finish_layout->addWidget(pushbutton_result);
header_finish_layout->setStretchFactor(l3,5);
header_finish_layout->setStretchFactor(pushbutton_result,1);
finish_layout->addWidget(tableview_finish);
//显示初始情况(初始队列)
tableview_begin= new QTableView;
model_begin=new QStandardItemModel();
refresh_begin();
QVBoxLayout *begin_layout=new QVBoxLayout;
begin_layout->addWidget(new QLabel("进程初始情况"));
begin_layout->addWidget(tableview_begin);
//显示阻塞队列
lineedit_pid=new QLineEdit;
pushbutton_active=new QPushButton("激活");
connect(pushbutton_active,SIGNAL(clicked()),this,SLOT(process_active()));
tableview_block=new QTableView;
model_block=new QStandardItemModel();
refresh_block();
QHBoxLayout *header_block_layout=new QHBoxLayout;
QLabel *l1=new QLabel("阻塞队列");
QLabel *l2=new QLabel("输入要唤醒进程的PID");
header_block_layout->addWidget(l1);
header_block_layout->addWidget(l2);
header_block_layout->addWidget(lineedit_pid);
header_block_layout->addWidget(pushbutton_active);
header_block_layout->setStretchFactor(l1,3);
header_block_layout->setStretchFactor(l2,1);
header_block_layout->setStretchFactor(lineedit_pid,1);
header_block_layout->setStretchFactor(pushbutton_active,1);
QVBoxLayout *block_layout=new QVBoxLayout;
block_layout->addWidget(tableview_block);
QHBoxLayout *mainwindow_layout=new QHBoxLayout;
QVBoxLayout *mainwindow_layout_right =new QVBoxLayout;
mainwindow_layout_left->addLayout(display_mem_printer_layout);
mainwindow_layout_left->addLayout(init_layout);
mainwindow_layout_left->addLayout(create_process_layout);
mainwindow_layout_left->addLayout(alogorithm_select_layout);
mainwindow_layout_left->addLayout(wait_layout);
mainwindow_layout_left->addLayout(run_layout);
mainwindow_layout_left->addLayout(ready_layout);
mainwindow_layout_right->addLayout(header_block_layout);
mainwindow_layout_right->addLayo
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络与通信是一个非常广泛的领域,它涉及到计算机科学、电子工程、数学等多个学科的知识。 云计算与大数据:数据集、包括云计算平台、大数据分析、人工智能、机器学习等,云计算是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需提供给计算机和其他设备。
资源推荐
资源详情
资源评论
收起资源包目录
基于C++,QT的进程调度模拟系统.zip (6个子文件)
cm
monixitong.h 3KB
main.cpp 222B
monixitong.pro 590B
monixitong.ui 391B
monixitong.pro.user 19KB
monixitong.cpp 20KB
共 6 条
- 1
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功