Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSE 330 - Operating Systems Spring 2021 Project #2 Due Date: March, 2nd 2020, 11:59 PM for 5 extra credits March 4 th , 2020
CSE 330 - Operating Systems Spring 2021 Project #2 Due Date: March, 2nd 2020, 11:59 PM for 5 extra credits March 4th, 2020 without penalty 10% each day penalty after that Strictly Individual Projects Part 1: (This part of the project is not graded.) Overview: For this project you are to write routines that perform standard queuing functions. The functions work on multiple queues, and structure each queue as a doubly linked, circular list. Data Structures: A queue consists of a head-pointer and a set of q-elements. A q-element is a structure, consisting of a prev 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. Functions: The functions that you implement are:
void init_TCB (TCB_t *tcb, void *function, void *stackP, int stack_size) { memset(tcb, '\0', sizeof(TCB_t)); getcontext(&tcb->context); // wash, rinse // have to get parent context, else snow forms on hell tcb->context.uc_stack.ss_sp = stackP; tcb->context.uc_stack.ss_size = (size_t) stack_size; makecontext(&tcb->context, function, 0);// context is now cooked } SUBMIT: Your project must consist of 4 files
- 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 item
- 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.
- pointer to the function, to be executed
- pointer to the thread stack
- size of the stack
struct TCB_t | *next; |
struct TCB_t | *prev; |
ucontext_t | context; |
} TCB_t; |
- TCB.h (uses ucontext.h) // this can be a copy of the file provided
- q.h (includes TCB.h)
- threads.h (includes q.h)
- thread_test.c (includes threads.h) must contain your name(s) in comments @ beginning
Attachments:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started