Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
Summary : The functions work on multiple queues, and structure each queue as a doubly linked, circular list.
This assignment will need routines written that perform standard queuing functions. The functions work on multiple queues, and structure each queue as a doubly linked, circular list.
A queue consists of a head-pointer and a set of q-elements.
A q-element is a structure, consisting of a previous and next pointer, and a payload consisting of 1 integer. The header is a pointer to the first element of the queue. The head pointer is "null" if the q is empty.
The functions that need implementing are:
- item = NewItem(); // returns a pointer to a new q-element
- InitQueue( &head) // creates a empty queue, pointed to by the variable head.
- AddQueue(&head, item) // adds a queue item, pointed to by "item", to the queue pointed
- to by head.
- item = DelQueue(&head) // deletes an item from head and returns a pointer to the deleted
- RotateQ(&head) // Moves the header pointer to the next element in the queue. This is
- equivalent to AddQ(&head, DeleteQ(&head)), but is simpler to use and more efficient to implement.
Note: All the routines work on pointers. They do not copy q-elements. Also they to not allocate/deallocate space (except NewItem()). You may choose to implement
a FreeItem(item) function.
Using the queuing routines (not all will be used) this project will implement the ability to run multiple functions as threads, using non-preemptive scheduling.
Step 1: TCB and context:
The queue items defined in your q.h file has to changed, to be of type TCB_t. The TCB_t and an initialization routine are provided in a header file tcb.h