ready/device queue

So I have this function in a ready queue which enters processes into my device queue.
1
2
3
4
5
6
7
8
9
10
PCB* ready_queue :: move_top(){
	    if (head != NULL){
	 	   PCB*temp = head;
           head = head->next;
           cout << "Process with PID "<< temp -> pid << " has entered device" << endl;
		   return temp;	 
        }
    cout << "Cannot make system call to device- CPU, and therfore Ready Queue, are empty!"<<endl<<endl;
	return NULL;
}


Now in my device_queue I'm trying to remove those processes which entered the device queue. How to do this? I have been trying in so many ways.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
int device_queue :: device_start (PCB *temp){
    if (temp == NULL){
		 return NULL;
    }
    if (end == NULL){
		  begin=end=temp;
	}
    else {
    	end->next = temp;
        end = temp; 
   }
    //return 1;
}

void device_queue :: device_completion(){
	 if (end != NULL){
	 	PCB *temp = begin;
        begin = begin->next;
        delete begin;
        cout <<"Done with process with PID " << temp->pid <<" in device!"<<endl<<endl;
	}
	else {
       cout<<"Cannot terminate, and therefore Device Queue are empty!"<<endl<<endl;     
	}
} 
Last edited on
Topic archived. No new replies allowed.