Demo entry 6737050

CS1504

   

Submitted by anonymous on Apr 29, 2018 at 06:17
Language: C#. Code size: 29.1 kB.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using System.Text;
public class PCB
{
    public int PID;
    public int TIME;
    public int PRI;
    public string STA;
    public int neicun;
    

    public PCB(int PID, int TIME, int PRI, string STA,int neicun)
    {
        this.PID = PID;
        this.TIME = TIME;
        this.PRI = PRI;
        this.STA = STA;
        this.neicun = neicun;
    }

    
}
public class memory
{
    public string pid;
    public int neicun;
    public bool state;
    public memory(string pid,int neicun,bool state)
    {
        this.pid = pid;
        this.neicun = neicun;
        this.state = state;
    }
}
public class Node
{
    public memory Element;
    public Node Flink;
    public Node Blink;
    public Node()
    {
        Element = null;
        Flink = null;
        Blink = null;
    }
    public Node(memory theElement)
    {
        Element = theElement;
        Flink = null;
        Blink = null;

    }

   
}
public class Linkedlist
{
    public Node head;
    public Linkedlist()
    {
        head = null;
    }
    public int Count()
    {
     
        Node p = head;
        int count = 0; 
                      
        while (p != null)
        {
            count++;
            p = p.Flink;
        }
        return count;
    }
    public memory GetElem(int i)
    { 
        Node p = head;
        int k = 0;//计数器   

        //如果i大于链表的长度或i小于0,则报出异常  
        if (i >= Count() || i < 0)
        {
            throw new Exception("Error");
        }



        //如果i大于0且小于链表长度,则遍历链表直到第i个节点为止  
        while (k < i)
        {
            k++;
            p = p.Flink;
        }
        return p.Element;
    }
    public Node Find(memory item)
    {
        Node current = new Node();
        current = head;
        while (current.Element.pid != item.pid)
        { current = current.Flink; }
        return current;
    }
    public void insert(memory newitem, memory after)
    {
        Node current = new Node();
        Node newNode = new Node(newitem);
        current = Find(after);
        newNode.Flink = current.Flink;
        newNode.Blink = current;
        current.Flink.Blink = newNode;
        current.Flink = newNode;

    }
    public Node FindPrevious(memory n)
    {
        Node current = head;
        while (!(current.Flink == null) && (current.Flink.Element != n))
        {
            current = current.Flink;
        }
        return current;
    }
    public void Remove(memory n)
    {
        Node p = Find(n);
        if (p.Flink != null && p.Blink != null)
        {
            p.Blink.Flink = p.Flink;
            p.Flink.Blink = p.Blink;
            p.Flink = null;
            p.Blink = null;
            p = null;

        }
        else if(p.Blink==null)
        {
            head = p.Flink;
            head.Flink = p.Flink.Flink;
            head.Blink = null;

        }

    }
    public void modify(memory n)
    {
        Node m=Find(n);
        m.Element.state = false;
       
       
    }
    public void insert(memory e, int i)
    {

        Node p = new Node(e); 
        Node q = head;
        int k = 0;   
        if (i >= Count() || i < 0)
        {
            System.Console.WriteLine("Error");
            return;
        }

        //如果在链表头插入,移动头指针  
        if (i == 0)
        {
            p.Flink = head;
            head = p;
            return;
        }

        
        while (k < i-1 )
        {
            k++;
            q = q.Flink;
        }
        //把新节点插入在第i个节点的位置  

        p.Flink = q.Flink;
        p.Blink = q;
        q.Flink.Blink = p;
        q.Flink = p;
    }
    public void Add(memory e)

    {

        Node p = new Node(e); 


        Node q = new Node(); 
        if (head == null)

        {

            head = p;

            return;

        }
        q = head;
        while (q.Flink != null)

        {

            q = q.Flink;

        }

        //在链表尾插入新节点  
        q.Flink = p;
        p.Blink = q;

    }
    public int usememory()
    {
        Node p = head;
        int sum = 0;

        while (p != null)
        {
            sum += p.Element.neicun;
            p = p.Flink;
        }
        return sum;
    }
    public int getstart(memory n)
    {
        int sum = 0;
        Node current = new Node();
        current = head;
        while (current.Element != n)
        {
            sum += (current.Element.neicun+1);
            current = current.Flink;
        }
        return sum;
        }

}

public class data : MonoBehaviour {
    public Text houbei;
    public Text jiuxu;
    public Text running;
    public Text finish;
    public Text block;
    public Text hang;
    public Text nc;
    public Text error;
    public Text jherror;
    public Text gqerror;
    public Text jgerror;
    public Slider speed;
    private static string tehb;
    private static string tejx;
    private static string tefh;
    private static string tebl;
    private static string tegq;
    private static string tenc;
    public InputField jinchengming;
    public InputField yunxingshijian;
    public InputField youxianquan;
    public InputField jihuojincheng;
    public InputField guaqijincheng;
    public InputField jieguajincheng;
    public InputField neicundaxiao;
    private String jincheng;
    private String prior;
    private String time;
    private String neicun;
    public static int pid=1;
    public static Queue<PCB> hbqueue = new Queue<PCB>();
    public static Queue<PCB> jxqueue = new Queue<PCB>();
    public static Queue<PCB> finishqueue = new Queue<PCB>();
    public static Queue<PCB> blockqueue = new Queue<PCB>();
    public static Queue<PCB> bkhangqueue = new Queue<PCB>();
    public static Queue<PCB> jxhangqueue = new Queue<PCB>();
    public static Queue<PCB> jlqueue = new Queue<PCB>();
    public static Linkedlist nclinklist = new Linkedlist();
    public PCB m;
    public int neicunsum = 3000;
    public float spee=1.0f;
   
    public bool insertjx(PCB t1, Linkedlist t)
    {   Node zc=new Node();
        bool gg = false;
        for (zc = t.head; zc != null;)
        {
            if (zc.Element.state == false && t1.neicun <= zc.Element.neicun)
            {
                gg = true;
                break;
            }
            zc = zc.Flink;
        }
        
            
        
        if (gg)
        {
            memory zc2=new memory(Convert.ToString(t1.PID),t1.neicun,true);
            nclinklist.insert(zc2,zc.Element);
            if ((zc.Element.neicun - zc2.neicun) != 0)
            { nclinklist.insert(new memory(Convert.ToString(t1.PID), zc.Element.neicun - zc2.neicun, false), zc2);


            }
            nclinklist.Remove(zc.Element);
            return true;
        }
        else if (t1.neicun <= (3000 - nclinklist.usememory()))
        {   
            memory zcm = new memory(Convert.ToString(t1.PID), t1.neicun, true);
            nclinklist.Add(zcm);
            return true;

        }
       
        else
            return false;
    }
    public void hbneicun(Linkedlist m)
    {   Node zc = m.head;
        while (zc != null)
        {
            if (zc.Flink != null && zc.Flink.Element.state == false && zc.Element.state == false)
            {
                zc.Element.neicun = zc.Element.neicun + zc.Flink.Element.neicun;
                m.Remove(zc.Flink.Element);
            }
            zc = zc.Flink;
        }
        bianli3(nclinklist, tenc, nc);
    }
    public  void bianli(Queue<PCB> atm,string te,Text TE)
    {
        te = "";
        foreach (PCB a in atm)
        {
            if (a.PID < 10)
            { te += a.PID + "            " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n"; }
            else
            {
                te += a.PID + "          " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n";
            }
        }
         TE .text = te;
    }
    public void bianli2(Queue<PCB> atm1, Queue<PCB> atm2, string te, Text TE)
    {
        te = "";
        foreach(PCB a in atm1)
        {
            if (a.PID < 10)
            { te += a.PID + "            " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n"; }
            else
            {
                te += a.PID + "          " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n";
            }
        }
        foreach (PCB a in atm2)
        {
            if (a.PID < 10)
            { te += a.PID + "            " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n"; }
            else
            {
                te += a.PID + "          " + a.TIME + "            " + a.PRI + "          " + a.STA + "\n";
            }
        }
        TE.text = te;
    }
    public void bianli3(Linkedlist m, string te, Text TE)
    {
        te = "";
        Node a = m.head;
      while(a!=null)
        {  if (a.Element.state == false)
            {
                a.Element.pid = null;
            }
            if (a.Flink == null && a.Element.state == false)
            {
                break;
            }
            if (a.Element.pid == null)
            {
                if (nclinklist.getstart(a.Element) == 0)
                { te += a.Element.pid + "         " + nclinklist.getstart(a.Element) + "         " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n"; }
                else if ((nclinklist.getstart(a.Element)) >= 1000 && (nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "        " + nclinklist.getstart(a.Element) + "   " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "  " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else if ((nclinklist.getstart(a.Element)) >= 1000)
                {
                    te += a.Element.pid + "        " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + " " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else if ((nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "        " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else
                { te += a.Element.pid + "        " + nclinklist.getstart(a.Element) + "     " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "    " + a.Element.neicun + "   " + a.Element.state + "\n"; }
            }
           else if (Convert.ToInt32(a.Element.pid) < 10)
            {

                if (nclinklist.getstart(a.Element) == 0)
                { te += a.Element.pid + "        " + nclinklist.getstart(a.Element) + "         " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n"; }
                else if ((nclinklist.getstart(a.Element)) >= 1000 && (nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "       " + nclinklist.getstart(a.Element) + "   " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "  " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else if ((nclinklist.getstart(a.Element)) >= 1000)
                {
                    te += a.Element.pid + "       " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + " " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else if ((nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "       " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else
                {
                    te += a.Element.pid + "       " + nclinklist.getstart(a.Element) + "     " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "    " + a.Element.neicun + "   " + a.Element.state + "\n";
                }

            }
            else
            {
                if (nclinklist.getstart(a.Element) == 0)
                { te += a.Element.pid + "     " + nclinklist.getstart(a.Element) + "         " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n"; }
                else if ((nclinklist.getstart(a.Element)) >= 1000 && (nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "     " + nclinklist.getstart(a.Element) + "   " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "  " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else if ((nclinklist.getstart(a.Element)) >= 1000)
                {
                    te += a.Element.pid + "     " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + " " + a.Element.neicun + "   " + a.Element.state + "\n";
                } 
                else if ((nclinklist.getstart(a.Element) + a.Element.neicun) >= 1000)
                {
                    te += a.Element.pid + "     " + nclinklist.getstart(a.Element) + "    " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "   " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
                else
                {
                    te += a.Element.pid + "     " + nclinklist.getstart(a.Element) + "     " + (nclinklist.getstart(a.Element) + a.Element.neicun) + "    " + a.Element.neicun + "   " + a.Element.state + "\n";
                }
            }

            a = a.Flink;
        }
        TE.text = te;

    }
    public PCB findlastpri(Queue<PCB> atm)
    {
        PCB last = atm.Peek();
        foreach (PCB r in atm)
        {
            if (last.PRI > r.PRI)
            {
                last = r;
            }
        }
        return last;

    }
    public void delete(Queue<PCB> atm,PCB dele)
    { PCB[] delet = new PCB[20];
        for (int i = 0; atm.Count != 0; i++)
        {
            if (dele != atm.Peek())
            {
                delet[i] = atm.Dequeue();
            }
            else
            {
                atm.Dequeue();
                i--;
            }
        }
        for (int i = 0; delet[i] != null; i++)
        {
            atm.Enqueue(delet[i]);
        }

    }
    public static void ini()
    {
       
   
        for (int i = 1; i <= 5; i++)
        {
            PCB ran;
            if (hbqueue.Count < 5)
            {
                ran=new PCB(pid++, UnityEngine.Random.Range(1, 10), UnityEngine.Random.Range(1, 10), "后备", UnityEngine.Random.Range(100, 500));
                hbqueue.Enqueue(ran);
                jlqueue.Enqueue(ran);
}

        }


    }
    public void add2()
    {
        bool isrepeat = false;
         foreach (PCB r in jlqueue)
        {
            if (r.PID == Convert.ToInt32(jincheng)) { isrepeat = true; }
        }
        for (int i = 1; i <= 5; i++)
        {
            PCB ran;
            if (hbqueue.Count < 25)
            {
                foreach (PCB r in jlqueue)
                {
                    if (r.PID == pid) { isrepeat = true;break; }
                    else { isrepeat = false; }
                }
                if (!isrepeat)
                {
                    ran = new PCB(pid++, UnityEngine.Random.Range(1, 10), UnityEngine.Random.Range(1, 10), "后备", UnityEngine.Random.Range(100, 500));
                    hbqueue.Enqueue(ran);
                    jlqueue.Enqueue(ran);
                }
                else
                {
                    pid++;
                }
            }

        }
        paixu2(hbqueue);
        bianli(hbqueue, tehb, houbei);

    }
    public  void run()
    {
       
        if (m == null&& jxqueue.Count!=0)
        {
            m = jxqueue.Dequeue();
            m.STA = "运行";
            running.text = m.PID + "             " + m.TIME + "             " + m.PRI + "           " + m.STA + "\n";
            paixu(jxqueue);
            bianli(jxqueue, tejx, jiuxu);
        }
        if (jxqueue.Count!=0&&m.PRI < jxqueue.Peek().PRI)
        {
            PCB m1;
            m.STA = "就绪";
            m1 = jxqueue.Dequeue();
            jxqueue.Enqueue(m);
            m = m1;
            m.STA = "运行";
            running.text = m.PID + "             " + m.TIME + "             " + m.PRI + "           " + m.STA + "\n";
            paixu(jxqueue);
            bianli(jxqueue, tejx, jiuxu);
        }
        if (m!=null&&m.TIME == 0)
        {
            m.STA = "完成";
            finishqueue.Enqueue(m);
            nclinklist.modify(new memory(Convert.ToString(m.PID), m.neicun, true));
            bianli3(nclinklist, tenc, nc);
            bianli(finishqueue, tefh, finish);
            m = null;
           
        }
        
        running.text = m.PID + "             " + m.TIME-- + "             " + m.PRI-- + "           " + m.STA + "\n";
        
      

       


    }
    public void add()
    {
        bool isrepeat=false;
        PCB f;
        jincheng = jinchengming.text;
        prior= youxianquan.text;
        time = yunxingshijian.text;
        neicun = neicundaxiao.text;
        foreach (PCB r in jlqueue)
        {
            if (r.PID == Convert.ToInt32(jincheng)) { isrepeat = true; }
        }
        if (Convert.ToInt32(time) <=0)
        {
            error.text = "进程运行时间不能小于等于0";
            PlayerPrefs.SetInt("error", 1);
        }
        else
        {
            if (!isrepeat)
            {
                f = new PCB(Convert.ToInt32(jincheng), Convert.ToInt32(time), Convert.ToInt32(prior), "后备",Convert.ToInt32(neicun));
                hbqueue.Enqueue(f);
                jlqueue.Enqueue(f);
                paixu2(hbqueue);
                bianli(hbqueue, tehb, houbei);
                PlayerPrefs.SetInt("error", 0);
                jinchengming.text = "";
                youxianquan.text = "";
                yunxingshijian.text="";


            }
            else
            {
                error.text = "该进程名已存在,请重新输入";
                PlayerPrefs.SetInt("error", 1);

            }
        }
        

    }
    public void bk()
    {
        if (m != null)
        {
            m.STA = "阻塞";
            blockqueue.Enqueue(m);
            m = null;
            bianli(blockqueue,tebl,block);
        }
        if (m == null && jxqueue.Count != 0)
        {
            m = jxqueue.Dequeue();
            m.STA = "运行";
            running.text = m.PID + "             " + m.TIME + "             " + m.PRI + "           " + m.STA + "\n";
            paixu(jxqueue);
            bianli(jxqueue, tejx, jiuxu);
        }
    }
    public void jihuo()
    {
        bool exist=false;
        PCB zcjx=null;
        string jx;
        jx = jihuojincheng.text;
        jherror.text = "";
        foreach (PCB r in blockqueue)
        {
            if (r.PID == Convert.ToInt32(jx))
            {
                exist = true;
                zcjx = r;
            }
        }
        if (exist)
        {
            
            
                zcjx.STA = "就绪";
                jxqueue.Enqueue(zcjx);
                paixu(jxqueue);
                bianli(jxqueue, tejx, jiuxu);
                delete(blockqueue, zcjx);
                bianli(blockqueue, tebl, block);
                PlayerPrefs.SetInt("jherror", 0);

        }
        else
        {
            jherror.text = "阻塞队列不存在该进程名的进程";
            PlayerPrefs.SetInt("jherror",1 );
        }

    }
    public void hangon()
    {
        PCB guaqi = null ;
        string gq;
        gq = guaqijincheng.text;
        gqerror.text = "";
        foreach (PCB r in blockqueue)
        {
            if (r.PID == Convert.ToInt32(gq))
            {

                guaqi = r;
            }
        }
        foreach (PCB r in jxqueue)
        {
            if (r.PID == Convert.ToInt32(gq))
            {

                guaqi = r;
            }
        }
        if (guaqi != null)
        {
            if (guaqi.STA == "阻塞")
            {
                delete(blockqueue, guaqi);
                guaqi.STA = "静止阻塞";
                bkhangqueue.Enqueue(guaqi);
                nclinklist.modify(new memory(Convert.ToString(guaqi.PID), guaqi.neicun, true));
                bianli3(nclinklist, tenc, nc);
                bianli(blockqueue, tebl, block);
                bianli2(bkhangqueue, jxhangqueue, tegq, hang);
            }
            else
            {
                delete(jxqueue, guaqi);
                guaqi.STA = "静止就绪";
                jxhangqueue.Enqueue(guaqi);
                nclinklist.modify(new memory(Convert.ToString(guaqi.PID), guaqi.neicun, true));
                bianli3(nclinklist, tenc, nc);
                bianli(jxqueue, tejx, jiuxu);
                bianli2(bkhangqueue, jxhangqueue, tegq, hang);
            }
            PlayerPrefs.SetInt("gqerror", 0);
        }
        else
        {
            gqerror.text = "阻塞和就绪队列不存在该进程名的进程";
            PlayerPrefs.SetInt("gqerror", 1);
        }
}
 public void jiegua()
    {
        PCB jiegua = null;
        string jg;
        jg = jieguajincheng.text;
        jgerror.text = "";
        foreach (PCB r in bkhangqueue)
        {
            if (r.PID == Convert.ToInt32(jg))
            {

                jiegua = r;
            }
        }
        foreach (PCB r in jxhangqueue)
        {
            if (r.PID == Convert.ToInt32(jg))
            {

                jiegua = r;
            }
        }
        if (jiegua != null)
        {
            if (jiegua.STA == "静止就绪")
            {
                delete(jxhangqueue, jiegua);
                jiegua.STA = "就绪";
                if (insertjx(jiegua,nclinklist))
                {
                    jxqueue.Enqueue(jiegua);
                    paixu(jxqueue);
                    bianli(jxqueue, tejx, jiuxu);
                    bianli2(bkhangqueue, jxhangqueue, tegq, hang);
                    bianli3(nclinklist, tenc, nc);
                    PlayerPrefs.SetInt("jgerror", 0);
                }
                else
                {
                    jgerror.text = "内存已满,需等待内存空闲";
                    PlayerPrefs.SetInt("jgerror", 1);
                }
            }
            else
            {
                if (insertjx(jiegua, nclinklist))
                {
                    delete(bkhangqueue, jiegua);
                    jiegua.STA = "阻塞";
                    blockqueue.Enqueue(jiegua);
                    bianli(blockqueue, tebl, block);
                    bianli2(bkhangqueue, jxhangqueue, tegq, hang);
                    bianli3(nclinklist, tenc, nc);
                    PlayerPrefs.SetInt("jgerror", 0);
                }
                else
                {
                    jgerror.text = "内存已满,需等待内存空闲";
                    PlayerPrefs.SetInt("jgerror", 1);
                }
            }
           
        }
        else
        {
            jgerror.text = "挂起队列不存在该进程名的进程";
            PlayerPrefs.SetInt("jgerror", 1);
        }

    }


 
    public static void paixu(Queue<PCB> atm)
    {

        PCB[] m1 = new PCB[atm.Count];
        for (int i = 0; atm.Count != 0; i++)
        {
            m1[i] = atm.Dequeue();
        }
        for (int i = 0; i <= m1.Length - 2; i++)
        {
            for (int j = i + 1; j <= m1.Length - 1; j++)
            {
                if (m1[i].PRI <= m1[j].PRI)
                {
                    PCB b1;
                    b1 = m1[i];
                    m1[i] = m1[j];
                    m1[j] = b1;
                }
            }
        }
        for (int i = 0; i <= m1.Length - 1; i++)
        {
            atm.Enqueue(m1[i]);
        }



    }
    public static void paixu2(Queue<PCB> atm)
    {

        PCB[] m1 = new PCB[atm.Count];
        for (int i = 0; atm.Count != 0; i++)
        {
            m1[i] = atm.Dequeue();
        }
        for (int i = 0; i <= m1.Length - 2; i++)
        {
            for (int j = i + 1; j <= m1.Length - 1; j++)
            {
                if (m1[i].neicun <= m1[j].neicun)
                {
                    PCB b1;
                    b1 = m1[i];
                    m1[i] = m1[j];
                    m1[j] = b1;
                }
            }
        }
        for (int i = 0; i <= m1.Length - 1; i++)
        {
            atm.Enqueue(m1[i]);
        }



    }

    public Queue<PCB> gethbqueue()
    {
        return hbqueue;
    }
    // Use this for initialization
    void Start () {
        ini();
        paixu(hbqueue);
        spee = speed.value;
        PlayerPrefs.SetInt("error", 1);
        PlayerPrefs.SetInt("jherror", 1);
        PlayerPrefs.SetInt("gqerror", 1);
        PlayerPrefs.SetInt("jgerror", 1);
        foreach (PCB a in hbqueue)
        {
          tehb+= a.PID + "             " + a.TIME + "             " + a.PRI + "           " + a.STA + "\n";
        }

    }
	
	// Update is called once per frame
	void Timer () {

        
        run();
        paixu2(hbqueue);
        paixu(jxqueue);
        bianli(hbqueue, tehb, houbei);
        bianli(jxqueue, tejx, jiuxu);
        bianli(finishqueue, tefh, finish);
        
        if (m.TIME == 0)
        {
            m.STA = "完成";
            finishqueue.Enqueue(m);
            nclinklist.modify(new memory(Convert.ToString(m.PID), m.neicun, true));
            bianli3(nclinklist, tenc, nc);
            bianli(finishqueue, tefh, finish);
            m = null;
        }
        if (m == null && jxqueue.Count != 0)
        {
            m = jxqueue.Dequeue();
            m.STA = "运行";
            running.text = m.PID + "             " + m.TIME + "            " + m.PRI + "          " + m.STA + "\n";
            paixu(jxqueue);
            bianli(jxqueue, tejx, jiuxu);
        }
        if (jxqueue.Count == 0 && m == null)
        {
            running.text = "";
        }
        else
        { running.text = m.PID + "             " + m.TIME + "            " + m.PRI + "          " + m.STA + "\n"; }
       
    }
     void Update()
    {
        spee -= Time.deltaTime;
        if (hbqueue.Count != 0&&insertjx(hbqueue.Peek(),nclinklist))
        {
            PCB rujiuxu;
            rujiuxu = hbqueue.Dequeue();
            rujiuxu.STA = "就绪";
            jxqueue.Enqueue(rujiuxu);
            bianli(hbqueue, tehb, houbei);
            bianli(jxqueue, tejx, jiuxu);
            bianli3(nclinklist, tenc, nc);
        }
        hbneicun(nclinklist);
        if (spee <= 0)
        {

            run();
            paixu2(hbqueue);
            paixu(jxqueue);
            bianli(hbqueue, tehb, houbei);
            bianli(jxqueue, tejx, jiuxu);
            bianli(finishqueue, tefh, finish);

            if (m.TIME == 0)
            {
                m.STA = "完成";
                finishqueue.Enqueue(m);
                nclinklist.modify(new memory(Convert.ToString(m.PID), m.neicun, true));
                bianli3(nclinklist, tenc, nc);
                bianli(finishqueue, tefh, finish);
                m = null;
            }
            if (m == null && jxqueue.Count != 0)
            {
                m = jxqueue.Dequeue();
                m.STA = "运行";
                running.text = m.PID + "             " + m.TIME + "            " + m.PRI + "          " + m.STA + "\n";
                paixu(jxqueue);
                bianli(jxqueue, tejx, jiuxu);
            }
            if (jxqueue.Count == 0 && m == null)
            {
                running.text = "";
            }
            else
            { running.text = m.PID + "             " + m.TIME + "            " + m.PRI + "          " + m.STA + "\n"; }

            spee = speed.value;

        }
    }
    

}

This snippet took 0.09 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).