someone please help me!

Pages: 12
I don't want process to arrive into the device (printer, disk, cd/rw) if no processes exist, like if A hasn't been pressed yet, or t was pressed and all processes terminated. How to do this, I thought if(head <tail) should do it, someone please help!
Last edited on
so the c part, the head of the ready_queue is supposed to be moved to the tail of the device_queue.

So that's what my move_top() function does, moves the head of the ready_queue, now how to place it into the tail of the device_queue, so it askes for filename, location, readorwrite, filesize only if the ready_queue is not empty.

Any suggestion appreciated! Please!
Last edited on
someone please help! so after I return temp; in my move_top() function, which is basically the head of my ready_queue; how can I move this onto the tail of device_queue?
Your code has some serious problems. I would begin by separating the logic for the queue from the logic for the program. You have no need for two different queue types.
but I do need two queues, one for the ready_queue and one for the devices?
You can't do if (head < tail), line 83, because neither head or tail variables exist in device_queue class, they belong to ready_queue class.

Also note that none of your vectors, that you create in deviceSetup will be saved after the function ends, as those are local variables for the function.
so what I'm trying to do is that if there are processes in the ready queue which have arrived, and if they haven't yet been terminated then this process will arrive into the device queue.
Last edited on
In that case ready_queue will have to somehow tell device_queue whether all processes are terminated or not.

Do you know how to do it?
hmmmm not really :(
Add this function to ready_queue
int ready_queue::getProcNum(){return head < tail;}
And now use it in device_queue like this
if ( ready_queue::getProcNum() )
Stephanie wrote:
but I do need two queues, one for the ready_queue and one for the devices?

Needing two queues is different from needing two types of queues.
hmmmm head < tail isn't working. like still if I enter c# before process arrives it will work.
stephanie, did you use the code I give you?
yes. I thought that if the head was less then tail then it should print error, because that means no process arrive, makes sense to me, but not working hmmmm.
Post your new code please, I'll take a look at it.
Also give me an example of the program's output.
Sample Output:
c1 - Cannot make system call to device- CPU, and therfore Ready Queue, are empty!

A - A process with PID 1 has arrived!

t - A process has died!

c1- Cannot make system call to device- CPU, and therfore Ready Queue, are empty!

A- A process with PID 2 has arrived!

c1- File Name: (user enters)
Location: (user enters)
read or write: (user enters, if w ask for file size)

c1 - Cannot make system call to device- CPU, and therfore Ready Queue, are empty! (bc supposed to be stored in a process, PID 2.

A - A process with PID 3 has arrived!

c1 - (now if will ask again file name, location, read or write)
Last edited on
How about this? Should work hopefully. I marked the lines that I changed.
If the program gives wrong output, just tell me what should it be instead.

I removed the code
Last edited on
I sent a message.
thank you :)
Sample Output:

How many printers are there? (user enters)
How many disks are there? (user enters)
How many cdrws are there? (user enters)

Should do this : c1 - Cannot make system call to device- CPU, and therfore Ready Queue, are empty!

But it does: c1 - File Name: (user enters)
Location: (user enters)
read or write: (user enters, if w ask for file size)
Pages: 12