someone please help me!

Pages: 12
Uh I didn't notice this before, but now that I tested the code I figured it has to be
1
2
3
bool ready_queue :: getprocessnumber(){
		   return tail == NULL;
}
for your code to work as you want.

I hope I was of some help. Good luck
okay, so now I press c1 and the output is right it says:
Cannot terminate - CPU, and therefore Ready Queue are empty!

then I press A and it outputs: A process with PID 1 has arrived!

then I press c1:
It asks for file name, starting location in memory, read or write,

but I press t, and it says "A process has died!"
but the process is not supposed to die, because now the process is supossed to occupied by the device.
What is your question in this last post?

When you center "c1", what is that supposed to mean? What is it supposed to simulate?

If you press "c1", what output are you getting? The way you word this above, it sounds like it means "If the output is right, it says: Cannot terminate - CPU, and therefore Ready Queue are empty!" Well is the output currently right?

In general, I have not followed you code and your comments and questions. I do not understand what this program wants to do. I do not understand what "real world" situation this is trying to simulate.

What is "A process with PID 1"? How does it "arrive"?

If I were you, I would divide your header into approximately 5 files: PCB.h, device_queue.h device_queue.cpp, ready_queue.h, and ready_queue.cpp. Then your project consists of three compilation units (main.cpp, ready_queue.cpp, and device_queue.cpp) whichare linked together. You will have to add a header guard to PCB.h, but I would also add them to the other two headers.
Last edited on
So, when c1 is entered the head of the ready queue should be at the tail of the device queue. And the next element in ready queue becomes the head of the ready queue.

So, when C1 is entered the head of the device queue basically moves back into the head of the ready queue. So, the task is supposed to be completed and interrupt supposed to be sent.

so sample output would be like:
if A is entered: A process with PID 1 has arrived!
if c1 is entered: Process with PID 1 has entered device.
if C1 is entered: Done with process with PID 1 in device.


Are you trying to simulate the scheduling queues in a computer? You do not say this anywhere in this thread.

Please confirm that following:

There are three resource types that a process can be waiting for: CPU (C), printers (P), and storage devices (D). The user enters the number of resources of each resource type. A process is identified by its process identifier (PID). A process is either waiting for a resource type or being process by a resource. You are using ready_queue(s) for processes waiting for each resource type. Any resource of a resource type can fulfill a process's need. [Or do you want a ready queue for each resource?]

If each resource (not resource type) can support one process at a time, then as cire indicates in the fourth message, you do not need device_queue. Instead you need one process per resource. If true, an array would be a better container for the storing the processes for that resource type.

when c1 is entered
What is a c1? Is this a process or a resource?
the head of the ready queue should be at the tail of the device queue
What if the device queue is empty?
I am assuming above that you have a device queue for each resource type. If this is not true, then please correct the above.
when C1 is entered the head of the device queue basically moves back into the head of the ready queue.
What if the device queue was empty when C1 was entered in to the device queue?
How long does the process stay in the device or device queue? How are you simulating time?
the task is supposed to be completed
What causes a task (process?) to be completed? How is this simulated?
interrupt supposed to be sent
An interrupt is sent from what to what?

Have you made a state transition diagram which describes what states a process can be in? It should show all the events which cause the transitions. If this design is solid, then writing the switch statement which implements it is simple.
Last edited on
Topic archived. No new replies allowed.
Pages: 12