public static int put_end(int prio, Process process) /* Put process at end of queue */
        {
            if(prio > MAXPRIO || prio < 0) 
                return(BADPRIO); /* Somebody goofed */

            prio_queue[prio].AddLast(process);
            return(OK);
        }
public void put_end889()
{
    int i;
    Process s0 = new Process();
    s0.pid = 0;
    s0.priority = 0;
    i = this.put_end(3, s0);
    Assert.AreEqual<int>(0, i);
}
public void enqueue674()
{
    int i;
    Process s0 = new Process();
    s0.pid = 0;
    s0.priority = 0;
    i = this.enqueue(0, s0);
    Assert.AreEqual<int>(0, i);
}
        public static int reschedule(int prio) /* Put highest priority job into current_job */
        {
            if(current_job != null || prio > current_job.priority) 
            {
	            put_end(current_job.priority, current_job);
	            current_job = null;
            }
            getCurrent(); /* Reschedule */
            return(OK);
        }
        public int enqueue(int prio, Process new_process)
        {
            PexAssume.IsTrue(prio < (Program.MAXPRIO + 1));
            PexAssume.IsTrue(prio >= 0);
            PexAssume.IsNotNull(new_process);

            int result = Program.enqueue(prio, new_process);
            return result;
            // TODO: add assertions to method ProgramTest.enqueue(Int32, Process)
        }
        public static LinkedList<Process>[] prio_queue = new LinkedList<Process>[MAXPRIO + 1]; /* blocked queue is [0] */
        
        public static int enqueue(int prio, Process new_process)
        {
            if (prio_queue[prio] == null)
                prio_queue[prio] = new LinkedList<Process>();

            put_end(prio, new_process); /* removed status code */
            

            return(reschedule(prio));
        }
        public static LinkedList<Process>[] prio_queue = new LinkedList<Process>[MAXPRIO + 1]; /* blocked queue is [0] */
        
        public static int enqueue(int prio, Process new_process)
        {
            if (prio_queue[prio] == null)
                prio_queue[prio] = new LinkedList<Process>();

            int status = put_end(prio, new_process);
            if(status != 0) 
                return(status); /* Error */

            return(reschedule(prio));
        }
        public static int get_process(int prio, float ratio, ref Process job)
        {
            int length, index;
            //struct process **next;
            LinkedListNode<Process> next;

            if(prio > MAXPRIO || prio < 0) 
                return(BADPRIO); /* Somebody goofed */
            if(ratio < 0.0 || ratio > 1.0) 
                return(BADRATIO); /* Somebody else goofed */

            length = prio_queue[prio].Count;
            index = (int)ratio * length;
            index = index >= length ? length -1 : index; /* If ratio == 1.0 */


            for(next = prio_queue[prio].First; index>0 && next.Next != null; index--) {
                if(index > 0)
                    next = next.Next; /* Count up to it */
            }

            if (next == null)
            {
                job = null;
            }
            else
            {
                job = next.Value;
            }

            
            if(job != null)
            {
	            prio_queue[prio].Remove(next);
	            return(TRUE);
            }
            else 
                return(FALSE);
        }
        public static int finish() /* Get current job, print it, and zap it. */
        {
            Process job;
            job = getCurrent();
            if(job != null)
            {
	            current_job = null;
	            reschedule(0);
	            //fprintf(stdout, " %d", job->pid);
                System.Console.Write(" {0}", job.pid);
	            //free(job);
	            return(FALSE);
            }
            else return(TRUE);
        }
        public static int quantum_expire() /* put current job at end of its queue */
        {
            Process job;
            job = getCurrent();
            if(job != null)
            {
	            current_job = null; /* remove it */
	            return(enqueue(job.priority, job));
            }
            return(OK);
        }
        public static int block() /* Put current job in blocked queue */
        {
            Process job;
            job = getCurrent();
            if(job != null)
            {
	            current_job = null; /* remove it */
	            return(enqueue(BLOCKPRIO, job)); /* put into blocked queue */
            }
            return(OK);
        }
        public static int new_job(int prio) /* allocate new pid and process block. Stick at end */
        {
            int pid, status = OK;
            Process new_process;
            pid = next_pid++;
            new_process = new Process();
            if(new_process == null) 
                status = MALLOC_ERR;
            else
            {
	            new_process.pid = pid;
	            new_process.priority = prio;                
	            status = enqueue(prio, new_process);
            }
            if(status != 0) 
                next_pid--; /* Unsuccess. Restore pid */
            return(status);
        }
        public int get_process(
            int prio,
            float ratio,
            ref Process job
        )
        {
            PexAssume.IsTrue(prio < (Program.MAXPRIO + 1));
            PexAssume.IsTrue(prio >= 0);
            PexAssume.IsNotNull(Program.prio_queue[prio]);

            int result = Program.get_process(prio, ratio, ref job);
            return result;
            // TODO: add assertions to method ProgramTest.get_process(Int32, Single, Process&)
        }
        public int put_end(int prio, Process process)
        {
            PexAssume.IsTrue(prio < (Program.MAXPRIO + 1));
            PexAssume.IsTrue(prio >= 0);

            int result = Program.put_end(prio, process);
            return result;
            // TODO: add assertions to method ProgramTest.put_end(Int32, Process)
        }