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

📄 form1.frm

📁 操作系统课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5310
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6975
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5310
   ScaleWidth      =   6975
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer3 
      Left            =   6360
      Top             =   3960
   End
   Begin VB.CommandButton Command4 
      Caption         =   "再生产"
      Height          =   375
      Left            =   480
      TabIndex        =   22
      Top             =   840
      Width           =   975
   End
   Begin VB.Timer Timer2 
      Left            =   5760
      Top             =   3960
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出"
      Height          =   375
      Left            =   5880
      TabIndex        =   21
      Top             =   4440
      Width           =   975
   End
   Begin VB.Timer Timer1 
      Left            =   5160
      Top             =   3960
   End
   Begin VB.CommandButton Command2 
      Caption         =   "消费"
      Height          =   375
      Left            =   5640
      TabIndex        =   6
      Top             =   840
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "生产"
      Height          =   375
      Left            =   480
      TabIndex        =   3
      Top             =   840
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Caption         =   "缓冲池"
      Height          =   2895
      Left            =   2040
      TabIndex        =   0
      Top             =   720
      Width           =   3015
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   5
         Left            =   2160
         TabIndex        =   15
         Top             =   1800
         Width           =   615
      End
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   4
         Left            =   1200
         TabIndex        =   14
         Top             =   1800
         Width           =   615
      End
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   3
         Left            =   240
         TabIndex        =   13
         Top             =   1800
         Width           =   615
      End
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   2
         Left            =   2160
         TabIndex        =   12
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   1
         Left            =   1200
         TabIndex        =   11
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label1 
         BackColor       =   &H000000FF&
         Height          =   615
         Index           =   0
         Left            =   240
         TabIndex        =   1
         Top             =   720
         Width           =   615
      End
   End
   Begin VB.Label Label6 
      BackColor       =   &H00FF00FF&
      Height          =   495
      Left            =   4800
      TabIndex        =   20
      Top             =   4200
      Width           =   855
   End
   Begin VB.Label Label5 
      Caption         =   "互斥"
      Height          =   255
      Left            =   4680
      TabIndex        =   19
      Top             =   3840
      Width           =   615
   End
   Begin VB.Line Line3 
      X1              =   5040
      X2              =   5640
      Y1              =   2160
      Y2              =   2160
   End
   Begin VB.Label Label4 
      Caption         =   "满缓冲池"
      Height          =   255
      Left            =   2880
      TabIndex        =   18
      Top             =   3840
      Width           =   735
   End
   Begin VB.Label Label3 
      Caption         =   "空缓冲池"
      Height          =   255
      Left            =   1200
      TabIndex        =   17
      Top             =   3840
      Width           =   735
   End
   Begin VB.Label Label2 
      BackColor       =   &H00FF00FF&
      Height          =   495
      Left            =   1440
      TabIndex        =   16
      Top             =   4200
      Width           =   855
   End
   Begin VB.Line Line2 
      X1              =   960
      X2              =   960
      Y1              =   1200
      Y2              =   1920
   End
   Begin VB.Line Line1 
      X1              =   1320
      X2              =   2040
      Y1              =   2160
      Y2              =   2160
   End
   Begin VB.Label Label14 
      Height          =   615
      Left            =   5520
      TabIndex        =   10
      Top             =   2880
      Width           =   1095
   End
   Begin VB.Label Label9 
      BackColor       =   &H00C0C0C0&
      Height          =   615
      Left            =   5640
      TabIndex        =   9
      Top             =   1920
      Width           =   615
   End
   Begin VB.Label Label8 
      BackColor       =   &H00FF00FF&
      Height          =   495
      Left            =   3120
      TabIndex        =   8
      Top             =   4200
      Width           =   855
   End
   Begin VB.Label Label13 
      Height          =   615
      Left            =   480
      TabIndex        =   7
      Top             =   2880
      Width           =   1095
   End
   Begin VB.Label Label12 
      Caption         =   "消费者"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5760
      TabIndex        =   5
      Top             =   360
      Width           =   735
   End
   Begin VB.Label Label11 
      BackColor       =   &H00C0C0C0&
      Height          =   615
      Left            =   720
      TabIndex        =   4
      Top             =   1920
      Width           =   615
   End
   Begin VB.Label Label10 
      Caption         =   "生产者"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   600
      TabIndex        =   2
      Top             =   360
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, k, a As Integer
Dim full As Integer
Dim emputy As Integer

Private Sub Command1_Click()              '生产按钮
  Line2.Visible = True
  Label11.BackColor = &HFF00&
  Label6.Caption = 1
  Label6.FontSize = 16
  Label13.Caption = "生产者生产了一个产品,申请一个缓冲池"
  Timer1.Interval = 1500
  Line1.Visible = True
End Sub

Private Sub Command2_Click()              '消费按钮
  Command4.Visible = True
If Label6.Caption = "1" Then              '判断缓冲池是否为空
    If Label8.Caption = "" Then
      MsgBox "没有产品可以消费", , "提示"
    End If
    MsgBox "互斥!不能消费!", , "提示"
 Else
   Timer2.Interval = 1500                 '时钟控件开始
   Line3.Visible = True
   Label6.Caption = 1
   Label6.FontSize = 16
   Label14.Caption = "消费者消费了一个产品"
   Label9.BackColor = &HC0C0C0
End If

End Sub

Private Sub Command3_Click()
   End
'退出按钮
End Sub

Private Sub Command4_Click()
    '再生产按钮
  Line1.Visible = True
  Line2.Visible = True
  Label11.BackColor = &HFF00&
  Label13.Caption = "生产者生产了一个产品,申请一个缓冲池"
     '平判断缓冲池是否满
  If Val(Label8.Caption) < 6 Then
     Timer3.Interval = 1500
     If Label1(a).BackColor = &HFF& Then
       Line2.Visible = True
       Label6.Caption = 1
       Label6.FontSize = 16
       Label14.Caption = "消费者消费了一个产品"
       Label9.BackColor = &HC0C0C0
       End If
    Else
      '提示
     MsgBox "缓冲池已满", , "提示"
      a = 0
      j = 0
 End If
 
End Sub

Private Sub Form_Load()
  full = 0
  emputy = 6
  Command4.Visible = False
  Line1.Visible = False
  Line2.Visible = False
  Line3.Visible = False
  Timer1.Interval = 0
  Timer2.Interval = 0
  Label2.Caption = 6
  Label2.FontSize = 16
End Sub
   '生产过程中的时钟控件
Private Sub Timer1_Timer()
  Label11.BackColor = &HC0C0C0
If i > 5 Then
    '判断缓冲池是否满
  MsgBox "缓冲池已满", , "提示"
  Label6.Caption = "0"
  Timer1.Interval = 0
  Label11.BackColor = &HFF00&
   Else
       '不满进行生产
     emputy = emputy - 1
     full = full + 1
     Label1(i).BackColor = &HFF00&
     Label6.Caption = 0
     Label2.Caption = emputy
     Label8.Caption = full
     Label2.FontSize = 16
     Label8.FontSize = 16
     i = i + 1
     Line1.Visible = False
     Line2.Visible = False
     Label13.Caption = ""
     Timer1.Interval = 0
     
End If
End Sub
   '消费过程的时钟控件
Private Sub Timer2_Timer()
 Label9.BackColor = &HFF00&
  If Val(Label8.Caption) = 0 Then
        '缓冲池是否空
     MsgBox "没有产品可供消费", , "提示"
     Label6.Caption = 0
     Line3.Visible = False
     Label9.BackColor = &H8000000F
     Label14.Caption = ""
     Timer2.Interval = 0
    Else
        '不空进行消费
       emputy = emputy + 1
       full = full - 1
       Label1(j).BackColor = &HFF&
       j = j + 1
       Label14.Caption = ""
       Label6.Caption = 0
       Label2.Caption = emputy
       Label8.Caption = full
       Timer2.Interval = 0
       
    End If
   
End Sub
   '再生产过程的时钟控件
Private Sub Timer3_Timer()
  Label11.BackColor = &HC0C0C0
  Line1.Visible = True
       '当前操作的缓冲池后面的缓冲池是否为空,不空指针后移
    If Label1(a).BackColor = &HFF00& Then
     a = a + 1
      If Label1(a).BackColor = &HFF00& Then
       a = a + 1
       If Label1(a).BackColor = &HFF00& Then
        a = a + 1
         If Label1(a).BackColor = &HFF00& Then
          a = a + 1
          End If
        End If
       End If
     Label1(a).BackColor = &HFF00&
      a = a + 1
      emputy = emputy - 1
      full = full + 1
      Else
       Label1(a).BackColor = &HFF00&
       a = a + 1
       emputy = emputy - 1
       full = full + 1
    End If
     k = a
     Label6.Caption = 0
     Label2.Caption = emputy
     Label8.Caption = full
     Line2.Visible = False
     Label13.Caption = ""
     Timer3.Interval = 0
     Line1.Visible = False
End Sub

⌨️ 快捷键说明

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