求大神~~解救

qxd来逛论坛 2013-11-05 11:03:43
进程管理
1.目的和要求
加强对进程概念和进程状态转换的理解。
2.实验内容
包括:编写程序模拟进程的创建、运行、阻塞、唤醒、终止等过程。
3.实验环境
不限。Java、VC++、VB均可。
4.实验提示
1)假设内存最多可调入5个进程,即就绪队列中的进程数最多有5个。分别编写进程的创建、运行、阻塞、唤醒、终止等函数,在main函数中通过命令调用各函数,实现进程状态的转换。
2)至少应包含3个队列,就绪队列、阻塞队列和完成队列,并且各队列随着进程的状态转换而呈动态变化,应能在屏幕上显示出队列的变换情况。此三个队列可用数据结构中的链表、队列或数组来实现。
3)实验结果可显示的部分内容如下(仅供参考)。
...全文
395 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
王二北 2013-11-06
  • 打赏
  • 举报
回复
你确定是进程而不是线程?
只是_曾经 2013-11-06
  • 打赏
  • 举报
回复
引用 2 楼 huxiweng 的回复:
作业题啊??先自己写吧,遇到问题来问
请不要做伸手党。
teemai 2013-11-06
  • 打赏
  • 举报
回复
引用 6 楼 u012591136 的回复:
[quote=引用 2 楼 huxiweng 的回复:] 作业题啊??先自己写吧,遇到问题来问
package lx; import java.util.Scanner; public class Progress { int runing[]=new int[5]; static Scanner sc=new Scanner(System.in); public void creat(){ Progress p=new Progress(); System.out.println("就绪队列为:"); for(int i=0;i<5;i++){ int a=sc.nextInt(); runing[i]=a; System.out.print("->"+runing[0]); System.out.print("->"+runing[1]); System.out.print("->"+runing[2]); System.out.print("->"+runing[3]); System.out.println("->"+runing[4]); } p.rerun(); } public void runing(){ } public void block(){ } public void rouse(){ } public void stop(){ System.out.println("当前进程终止"); Progress p=new Progress(); p.rerun(); } public void rerun(){ System.out.println("请输入您的操作:1.回到系统菜单2.退出;"); int input=sc.nextInt(); Progress p=new Progress(); if(input==1){ p.start(); } if(input==2){ System.exit(0); } } public void start(){ System.out.println("-----------------系统菜单-------------------"); System.out.println("请输入您的操作:1.创建2.运行3.阻塞4.唤醒5.终止"); System.out.println("--------------------------------------------"); int input=sc.nextInt(); Progress p3=new Progress(); if(input==1){ p3.creat(); } if(input==2){ p3.runing(); } if(input==3){ p3.block(); } if(input==4){ p3.rouse(); } if(input==5){ p3.stop(); } } public static void main(String[] args) { Progress p1=new Progress(); p1.start(); } } 这里面我在creat方法得到的数组,怎么在下个方法继续使用呢?[/quote] 问题说清楚点啊,哪个数组,在哪个方法里用?
qxd来逛论坛 2013-11-06
  • 打赏
  • 举报
回复
引用 2 楼 huxiweng 的回复:
作业题啊??先自己写吧,遇到问题来问
package lx; import java.util.Scanner; public class Progress { int runing[]=new int[5]; static Scanner sc=new Scanner(System.in); public void creat(){ Progress p=new Progress(); System.out.println("就绪队列为:"); for(int i=0;i<5;i++){ int a=sc.nextInt(); runing[i]=a; System.out.print("->"+runing[0]); System.out.print("->"+runing[1]); System.out.print("->"+runing[2]); System.out.print("->"+runing[3]); System.out.println("->"+runing[4]); } p.rerun(); } public void runing(){ } public void block(){ } public void rouse(){ } public void stop(){ System.out.println("当前进程终止"); Progress p=new Progress(); p.rerun(); } public void rerun(){ System.out.println("请输入您的操作:1.回到系统菜单2.退出;"); int input=sc.nextInt(); Progress p=new Progress(); if(input==1){ p.start(); } if(input==2){ System.exit(0); } } public void start(){ System.out.println("-----------------系统菜单-------------------"); System.out.println("请输入您的操作:1.创建2.运行3.阻塞4.唤醒5.终止"); System.out.println("--------------------------------------------"); int input=sc.nextInt(); Progress p3=new Progress(); if(input==1){ p3.creat(); } if(input==2){ p3.runing(); } if(input==3){ p3.block(); } if(input==4){ p3.rouse(); } if(input==5){ p3.stop(); } } public static void main(String[] args) { Progress p1=new Progress(); p1.start(); } } 这里面我在creat方法得到的数组,怎么在下个方法继续使用呢?
ceclinux 2013-11-06
  • 打赏
  • 举报
回复
我觉得以后作业什么直接就上来问还叫大神什么直接就可以删了
Mourinho 2013-11-06
  • 打赏
  • 举报
回复
又一个伸手党
叶公好飞 2013-11-06
  • 打赏
  • 举报
回复
发布实用软件者,真是为民造福啊,我们要大力宣扬,以提高工作效率。
郑涛 2013-11-06
  • 打赏
  • 举报
回复
package com.tong.therad.wait; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; class Car { /** 有没打蜡 */ private boolean waxOn = false; /** 打蜡 */ public synchronized void waxed() { waxOn = true; notifyAll();// 打蜡完成,唤醒其它线程 } /** 抛光 */ public synchronized void buffed() { waxOn = false; notifyAll(); // 抛光完成,唤醒其它线程 } /** 等待打蜡 */ public synchronized void waitForWaxing() throws InterruptedException { while (waxOn == false) {wait();} } /** 等待抛光 */ public synchronized void waitForBuffing() throws InterruptedException { while (waxOn == true) {wait();} } } class WaxOn implements Runnable { private Car car; public WaxOn(Car car) { this.car = car; } public void run() { try { while (!Thread.interrupted()) { System.out.println("Wax On"); TimeUnit.MILLISECONDS.sleep(200); car.waxed(); // 是否由正确的原因唤醒,如果不是,再次调用wait(); car.waitForBuffing(); } } catch (InterruptedException e) { System.out.println("Exiting Via interrupt"); } System.out.println("Ending Wax On task"); } } class WaxOff implements Runnable { private Car car; public WaxOff(Car car) {this.car = car;} public void run() { try { while (!Thread.interrupted()) { car.waitForWaxing(); System.out.println("Wax Off"); TimeUnit.MILLISECONDS.sleep(200); car.buffed(); } } catch (InterruptedException e) { System.out.println("Exiting Via interrupt"); } System.out.println("Ending Wax Off task"); } } public class WaxOMatic { public static void main(String[] args) throws InterruptedException { Car car = new Car(); ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new WaxOff(car)); exec.execute(new WaxOn(car)); TimeUnit.SECONDS.sleep(5); exec.shutdownNow(); } }
qxd来逛论坛 2013-11-06
  • 打赏
  • 举报
回复
引用 7 楼 huxiweng 的回复:
[quote=引用 6 楼 u012591136 的回复:] [quote=引用 2 楼 huxiweng 的回复:] 作业题啊??先自己写吧,遇到问题来问
package lx; import java.util.Scanner; public class Progress { int runing[]=new int[5]; static Scanner sc=new Scanner(System.in); public void creat(){ Progress p=new Progress(); System.out.println("就绪队列为:"); for(int i=0;i<5;i++){ int a=sc.nextInt(); runing[i]=a; System.out.print("->"+runing[0]); System.out.print("->"+runing[1]); System.out.print("->"+runing[2]); System.out.print("->"+runing[3]); System.out.println("->"+runing[4]); } p.rerun(); } public void runing(){ } public void block(){ } public void rouse(){ } public void stop(){ System.out.println("当前进程终止"); Progress p=new Progress(); p.rerun(); } public void rerun(){ System.out.println("请输入您的操作:1.回到系统菜单2.退出;"); int input=sc.nextInt(); Progress p=new Progress(); if(input==1){ p.start(); } if(input==2){ System.exit(0); } } public void start(){ System.out.println("-----------------系统菜单-------------------"); System.out.println("请输入您的操作:1.创建2.运行3.阻塞4.唤醒5.终止"); System.out.println("--------------------------------------------"); int input=sc.nextInt(); Progress p3=new Progress(); if(input==1){ p3.creat(); } if(input==2){ p3.runing(); } if(input==3){ p3.block(); } if(input==4){ p3.rouse(); } if(input==5){ p3.stop(); } } public static void main(String[] args) { Progress p1=new Progress(); p1.start(); } } 这里面我在creat方法得到的数组,怎么在下个方法继续使用呢?[/quote] 问题说清楚点啊,哪个数组,在哪个方法里用?[/quote] 我的creat方法将手动输入的a依次赋值给runing数组,我想在runing方法里将这个数组删去指定元素,并输出剩下的元素
teemai 2013-11-05
  • 打赏
  • 举报
回复
作业题啊??先自己写吧,遇到问题来问
qxd来逛论坛 2013-11-05
  • 打赏
  • 举报
回复
引用 楼主 u012591136 的回复:
进程管理 1.目的和要求 加强对进程概念和进程状态转换的理解。 2.实验内容 包括:编写程序模拟进程的创建、运行、阻塞、唤醒、终止等过程。 3.实验环境 不限。Java、VC++、VB均可。 4.实验提示 1)假设内存最多可调入5个进程,即就绪队列中的进程数最多有5个。分别编写进程的创建、运行、阻塞、唤醒、终止等函数,在main函数中通过命令调用各函数,实现进程状态的转换。 2)至少应包含3个队列,就绪队列、阻塞队列和完成队列,并且各队列随着进程的状态转换而呈动态变化,应能在屏幕上显示出队列的变换情况。此三个队列可用数据结构中的链表、队列或数组来实现。 3)实验结果可显示的部分内容如下(仅供参考)。
用数组简单实现,创建就是创建数组1(就绪队列)并打印数组1,运行就是将数组1的指定元素添加到数组2(完成队列),并打印,求大神给个代码

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧