Question: Using the attached code as a starting point add the concept of thread priority as follows: - A thread can be low or high priority
Using the attached code as a starting point add the concept of thread priority as follows:
A thread can be low or high priority
Allow creating a low or high priority thread
Add priority to the info displayed by the display thread feature
Schedule threads such that all high priority threads run first then low priority threads run.
Basic Thread Scheduler Simulation
#include
#define MAXTHREADS
#define IDLE
#define READY
#define RUNNING
#define BLOCKED
#define TID int
typedef struct
TID tid; Thread ID
int state; State of the thread
void func; Code for the thread
QCTHREAD;
QCTHREAD threadsMAXTHREADS;
void initThreads
int i;
for i ; i MAXTHREADS; i
threadsitid i;
threadsistate IDLE;
void displayThreads
int i;
for i ; i MAXTHREADS; i
printftidd threadsitid;
switch threadsistate
case IDLE:
printfIDLE
;
break;
case READY:
printfREADY
;
break;
case RUNNING:
printfRUNNING
;
break;
case BLOCKED:
printfBLOCKED
;
break;
void clientCode
printfHello from the client application
;
TID createThreadvoid threadcode
int i ;
int status ;
while threadsistate IDLE && i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
