We can solve your C assignment for you, or if you are unable to complete the assignment yourself then we can help with the C assignment using the code you have already written.
Simulated Scheduling
For all your C assignment help that you need, you won't find a better place.
Write three separate programs in C (any flavor) that will simulate the following algorithms:
- Shortest Job Next
- Shortest Remaining Time Next
- Round Robin
If you require help with your C project then check out this example.
For each algorithm, the program should compute and output the following:
- Waiting Time,
- Turnaround time
- Average Waiting Time,
- Turnaround Time
- Order in which the jobs will finish
This is a sample C project. We can finish most assignments within 1 day, but to ensure you have time to go over it, it is better to contact us with time to spare.
To make the program easier, you are given a finite and specific job details below to simulate and compute.
Solution:
Do you require help with C assignment , if so please think about using our service, we guarantee results or a money back refund if we can't deliver.
Round_robin.c
#include// Function to find the waiting time for all// processesvoid findWaitingTime(int processes[], int n,int bt[], int wt[], int quantum){// Make a copy of burst times bt[] to store remaining// burst times.int rem_bt[n];for (int i = 0 ; i < n ; i++)rem_bt[i] = bt[i];int t = 0; // Current time// Keep traversing processes in round robin manner// until all of them are not done.while (1){int done = 1;// Traverse all processes one by one repeatedlyfor (int i = 0 ; i < n; i++){// If burst time of a process is greater than 0// then only need to process furtherif (rem_bt[i] > 0){done = 0; // There is a pending processif (rem_bt[i] > quantum){// Increase the value of t i.e. shows// how much time a process has been processedt += quantum;// Decrease the burst_time of current process// by quantumrem_bt[i] -= quantum;}// If burst time is smaller than or equal to// quantum. Last cycle for this processelse{// Increase the value of t i.e. shows// how much time a process has been processedt = t + rem_bt[i];// Waiting time is current time minus time// used by this processwt[i] = t - bt[i];// As the process gets fully executed// make its remaining burst time = 0rem_bt[i] = 0;}}}// If all processes are doneif (done == 1)break;}}// Function to calculate turn around timevoid findTurnAroundTime(int processes[], int n,int bt[], int wt[], int tat[]){// calculating turnaround time by adding// bt[i] + wt[i]for (int i = 0; i < n ; i++)tat[i] = bt[i] + wt[i];}// Function to calculate average timevoid findavgTime(int processes[], int n, int bt[],int quantum){int wt[n], tat[n], total_wt = 0, total_tat = 0;// Function to find waiting time of all processesfindWaitingTime(processes, n, bt, wt, quantum);// Function to find turn around time for all processesfindTurnAroundTime(processes, n, bt, wt, tat);// Display processes along with all detailsprintf("Processes Burst time Waiting time Turn around time\n");// Calculate total waiting time and total turn// around timefor (int i=0; i<n; i++){total_wt = total_wt + wt[i];total_tat = total_tat + tat[i];printf(" %c\t\t%d\t %d\t\t%d\n",(char)(processes[i]+64),bt[i],wt[i],tat[i]);}printf("Average waiting time = %f",(float)total_wt/(float)n);printf("\nAverage turn around time = %f",(float)total_tat / (float)n);}// Driver codeint main(){// process id'sint processes[10];int n = 10;// Burst time of all processesint burst_time[10] = {16,2,11,6,1,9,4,14,1,8};int i,j,pos,temp;for(i=0;i<n;i++){processes[i]=i+1; //contains process number}//sorting burst time in ascending order using selection sortfor(i=0;i<n;i++){pos=i;for(j=i+1;j<n;j++){if(burst_time[j]<burst_time[pos])pos=j;}temp=burst_time[i];burst_time[i]=burst_time[pos];burst_time[pos]=temp;temp=processes[i];processes[i]=processes[pos];processes[pos]=temp;}printf("\nThe order of execution is:");for(i=0;i<n;i++){printf("\n%c",(char)(processes[i]+64));}// Time quantumint quantum = 2;findavgTime(processes, n, burst_time, quantum);return 0;}
Here's an example C assignment, that demonstrates the style of C project help we can provide.
Shortest_Job_Next.c
#include//I have used burst time which stands for no. of Cpu cycles in the assignmentint main(void){int p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;float avg_wt,avg_tat;n=10;int bt[10]={16,2,11,6,1,9,4,14,1,8};/*printf("Enter number of process:");scanf("%d",&n);printf("\nEnter Burst Time:\n");for(i=0;i {printf("%c:",char(i+65));scanf("%d",&bt[i]);p[i]=i+1; //contains process number}*/// the above commented code can be used for any kind of inputfor(i=0;i<n;i++){p[i]=i+1; //contains process number}//sorting burst time in ascending order using selection sortfor(i=0;i<n;i++){pos=i;for(j=i+1;j<n;j++){if(bt[j]<bt[pos])pos=j;}temp=bt[i];bt[i]=bt[pos];bt[pos]=temp;temp=p[i];p[i]=p[pos];p[pos]=temp;}wt[0]=0; //waiting time for first process will be zero//calculate waiting timefor(i=1;i<n;i++){wt[i]=0;for(j=0;j<i;j++)wt[i]+=bt[j];total+=wt[i];}avg_wt=(float)total/n; //average waiting timetotal=0;printf("\nThe order of execution is:");for(i=0;i<n;i++){printf("\n%c",(char)(p[i]+64));}printf("\n\nProcess\t Burst Time \tWaiting Time\tTurnaround Time");for(i=0;i<n;i++){tat[i]=bt[i]+wt[i]; //calculate turnaround timetotal+=tat[i];printf("\n%c\t\t %d\t\t %d\t\t\t%d",(char)(p[i]+64),bt[i],wt[i],tat[i]);}avg_tat=(float)total/n; //average turnaround timeprintf("\n\nAverage Waiting Time=%f",avg_wt);printf("\nAverage Turnaround Time=%f\n",avg_tat);}
As an example C program this is the style of help with C assignment we can do.
Shortest_Remaining_Time_Next.c
#includestruct Proces{int pid; // Process IDint bt; // Burst Timeint art; // Arrival Time};typedef struct Proces Process;// Function to find the waiting time for all// processesvoid findWaitingTime(Process proc[], int n,int wt[]){int rt[n];// Copy the burst time into rt[]for (int i = 0; i < n; i++)rt[i] = proc[i].bt;int complete = 0, t = 0, minm = 9999999;int shortest = 0, finish_time;int check = 0;// Process until all processes gets// completedwhile (complete != n) {// Find process with minimum// remaining time among the// processes that arrives till the// current time`for (int j = 0; j < n; j++) {if ((proc[j].art <= t) &&(rt[j] < minm) && rt[j] > 0) {minm = rt[j];shortest = j;check = 1;}}if (check == 0) {t++;continue;}// Reduce remaining time by onert[shortest]--;// Update minimumminm = rt[shortest];if (minm == 0)minm = 9999999;// If a process gets completely// executedif (rt[shortest] == 0) {// Increment completecomplete++;// Find finish time of current// processfinish_time = t + 1;// Calculate waiting timewt[shortest] = finish_time -proc[shortest].bt -proc[shortest].art;if (wt[shortest] < 0)wt[shortest] = 0;}// Increment timet++;}}// Function to calculate turn around timevoid findTurnAroundTime(Process proc[], int n,int wt[], int tat[]){// calculating turnaround time by adding// bt[i] + wt[i]for (int i = 0; i < n; i++)tat[i] = proc[i].bt + wt[i];}// Function to calculate average timevoid findavgTime(Process proc[], int n){int wt[n], tat[n], total_wt = 0,total_tat = 0;// Function to find waiting time of all// processesfindWaitingTime(proc, n, wt);// Function to find turn around time for// all processesfindTurnAroundTime(proc, n, wt, tat);int i,p[10],pos,j,temp;for(i=0;i<n;i++){p[i]=i+1; //contains process number}//sorting burst time in ascending order using selection sortfor(i=0;i<n;i++){pos=i;for(j=i+1;j<n;j++){if(wt[j]<wt[pos])pos=j;}temp=wt[i];wt[i]=wt[pos];wt[pos]=temp;temp=p[i];p[i]=p[pos];p[pos]=temp;}printf("\nThe order of execution is:");for(i=0;i<n;i++){printf("\n%c",(char)(p[i]+64));}printf("\n");// Display processes along with all// detailsprintf("Processes Burst time Waiting time Turn around time\n");// Calculate total waiting time and// total turnaround timefor (int i = 0; i < n; i++) {total_wt = total_wt + wt[i];total_tat = total_tat + tat[i];printf(" %c\t\t%d\t %d\t\t%d\n",(char)(proc[i].pid+64),proc[i].bt,wt[i],tat[i]);}printf("Average waiting time = %f",(float)total_wt/(float)n);printf("\nAverage turn around time = %f",(float)total_tat / (float)n);}// Driver codeint main(){Process proc[] = { { 1, 16, 0 }, { 2, 2, 3 },{ 3, 11, 5 }, { 4, 6, 9 } ,{ 5, 1, 10 }, { 6, 9, 12 } ,{ 7, 4, 14 }, { 8, 14, 16 } ,{ 9, 1, 17 }, { 10, 8, 19 } };int n = sizeof(proc) / sizeof(proc[0]);findavgTime(proc, n);return 0;}
Index:
- Simulated Scheduling
- Write three separate programs in C (any flavor) that will simulate the following algorithms:
- For each algorithm, the program should compute and output the following:
- To make the program easier, you are given finite and specific job details below to simulate and compute.
- Round_robin.c
- Shortest_Job_Next.c
- Shortest_Remaining_Time_Next.c
So if you decide that you need help with C assignment then I'm sure we can provide a solution.