激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频

操作系統課程設計報告模擬進(jìn)程調度程序(一)

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

操作系統課程設計報告模擬進(jìn)程調度程序(一)

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

操作系統課程設計報告模擬進(jìn)程調度程序(一)

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

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

二、算法設計
主要設計思想
 在主程序中,通過(guò)選擇結構,調用兩種調度算法。
 各種調度算法實(shí)現
 首先建立一個(gè)進(jìn)程類(lèi), 然后建立一個(gè)調度類(lèi),通過(guò)這個(gè)類(lèi)來(lái)執行調度算法。再建立一個(gè)鏈表,用來(lái)存放這些進(jìn)程。
 優(yōu)先權調度:在優(yōu)先權調度中,每產(chǎn)生一個(gè)進(jìn)程,程序會(huì )記錄進(jìn)程的優(yōu)先權,然后按產(chǎn)生的先后順序插入。當當前進(jìn)程結束時(shí),程序從鏈表中取出一個(gè)優(yōu)先權最高的進(jìn)程執行。
 輪轉法調度:由用戶(hù)定義一個(gè)時(shí)間片。在每個(gè)時(shí)間片中,程序執行一個(gè)進(jìn)程。當時(shí)間片結束后,程序將結束當前執行的進(jìn)程,從鏈表中調入下一個(gè)進(jìn)程,并將當前執行的進(jìn)程插入到鏈表尾部。整個(gè)鏈表相當于一個(gè)循環(huán)隊列。
 
 
三、源代碼及說(shuō)明
1優(yōu)先級調度算法源代碼
    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輪轉法調度源代碼

            '
    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

四、結果與討論
 1優(yōu)先權調度算法結果圖
 2 輪轉法的程序結果圖

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

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

【操作系統課程設計報告模擬進(jìn)程調度程序(一)】相關(guān)文章:

利用進(jìn)程間通信實(shí)現程序自我保護分析03-09

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

基于Vxworks實(shí)時(shí)操作系統的串口通信程序設計與實(shí)現03-18

I2C總線(xiàn)在uClinux操作系統下的驅動(dòng)程序設計11-22

組件機制與操作系統的實(shí)現03-18

人文導向牽動(dòng)每一個(gè)國家全面拓展進(jìn)程03-07

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

分枝結構的程序設計 (一)03-07

C語(yǔ)言程序設計 (一)12-26

激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频