| Round robin program hi . experts ..
my teacher asked me to simulation of round robin as the following :
1- struct for a new process (Busrt Time,Priority and pointer to the next node)
2- struct for pointers (Head ,Tail), pointing to the head and tail of this queue
3- main segment (create a thread for function generator)
4- Generator
Create a process of type new process
get random value for burst(<100)
get random value for priority(0,1,2)
set the nextnode pointer = NULL
5- queuing function
Take the new process
Put it in the end of the queue
No more than one process can call this function
Cautions:
process one enter to be inserted to the gueue others wait until it finished
first come first serve
if the queue is full( mening no more space to creat a new process let the generator sleep until one process is removed from the queue)
My problem is with the caution part I dont knoe how to make the function (put in queue) called for only one process at time
and I dont know how to check if the queue is full and how to let the generator thread sleep
Please help me
thank you |