国产激情久久久久影院小草_国产91高跟丝袜_99精品视频99_三级真人片在线观看

操作系統(tǒng)課程設(shè)計報告模擬進程調(diào)度程序(一)

時間:2024-05-13 21:32:34 計算機畢業(yè)論文 我要投稿
  • 相關(guān)推薦

操作系統(tǒng)課程設(shè)計報告模擬進程調(diào)度程序(一)

此設(shè)計報告是對操作系統(tǒng)中進程調(diào)度的兩種算法,即靜態(tài)優(yōu)先權(quán)調(diào)度算法和需要時間片的轉(zhuǎn)法進行了描述,并分析了它們的工作機理。
 最高優(yōu)先權(quán)調(diào)度算法的基本思想是把CPU分配給就緒隊列中優(yōu)先權(quán)最高的進程。靜態(tài)優(yōu)先數(shù)是在創(chuàng)建進程時確定的,并在整個進程運行期間不再改變。
 簡單輪轉(zhuǎn)法的基本思想是:所有就緒進程按 FCFS排成一個隊列,總是把處理機分配給隊首的進程,各進程占用CPU的時間片相同。如果運行進程用完它的時間片后還未完成,就把它送回到就緒隊列的末尾,把處理機重新分配給隊首的進程,直至所有的進程運行完畢。
 然后用具體語言模擬了一個進程調(diào)度的程序。用戶可以自己輸入產(chǎn)生進程,然后選擇調(diào)度方式進行調(diào)度。所用的語言為VisualBasic.Net,結(jié)果顯示了調(diào)度運行過程。

操作系統(tǒng)課程設(shè)計報告模擬進程調(diào)度程序(一)

問題描述和分析 ………………………………………………   4
算法設(shè)計   ……………………………………………………   5
源代碼及說明 …………………………………………………   5
結(jié)果與分析 ………………………………………………………17
參考文獻………………………………………………………   18

一、問題描述和分析
問題描述
 CPU調(diào)度是多道程序操作系統(tǒng)的基礎(chǔ),幾乎所有計算機資源在使用前都要被調(diào)度,因此,CPU調(diào)度對于操作系統(tǒng)來說非常重要。
 假如操作系統(tǒng)中存在若干進程,這些進程,將會被按照指定的調(diào)度方式,由CPU進行調(diào)度。
 本程序,用來模擬實現(xiàn)操作系統(tǒng)中的兩種調(diào)度方法,即:優(yōu)先權(quán)調(diào)度和輪轉(zhuǎn)法調(diào)度。
 下面對四種調(diào)度方法進行描述
 優(yōu)先權(quán)調(diào)度(priority-scheduling algorithm):在這種方式下,每一個進程都有一個優(yōu)先權(quán)與其關(guān)聯(lián),具有最高優(yōu)先權(quán)的進程會被分配到CPU,具有相同優(yōu)先權(quán)的進程按FCFS順序調(diào)度。
 輪轉(zhuǎn)法(round-robin):這種調(diào)度方式是專門為分時系統(tǒng)而設(shè)計的。它類似于FCFS調(diào)度,但是增加了搶占以在進程是。定義一個較小時間單元,稱為時間量或時間片。時間片通常為10ms到100ms。為每個進程分配不超過一個時間片間隔的CPU。
分析
 根據(jù)描述確定解決方法。本程序利用VisualBasic.Net語言實現(xiàn)。首先定義一個進程的類,包括進程名、達到時間、服務(wù)時間、優(yōu)先權(quán)。再定義一個調(diào)度類,用以實現(xiàn)調(diào)度算法。
 最后在主程序中,用戶可選擇兩種調(diào)度算法,確定問題的類型。

二、算法設(shè)計
主要設(shè)計思想
 在主程序中,通過選擇結(jié)構(gòu),調(diào)用兩種調(diào)度算法。
 各種調(diào)度算法實現(xiàn)
 首先建立一個進程類, 然后建立一個調(diào)度類,通過這個類來執(zhí)行調(diào)度算法。再建立一個鏈表,用來存放這些進程。
 優(yōu)先權(quán)調(diào)度:在優(yōu)先權(quán)調(diào)度中,每產(chǎn)生一個進程,程序會記錄進程的優(yōu)先權(quán),然后按產(chǎn)生的先后順序插入。當當前進程結(jié)束時,程序從鏈表中取出一個優(yōu)先權(quán)最高的進程執(zhí)行。
 輪轉(zhuǎn)法調(diào)度:由用戶定義一個時間片。在每個時間片中,程序執(zhí)行一個進程。當時間片結(jié)束后,程序?qū)⒔Y(jié)束當前執(zhí)行的進程,從鏈表中調(diào)入下一個進程,并將當前執(zhí)行的進程插入到鏈表尾部。整個鏈表相當于一個循環(huán)隊列。
 
 
三、源代碼及說明
1優(yōu)先級調(diào)度算法源代碼
    Dim a As Integer
    Dim b As Integer
    Dim c As Integer
    Dim d As Integer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label7.Width < 200 Then
            Label7.Visible = True
            Label7.Width += 10

            Label17.Visible = True
            Label16.Visible = False
            Label18.Visible = False

        Else
            Label17.Visible = False
            Label18.Visible = False
            Label16.Visible = True
            a = 6

        End If

        If a < b And a < c And a < d Then

            Timer1.Enabled = True

        End If

        If b < a And b < c And b < d Then

            Timer2.Enabled = True


        End If

        If c < a And c < b And c < d Then

            Timer3.Enabled = True


        End If

        If d < a And d < b And d < c Then

            Timer4.Enabled = True

        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If Label8.Width < 200 Then
            Label8.Visible = True
            Label8.Width += 10

            Label20.Visible = True
            Label19.Visible = False
            Label21.Visible = False

        Else
            Label20.Visible = False
            Label21.Visible = False
            Label19.Visible = True
            b = 7

        End If

        If a < b And a < c And a < d Then

            Timer1.Enabled = True

        End If

        If b < a And b < c And b < d Then

            Timer2.Enabled = True


        End If

        If c < a And c < b And c < d Then

            Timer3.Enabled = True


        End If

        If d < a And d < b And d < c Then

            Timer4.Enabled = True

        End If
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        If Label9.Width < 200 Then
            Label9.Visible = True
            Label9.Width += 10

            Label23.Visible = True
            Label22.Visible = False
            Label24.Visible = False

        Else
            Label23.Visible = False
            Label24.Visible = False
            Label22.Visible = True
            c = 8

        End If

        If a < b And a < c And a < d Then

            Timer1.Enabled = True

        End If

        If b < a And b < c And b < d Then

            Timer2.Enabled = True


        End If

        If c < a And c < b And c < d Then

            Timer3.Enabled = True


        End If

        If d < a And d < b And d < c Then

            Timer4.Enabled = True

        End If
    End Sub

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        If Label10.Width < 200 Then
            Label10.Visible = True
            Label10.Width += 10

            Label26.Visible = True
            Label25.Visible = False
            Label27.Visible = False

        Else
            Label26.Visible = False
            Label27.Visible = False
            Label25.Visible = True
            d = 9

        End If

        If a < b And a < c And a < d Then

            Timer1.Enabled = True

        End If

        If b < a And b < c And b < d Then

            Timer2.Enabled = True


        End If

        If c < a And c < b And c < d Then

            Timer3.Enabled =True


        End If

        If d < a And d < b And d < c Then

            Timer4.Enabled = True

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        a = TextBox1.Text
        b = TextBox2.Text
        c = TextBox3.Text
        d = TextBox4.Text

 


        If a < b And a < c And a < d Then

            Timer1.Enabled = True

        End If

        If b < a And b < c And b < d Then

            Timer2.Enabled = True


        End If

        If c < a And c < b And c < d Then

            Timer3.Enabled = True


        End If

        If d < a And d < b And d < c Then

            Timer4.Enabled = True

        End If
        TextBox1.Enabled = False
        TextBox2.Enabled = False
        TextBox3.Enabled = False
        TextBox4.Enabled = False

        Button1.Enabled = False
        Button2.Enabled = True

        Label18.Visible = True
        Label21.Visible = True
        Label24.Visible = True
        Label27.Visible = True
    End Sub
End Class

 

 

2輪轉(zhuǎn)法調(diào)度源代碼

            '
    Dim a As Integer
    Dim b As Integer
    Dim c As Integer
    Dim d As Integer
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        a = TextBox1.Text
        b = TextBox2.Text
        c = TextBox3.Text
        d = TextBox4.Text
       
        If a > 0 And b > 0 And c > 0 And d > 0 Then
            Timer1.Enabled() = True
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim i As Integer
        i = a - Label7.Width
        If i < 20 Then
            Label7.Width = Label7.Width + i

            Label18.Visible = False
            Label17.Visible = False
            Label16.Visible = True

            Timer1.Enabled = False
            Timer2.Enabled = True
        End If

        If Label7.Width < a Then

            Label7.Width = Label7.Width + 10

            Label18.Visible = True
            Label17.Visible = False
            Label16.Visible = False

            Timer1.Enabled = False
            Timer2.Enabled = True
        Else

            Label18.Visible = False
            Label17.Visible = False
            Label16.Visible = True

            Timer1.Enabled = False
            Timer2.Enabled = True

        End If

        If Label8.Width >= b Then
            Label21.Visible = False
            Label20.Visible = False
            Label19.Visible = True
        Else
            Label21.Visible = False
            Label20.Visible = True
            Label19.Visible = False
        End If

        If Label7.Width < a And Label8.Width >= b And Label9.Width >= c And Label10.Width >= d Then
            Label18.Visible = False
            Label17.Visible = True
            Label16.Visible = False
        ElseIf Label29.Width = a Then
            Label18.Visible = False
            Label17.Visible = False
            Label16.Visible = True

        End If

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim i As Integer
        i = b - Label8.Width
        If i < 20 Then
            Label8.Width += i

            Label21.Visible = False
            Label20.Visible = False
            Label19.Visible = True

            Timer2.Enabled = False
            Timer3.Enabled = True
        End If

        If Label8.Width < b Then
            Label8.Width += 10

            Label21.Visible = True
            Label20.Visible = False
            Label19.Visible = False

            Timer2.Enabled = False
            Timer3.Enabled = True
        Else
            Label21.Visible = False
            Label20.Visible = False
            Label19.Visible = True

            Timer2.Enabled = False
            Timer3.Enabled = True
        End If

        If Label9.Width >= c Then
            Label24.Visible = False
            Label23.Visible = False
            Label22.Visible = True
        Else
            Label24.Visible = False
            Label23.Visible = True
            Label22.Visible = False
        End If

        If Label8.Width < b And Label7.Width >= a And Label9.Width >= c And Label10.Width >= d Then
            Label21.Visible = False
            Label20.Visible = True
            Label19.Visible = False
        ElseIf Label8.Width = b Then
            Label21.Visible = False
            Label20.Visible = False
            Label19.Visible = True

        End If
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Dim i As Integer
        i = c - Label9.Width
        If i < 20 Then
            Label9.Width += i

            Label24.Visible = False
            Label23.Visible = False
            Label22.Visible = True

            Timer3.Enabled = False
            Timer4.Enabled = True
        End If

        If Label9.Width < c Then
            Label9.Width += 10

            Label24.Visible = True
            Label23.Visible = False
            Label22.Visible = False

            Timer3.Enabled = False
            Timer4.Enabled = True
        Else
       &nbnbsp;     Label27.Visible = True
            Label26.Visible = False
            Label25.Visible = False

 

            Timer4.Enabled = False
            Timer1.Enabled = True
        Else
            Label27.Visible = False
            Label26.Visible = False
            Label25.Visible = True

            Timer4.Enabled = False
            Timer1.Enabled = True
        End If

        If Label7.Width >= a Then
            Label18.Visible = False
            Label17.Visible = False
            Label16.Visible = True
        Else
            Label18.Visible = False
            Label17.Visible = True
            Label16.Visible = False
        End If

        If Label10.Width < d And Label7.Width >= a And Label8.Width >= b And Label9.Width >= c Then
            Label27.Visible = False
            Label26.Visible = True
            Label25.Visible = False
        ElseIf Label10.Width = d Then
            Label27.Visible = False
            Label26.Visible = False
            Label25.Visible = True

        End If
    End Sub

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

四、結(jié)果與討論
 1優(yōu)先權(quán)調(diào)度算法結(jié)果圖
 2 輪轉(zhuǎn)法的程序結(jié)果圖

5.結(jié)果分析:
     經(jīng)選擇調(diào)度算法后,每種調(diào)度算法都能成功地執(zhí)行。所以,本次課程設(shè)計成功。            五、參考文獻

1、《Windows操作系統(tǒng)原理》  陳向群等著 機械工業(yè)出版社
2、《VisualBasic.Net程序設(shè)計》馮博琴 崔舒寧著 清華大學(xué)出版社
3、《操作系統(tǒng) 原理·技術(shù)與編程》  蔣靜, 徐志偉著 機械工業(yè)出版社

【操作系統(tǒng)課程設(shè)計報告模擬進程調(diào)度程序(一)】相關(guān)文章:

利用進程間通信實現(xiàn)程序自我保護分析03-09

基于μC/OS-II操作系統(tǒng)的任務(wù)調(diào)度機制03-04

基于Vxworks實時操作系統(tǒng)的串口通信程序設(shè)計與實現(xiàn)03-18

I2C總線在uClinux操作系統(tǒng)下的驅(qū)動程序設(shè)計11-22

組件機制與操作系統(tǒng)的實現(xiàn)03-18

人文導(dǎo)向牽動每一個國家全面拓展進程03-07

哈姆雷特:現(xiàn)代化進程的祭品03-08

分枝結(jié)構(gòu)的程序設(shè)計 (一)03-07

C語言程序設(shè)計 (一)12-26