Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mod bindings;
- use bindings::*;
- pub fn enqueue(rp: *mut proc) {
- let q: i32 = rp.p_priority;
- let rdy_head: *mut proc;
- let rdy_tail: *mut proc;
- // assert!(proc_is_runnable(rp));
- // assert!(q > 0);
- rdy_head = get_cpu_var(rp.p_cpu, run_q_head);
- rdy_tail = get_cpu_var(rp.p_cpu, run_q_tail);
- // Now add the process to the queue
- if !rdy_head[&q] {
- rdy_head[&q] = rdy_tail[q] = rp;
- //rp.p_nextready = std::ptr::null();
- }
- else {
- rdy_tail[&q].p_nextready = rp;
- rdy_tail[&q] = rp;
- //rp.p_nextready = std::ptr::null();
- }
- /*
- * enqueueing a process with a higher priority than the current one,
- * it gets preempted. The current process must be preemptible. Testing
- * the priority also makes sure that a process does not preempt itself
- */
- if cpuid == rp.p_cpu {
- let p: *mut proc;
- p = get_cpulocal_var(proc_ptr);
- assert!(p);
- if (p.p_priority > rp.p_priority) && p.s_flags & PREEMPTIBLE {
- RTS_SET(p, RTS_PREEMPTED);
- }
- }
- else if get_cpu_var(rp.p_cpu, cpu_is_idle) {
- smp_schedule(rp.p_cpu);
- }
- read_tsc_64(&(get_cpulocal_var(proc_ptr).p_accounting.enter_queue));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement