⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 进程调度.frm

📁 是关于CPU进程调度的模拟程序
💻 FRM
📖 第 1 页 / 共 4 页
字号:
      Begin VB.Line Line6 
         BorderColor     =   &H000000FF&
         BorderWidth     =   2
         X1              =   760
         X2              =   760
         Y1              =   2160
         Y2              =   2500
      End
      Begin VB.Line Line5 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   2
         X1              =   3110
         X2              =   3360
         Y1              =   1360
         Y2              =   1360
      End
      Begin VB.Line Line4 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   2
         X1              =   3360
         X2              =   3360
         Y1              =   850
         Y2              =   1340
      End
      Begin VB.Line Line3 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   2
         X1              =   743
         X2              =   3360
         Y1              =   850
         Y2              =   850
      End
      Begin VB.Line Line2 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   2
         X1              =   760
         X2              =   760
         Y1              =   850
         Y2              =   1800
      End
      Begin VB.Line Line1 
         BorderStyle     =   2  'Dash
         BorderWidth     =   2
         Index           =   0
         X1              =   960
         X2              =   1680
         Y1              =   1980
         Y2              =   1980
      End
      Begin VB.Label Label6 
         BackColor       =   &H8000000A&
         Caption         =   "调 度"
         Height          =   240
         Left            =   1120
         TabIndex        =   24
         Top             =   1785
         Width           =   495
      End
      Begin VB.Label Label5 
         BackColor       =   &H8000000A&
         Caption         =   "时间片总数"
         Height          =   255
         Left            =   240
         TabIndex        =   16
         Top             =   375
         Width           =   975
      End
   End
   Begin VB.Image Image6 
      Height          =   1200
      Left            =   5400
      Picture         =   "进程调度.frx":314A
      Top             =   3360
      Visible         =   0   'False
      Width           =   1440
   End
   Begin VB.Image Image5 
      Height          =   990
      Left            =   5760
      Picture         =   "进程调度.frx":35B8
      Top             =   3600
      Visible         =   0   'False
      Width           =   1080
   End
   Begin VB.Image Image4 
      Height          =   1005
      Left            =   5640
      Picture         =   "进程调度.frx":3E97
      Top             =   3480
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.Image Image3 
      Height          =   990
      Left            =   5640
      Picture         =   "进程调度.frx":4BD6
      Top             =   3600
      Visible         =   0   'False
      Width           =   1245
   End
   Begin VB.Image Image2 
      Height          =   990
      Left            =   5640
      Picture         =   "进程调度.frx":5D60
      Top             =   3600
      Visible         =   0   'False
      Width           =   1320
   End
   Begin VB.Image Image1 
      Height          =   1020
      Left            =   4440
      Picture         =   "进程调度.frx":7977
      Top             =   2640
      Width           =   1185
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim f, X As Integer
Dim T(0 To 3) As Integer
Dim S(1 To 4) As Integer
Dim i, j, m, a As Integer
Dim n, q, p As Integer
Dim max As Integer
Private Sub DTPicker1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)

End Sub

Private Sub ImageCombo1_Change()

End Sub

Private Sub Active_Timer()
Static pickbmp As Integer
If pickbmp = 0 Then
   Image1.Picture = Image2.Picture
   pickbmp = 1
ElseIf pickbmp = 1 Then
   Image1.Picture = Image3.Picture
   pickbmp = 2
ElseIf pickbmp = 2 Then
   Image1.Picture = Image4.Picture
   pickbmp = 3
ElseIf pickbmp = 3 Then
   Image1.Picture = Image5.Picture
   pickbmp = 4
ElseIf pickbmp = 4 Then
   Image1.Picture = Image6.Picture
   pickbmp = 0
End If
End Sub

Private Sub Begin_Click()
Timer1.Enabled = True
Ready.Enabled = True
Stopped.Enabled = True
Begin.Enabled = False
Create.Enabled = False
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Create_Click()
f = 0
m = 0
Text1(0) = 0
Slider1.Value = 0
CPUtimer = 0
Timer1.Enabled = False
Timer2.Enabled = True
Option1(0).Enabled = True
Option2.Enabled = True
Option3.Enabled = True
Begin.Enabled = True
Create.Enabled = True
Text8(0).Text = "P1"
Text4(0) = Int(Rnd * 5 + 1)
Text5(0) = Int(Rnd * 10 + 1)
Text6(0) = Int(Rnd * 9 + 8)
Text8(1).Text = "P2"
Text4(1) = Int(Rnd * 5 + 1)
Text5(1) = Int(Rnd * 10 + 1)
Text6(1) = Int(Rnd * 9 + 8)
Text8(2).Text = "P3"
Text4(2) = Int(Rnd * 5 + 1)
Text5(2) = Int(Rnd * 10 + 1)
Text6(2) = Int(Rnd * 9 + 8)
Text8(3).Text = "P4"
Text4(3) = Int(Rnd * 5 + 1)
Text5(3) = Int(Rnd * 10 + 1)
Text6(3) = Int(Rnd * 9 + 8)
For p = 0 To 3
T(p) = Text5(p) + 1
Next p
ProgressBar1(0).max = Text5(0) * 1000
ProgressBar1(1).max = Text5(1) * 1000
ProgressBar1(2).max = Text5(2) * 1000
ProgressBar1(3).max = Text5(3) * 1000
End Sub

Private Sub Option2_Click()
Timer3.Enabled = False
Timer2.Enabled = True
End Sub

Private Sub Option3_Click()
Timer2.Enabled = False
Timer3.Enabled = True
End Sub

Private Sub Ready_Timer()
If m < 4 Then
  For i = 0 To 3
     If CPUtimer = Text4(i) And Text2(1) = "" And Text2(0) <> Text8(i) Then
       Text2(1) = Text8(i)
       If Option3.Value = True Then
       Text3(1) = Text6(i)
       Else: Text3(1) = 10 - Text5(i)
       End If
       m = m + 1
     End If
     If CPUtimer = Text4(i) And Text2(1) <> "" And Text2(2) = "" And Text2(1) <> Text8(i) Then
       Text2(2) = Text8(i)
       If Option3.Value = True Then
       Text3(2) = Text6(i)
       Else: Text3(2) = 10 - Text5(i)
       End If
       m = m + 1
     End If
     If CPUtimer = Text4(i) And Text2(1) <> "" And Text2(2) <> "" And Text2(3) = "" And Text2(2) <> Text8(i) Then
       Text2(3) = Text8(i)
       If Option3.Value = True Then
       Text3(3) = Text6(i)
       Else: Text3(3) = 10 - Text5(i)
       End If
       m = m + 1
     End If
     If CPUtimer = Text4(i) And Text2(1) <> "" And Text2(2) <> "" And Text2(3) <> "" And Text2(4) = "" And Text2(3) <> Text8(i) Then
        Text2(4) = Text8(i)
        If Option3.Value = True Then
        Text3(4) = Text6(i)
        Else: Text3(4) = 10 - Text5(i)
        End If
        m = m + 1
     End If
  Next i
End If
End Sub

Private Sub Shift_Timer()
If Text2(1) <> "" And Text2(0) = "" Then
      Text2(0).Text = Text2(1).Text
      Text2(1).Text = ""
      Text3(6).Text = Text3(1).Text
End If
If Text2(1).Text = "" Then
    Text2(1).Text = Text2(2)
    Text3(1) = Text3(2)
    Text2(2).Text = Text2(3)
    Text3(2) = Text3(3)
    Text2(3).Text = Text2(4)
    Text3(3) = Text3(4)
    Text2(4).Text = ""
    Text3(4).Text = ""
End If
If Option2.Value = False Then
For n = 1 To 3
        If Text2(n + 1).Text <> "" And Text2(n).Text <> "" And Text3(n).Text < Text3(n + 1).Text Then
         Text3(0) = Text2(n)
         Text2(n).Text = Text2(n + 1).Text
         Text2(n + 1).Text = Text3(0)
         Text3(5) = Text3(n).Text
         Text3(n).Text = Text3(n + 1).Text
         Text3(n + 1).Text = Text3(5)
        End If
Next n
End If
End Sub
Private Sub start_Click()
Timer1.Enabled = True
Timer2.Enabled = True
Ready.Enabled = True
Timer4.Enabled = True
Stopped.Enabled = True
Start.Enabled = False
End Sub

Private Sub stopped_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer4.Enabled = False
Ready.Enabled = False
Stopped.Enabled = False
Start.Enabled = True
End Sub

Private Sub Timer1_Timer()
Slider1.Value = Slider1.Value + 2
If Slider1.Value > 63 And Text2(0) = "" Then
  CPUtimer = CPUtimer + 1
  Slider1.Value = 0
End If
End Sub

Private Sub Timer2_Timer()
If Option2.Enabled = True Or Option1(0) = True Then
 For j = 0 To 3
   If Text2(0).Text = Text8(j).Text And T(j) > 0 Then
      T(j) = T(j) - 1
      If T(j) > 0 Then
      Text1(j) = Text1(j) + 1   '已用CPU
      CPUtimer = CPUtimer + 1
      Slider1.Value = 0
      End If
   End If
   If Text2(0).Text = Text8(j).Text And T(j) = 0 And f < 4 Then
      Text2(5 + f).Text = Text2(0).Text
      Text2(0).Text = ""
      f = f + 1
      Text7(j).Text = CPUtimer.Text
      Picture1(j).Visible = True
   End If
 Next j
End If
If f = 4 Then
Timer1.Enabled = False
End If
End Sub

Private Sub Timer3_Timer()
If Option3.Enabled = True Then
   For j = 0 To 3
     If Text2(0).Text = Text8(j).Text And T(j) > 0 Then
       T(j) = T(j) - 1
       If T(j) > 0 Then
       Text1(j) = Text1(j) + 1   '已用CPU
       CPUtimer = CPUtimer + 1
       Slider1.Value = 0
       For a = 1 To 4
       If Text2(a).Text = "" Then
         Text2(a).Text = Text2(0).Text
         Text3(a) = Text3(6) - 1
         Text2(0).Text = ""
       End If
       Next a
       End If
    End If
   If Text2(0).Text = Text8(j).Text And T(j) = 0 And f < 4 Then
      Text2(5 + f).Text = Text2(0).Text
      Text2(0).Text = ""
      f = f + 1
      Text7(j).Text = CPUtimer.Text
      Picture1(j).Visible = True
   End If
   Next j
End If
If f = 4 Then
Timer1.Enabled = False
End If
End Sub

Private Sub Timer4_Timer()
If Text2(0).Text = "P1" And ProgressBar1(0).Value + 15 >= ProgressBar1(0).max Then
ProgressBar1(0).Value = ProgressBar1(0).max - 1
End If
If Text2(0).Text = "P1" And ProgressBar1(0).Value + 15 < ProgressBar1(0).max Then
ProgressBar1(0).Value = ProgressBar1(0).Value + 15
End If
If Text2(0).Text = "P2" And ProgressBar1(1).Value + 15 >= ProgressBar1(1).max Then
ProgressBar1(1).Value = ProgressBar1(1).max - 1
End If
If Text2(0).Text = "P2" And ProgressBar1(1).Value + 15 < ProgressBar1(1).max Then
ProgressBar1(1).Value = ProgressBar1(1).Value + 15
End If
If Text2(0).Text = "P3" And ProgressBar1(2).Value + 15 >= ProgressBar1(2).max Then
ProgressBar1(2).Value = ProgressBar1(2).max - 1
End If
If Text2(0).Text = "P3" And ProgressBar1(2).Value + 15 < ProgressBar1(2).max Then
ProgressBar1(2).Value = ProgressBar1(2).Value + 15
End If
If Text2(0).Text = "P4" And ProgressBar1(3).Value + 15 >= ProgressBar1(3).max Then
ProgressBar1(3).Value = ProgressBar1(3).max - 1
End If
If Text2(0).Text = "P4" And ProgressBar1(3).Value + 15 < ProgressBar1(3).max Then
ProgressBar1(3).Value = ProgressBar1(3).Value + 15
End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -