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

📄 form1.frm

📁 操作系统课程设计生产者-消费者模拟算法。(我上传的为几种不同的算法,我这里还有好多
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   6360
      TabIndex        =   12
      Top             =   3720
      Width           =   495
   End
   Begin VB.Label labmutex 
      BackColor       =   &H00FFC0FF&
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   6360
      TabIndex        =   11
      Top             =   3000
      Width           =   495
   End
   Begin VB.Label labelshow 
      BackColor       =   &H0080C0FF&
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "幼圆"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   615
      Left            =   2880
      TabIndex        =   10
      Top             =   6480
      Width           =   6135
   End
   Begin VB.Label Label4 
      BackColor       =   &H00FFC0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "empty="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5280
      TabIndex        =   9
      Top             =   4320
      Width           =   1095
   End
   Begin VB.Label Label3 
      BackColor       =   &H00FFC0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "full ="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5280
      TabIndex        =   8
      Top             =   3720
      Width           =   1215
   End
   Begin VB.Label Label2 
      BackColor       =   &H00FFC0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "mutex="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5280
      TabIndex        =   7
      Top             =   3000
      Width           =   1215
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   7
      Left            =   8040
      TabIndex        =   6
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   6
      Left            =   6855
      TabIndex        =   5
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   5
      Left            =   5760
      TabIndex        =   4
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   4
      Left            =   4560
      TabIndex        =   3
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   3
      Left            =   3360
      TabIndex        =   2
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      Height          =   975
      Index           =   2
      Left            =   2145
      TabIndex        =   1
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFC0C0&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H00000000&
      Height          =   975
      Index           =   1
      Left            =   960
      TabIndex        =   0
      Top             =   1560
      Width           =   975
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mutex As Integer
Dim full As Integer
Dim emputy As Integer
Dim count1 As Integer
Dim i As Integer
Dim bool1 As Boolean
Dim bool As Boolean

Private Sub Command1_Click()
End
End Sub

Private Sub Command2_Click()


If bool1 Then
Label7.Visible = True
Label8.Visible = True
bool1 = False

Else
Label7.Visible = False
Label8.Visible = False
bool1 = True

End If
End Sub

Private Sub consumer_Click()
If full > 0 Then
If mutex = 1 Then
  mutex = 0
  
  labmutex.Caption = "0"
  timer_consumer.Enabled = True
Else: MsgBox "缓冲区正被占用,请等待...............  ", 5 + vbExclamation, "信息提示"
End If
Else: MsgBox "已无可用缓冲区供消费!", 5 + vbExclamation, "信息提示"
End If
End Sub

Private Sub Form_Load()
mutex = 1
full = 0
emputy = 7
count1 = 0
i = 0
Form2.Hide

End Sub

Private Sub producer_Click()
count1 = count1 + 1
If emputy > 0 Then
If mutex = 1 Then
  mutex = 0
  labmutex.Caption = "0"
  timer_production.Enabled = True
Else:
count1 = count1 - 1

MsgBox "缓冲区正被占用,请等待...............", 7 + vbExclamation, "信息提示"
    
      'count1 = count1 - 1
      
End If
Else: MsgBox "已无可用缓冲区供存入!", 7 + vbExclamation, "信息提示"
      count1 = count1 - 1
End If
End Sub

Private Sub timer_production_Timer()
  If bool Then
    Picture1(count1).Visible = True
     labelshow.Caption = "生产者进程正在占用缓冲区,请等待..............."
   bool = False
     Else
    Picture1(count1).Visible = False
 
   labelshow.Caption = "生产者进程正在占用缓冲区,请等待..............."
   bool = True

  End If
  i = i + 1
  If i = 7 Then
  i = 0
    timer_production.Enabled = False
  mutex = 1
   labmutex.Caption = "1"
      Picture1(count1).Visible = True
  full = full + 1
  labfull.Caption = Str(full)
 
    emputy = emputy - 1
  labemputy.Caption = Str(emputy)
  labelshow.Caption = "  Ready  "
  End If
End Sub

Private Sub timer_consumer_timer()
If bool Then
 Label1(count1).BackColor = &HFF00&
 
 
   labelshow.Caption = "消费者进程正在占用缓冲区,请等待..............."
   bool = False
     Else
 Label1(count1).BackColor = &H8000000F
  Picture1(count1).Visible = False
     labelshow.Caption = "消费者进程正在占用缓冲区,请等待...............    "
   bool = True
  End If
  i = i + 1
  If i = 7 Then
  i = 0
   timer_consumer.Enabled = False
     mutex = 1
   labmutex.Caption = "1"
     Label1(count1).BackColor = &H8000000F
   Picture1(count1).Visible = False
    count1 = count1 - 1
  full = full - 1
  labfull.Caption = Str(full)
  emputy = emputy + 1
  labemputy.Caption = Str(emputy)
  labelshow.Caption = "  Ready  "
  End If
End Sub

⌨️ 快捷键说明

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