Results 1 to 3 of 3

Thread: quantum time/ round robin

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Question quantum time/ round robin

    hello,

    i have a project in which i have to make a program that will calculate the total waiting time and the average waiting time of a maximum of 5 processes (or also known as process management/ process queue)

    this is my second project.. the first one i had was first come first served.. for those of you guyz who undergone a course about operating systems, im sure you would understand what im saying..

    the code below was my code on the first come first served process queue:

    Code:
    Option Explicit
    
    Dim inputs(5) As Integer
    Dim ans As Integer
    Dim a As Integer
    
    
    
    
    
    Private Sub btn_enter_Click()
    Dim wid As Integer
    
    On Error GoTo errorhandler
     If ((txt_proc.Text < 0) Or (txt_proc.Text Like 0)) Then
        MsgBox "Enter numbers greater than 0", vbCritical, "Error"
    
     Else
       
       If (a < cmb_proc.Text) Then
            inputs(a) = txt_proc.Text
            List1.AddItem ("input " & a + 1 & ": " & inputs(a))
            wid = inputs(a) * 100
            
            If (a Like 0) Then
                txt_1.Visible = True    'put if statements in each txt
                txt_1.Width = wid
                txt_1.Text = inputs(a)
           ElseIf (a Like 1) Then
                txt_2.Visible = True
                txt_2.Left = 240 + txt_1.Width
                txt_2.Width = wid
                txt_2.Text = inputs(a)
           ElseIf (a Like 2) Then
                txt_3.Visible = True
                txt_3.Left = txt_2.Left + txt_2.Width
                txt_3.Width = wid
                txt_3.Text = inputs(a)
           ElseIf (a Like 3) Then
                txt_4.Visible = True
                txt_4.Left = txt_3.Left + txt_3.Width
                txt_4.Width = wid
                txt_4.Text = inputs(a)
           ElseIf (a Like 4) Then
                txt_5.Visible = True
                txt_5.Left = txt_4.Left + txt_4.Width
                txt_5.Width = wid
                txt_5.Text = inputs(a)
           ElseIf (a Like 5) Then
                txt_6.Visible = True
                txt_6.Left = txt_5.Left + txt_5.Width
                txt_6.Width = wid
                txt_6.Text = inputs(a)
           End If
            
             a = a + 1
         If (a Like cmb_proc.Text) Then
               btn_ok.Enabled = True
               txt_proc.Enabled = False
                btn_enter.Enabled = False
                cmb_proc.Enabled = True
                calc
                cmb_proc.Text = ""
           End If
        End If
        
        txt_proc.Text = ""
        
        End If
        Exit Sub
        
    errorhandler:
        If (Err.Number = 6) Then
        MsgBox "overflow", vbInformation, "overflow"
        End If
       
       
    End Sub
        
    
    Private Sub btn_ok_Click()
    
    If (cmb_proc.Text Like "") Then
        MsgBox "Please choose number of processes.", vbCritical, "Error"
    Else
        a = 0
        btn_ok.Enabled = False
        cmb_proc.Enabled = False
        txt_proc.Enabled = True
        btn_enter.Enabled = True
        Form1.Refresh
        txt_1.Visible = False
        txt_2.Visible = False
        txt_3.Visible = False
        txt_4.Visible = False
        txt_5.Visible = False
        txt_6.Visible = False
        List1.Clear
    End If
    End Sub
    
    
    
    
    
    
    Public Sub calc()
       Dim total As Integer
       Dim ave As Integer
       Dim bars(5) As Object
       Dim p As Integer
       Dim p1 As Integer
         
        
        If (cmb_proc.Text Like 1) Then
            total = inputs(0)
       Else
         While (p < cmb_proc.Text - 1)
            For p1 = p + 1 To cmb_proc.Text - 1
                total = total + inputs(p)
            Next p1
            p = p + 1
        Wend
        
       End If
       
       ave = total / cmb_proc.Text
        MsgBox "Total waiting time is: " & total
        MsgBox "Average waiting time is: " & ave
        txt_1.Visible = True
    End Sub
    this following algorithm was my algorithm for first come first served:
    Code:
    Public Sub calc()
       Dim total As Integer
       Dim ave As Integer
       Dim bars(5) As Object
       Dim p As Integer
       Dim p1 As Integer
         
        
        If (cmb_proc.Text Like 1) Then
            total = inputs(0)
       Else
         While (p < cmb_proc.Text - 1)
            For p1 = p + 1 To cmb_proc.Text - 1
                total = total + inputs(p)
            Next p1
            p = p + 1
        Wend
        
       End If
       
       ave = total / cmb_proc.Text
        MsgBox "Total waiting time is: " & total
        MsgBox "Average waiting time is: " & ave
        txt_1.Visible = True
    End Sub

    it also has some sort of progress bar or status bar that would provide the user some visualization on the length of each process he enters..



    if theres anyone who can help me with this, please post the algorithm on how to come up with the total waiting time and average waiting time for time quantum/ round robin....

  2. #2
    New Member
    Join Date
    Nov 2011
    Location
    clarin
    Posts
    1

    Re: quantum time/ round robin

    this code is for first come first serve with total waiting time and average waiting time...

    Option Explicit
    Dim a As Integer
    Dim b As Integer
    Dim c As Integer
    Dim d As Integer
    Dim x As Integer
    Dim burstime(1000) As Double
    Dim waittime(1000) As Double
    Dim totalwtime As Double
    Dim inpro As String

    Private Sub Command1_Click()

    If Not IsNumeric(Text1.Text) Then
    MsgBox "Please enter numbers only.", vbInformation
    Text1.Text = ""
    End If

    c = Val(Text1)
    d = 0
    waittime(d) = 0

    While d <> c
    inpro = InputBox("Please input the burst time of process " & d + 1, "Burst Time")
    inpro = InputBox("Please input your name ")
    If Val(inpro) <> 0 Then
    burstime(d) = Val(inpro)
    waittime(d + 1) = waittime(d) + burstime(d)
    totalwtime = totalwtime + waittime(d)
    a = a + burstime(d)
    d = d + 1
    Else
    MsgBox "Please input a number", vbExclamation, "INVALID"
    End If
    Wend
    List1.Clear
    List1.AddItem vbCrLf
    List1.AddItem " Number of Process(es) : " & c
    List1.AddItem vbCrLf
    List1.AddItem vbCrLf
    List1.AddItem " NAME" & vbTab & "PROCESS" & vbTab & "BURST TIME" & vbTab & "WAITING TIME"
    List1.AddItem vbCrLf
    d = 0
    While d <> c
    List1.AddItem " " & d + 1 & vbTab & vbTab & " " & burstime(d) & vbTab & vbTab & " " & waittime(d)
    d = d + 1
    Wend
    List1.AddItem vbCrLf
    List1.AddItem ""
    List1.AddItem vbCrLf
    List1.AddItem " Total Waiting Time : " & totalwtime
    List1.AddItem " Average Waiting Time : " & totalwtime / c
    Text1.SetFocus


    End Sub




    could you also help me in making a program in round robin...

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: quantum time/ round robin

    Quote Originally Posted by jaycel View Post
    could you also help me in making a program in round robin...
    FYI: You have replied to a thread that is over 3 years old. May want to consider creating your own thread
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width