问题 单项选择题

在一个单CPU的计算机系统中,有3台不同的外部设备R1、R2、R3和3个进程P1、P2、P3。系统CPU调度采用可剥夺式优先级的进程调度方案,3个进程的优先级、使用设备的先后顺序和占用设备时问如表8-4所示。
假设操作系统的开销忽略不计,从3个进程同时投入运行到全部完成,CPU的利用率约为 (6) %;R3的利用率约为 (7) %(设备的利用率指该设备的使用时间与进程组全部完成所占用时间的比率)。

A.66

B.50

C.33

D.17

答案

参考答案:B

解析:[要点解析] 在多道系统中的3个任务(P1、P2、P3)是竞争使用CPU,但可并行使用I/O设备(R1、R2、R3)。各个任务运行的分析过程如图8-4所示。图中水平粗实线表示某进程实际执行过程所占用的CPU或I/O设备的时间。

表8-4 进程的优先级、使用设备的先后顺序和占用设备时间表

进程
问答题

【说明】 本程序通过移动滑动条修改颜色RGB值,从而控制颜色。程序中有一个面板、3个标签和3个滑动条,标签和滑动条一一对应,分别对应三原色红、绿、蓝,任意拖动其中的一个滑动条,所对应的颜色值就会发生变化,面板的颜色也会发生对应的变化,如下图所示,滑动条值的范围是0~255。

【Java代码】 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class simple extends JFrame implements AdjustmentListener{ public simple(){ setTitle("simple"); setSize(300, 200); addWindowListener(new WindowAdapter(){ public void windowClosing( (1) ){ System.exit(0); } }); Container contentPane=getContentPane(); JPanel p= (2) ; p.setLayout(new GridLayout(3, 2)); p.add(redLabel=new JLabel("Red 0")); p.add(red=new JScrollBar(Adjustable. HORIZONTAL, 0, 0, 0, 255)); red.setBlocklncrement(16); red.addAdjustmentListener(this); p.add(greenLabel= (3) ("Green 0")); p.add(green=new JScrollBar(Adjustable.HORIZONTAL 0, 0, 0, 255)); green setBIocklncrement(16); green.addAdjustmentListener(this); p.add(blueLabel=new JLabel("Blue 0")); p.add(btue=new JScrollBar(Adjustable. HORIZONTAL, 0, 0, 0, 255)); blue,setBIocklncrement(16); blue.addAdjustmentListener(this); contentPane.add(p, "South"); colorPanet=new JPanel(); colorPanet.setBackground(new Color(0, 0, 0)); contentPane.add( (4) ,"Center"); }public void adjustmentValueChanged(AdjustmentEvent evt){ redLabel.setText("Red"+red.getValue()); greenLabel.setText("Green"+green.getValue()); blueLabel.setText("Blue"+blue.getValue()); coiorPanel.setBackground(new Color(red.getValue(), green.getValue(), blue.getValue())); colorPanel.repaint(); } public static void main(String[] args){ JFrame f= (5) ; f.show(); } private JLabel redLabel; private JLabel greenLabel; private JLabel blueLabel; private JScrollBar red; private JScroilBar green; private JScrollBar blue; private JPanel colorPanel;