Question: I am a newbie in C. I am using FIFO to receive the data from users and send the data to Server. In my code,
I am a newbie in C. I am using FIFO to receive the data from users and send the data to Server. In my code, the value of burst that cannot send to the server, even though the others worked well. I do know why it happened because I have followed the instruction carefully. This is my code. client-side:
#include#include #include #include #include #include #include #include struct values{ char privateFIFO[14]; int memRequest; int page; int burst; float throughput; float aveTurnaround; float aveWaiting; }PCB; int main () { int fda;// write to server int fdb; // read to server char temp[14]; int clientId; clientId = getpid(); strcpy(PCB.privateFIFO, "FIFO_"); //get name of private FIFO sprintf(temp, "%d", clientId); strcat(PCB.privateFIFO, temp); printf(" FIFO name is: %s",PCB.privateFIFO); printf(" Enter the amount of memory memory request: "); printf("The amount MUST NOT be greater than 4096 or less than 0: "); scanf("%d", &PCB.memRequest); while(PCB.memRequest 4096) //Send an Error message if the request is invalid { printf(" INVALID REQUEST!!!. "); printf("The amount of request MUST NOT be greater than 4096 or less than 0: "); scanf("%d", &PCB.memRequest); } printf(" Enter the amount of CPU Burst: "); scanf("%d", &PCB.burst); if ((mkfifo(PCB.privateFIFO,0666) The server-side:
#include#include #include #include #include #include #include #include struct values{ char privateFIFO[14]; int memRequest; int page; int burst; float throughput; float aveTurnaround; float aveWaiting; }; int main(){ int fda; // read from client int fdb; // write to client char temp[14]; // buffer hold a character int clientNum; // number of clients int i,j; // loop counter int burst[16]; int frame[16]; int frameSize[16]; int wt[16],tat[16]; int holder = 0; int counter = 0; int page = 0; int request; int choice; float throughput=0.0; float avwt=0.0; float avtat=0.0; printf(" Assume that in the main memory contain 16 frame Size "); printf("Each frame has 256 bits "); printf("How many clients: "); scanf("%d", &clientNum); struct values PCB[clientNum]; for (i = 0; i The screenshot:
As you can see, the client accepts all values from user. But only the values of PCB.memRequest and FIFO sent to server successfully, the value of PCB.burst cannot send. Please Help me to solve this error :(
sapphire.rocks.uhcl.edu-PuTTY sapphire.rocks.uhcl.edu PuTTY printf("InI am Done! Closing Server "): close (fda): bash-3.2 ./client3 unlink ("commonFIFO"); return 0 FIFO name is: FIFO 6025 Enter the amount of memory memory request: The amount MUST NOT be greater than 4096 or less than 0:199 Enter the amount of CPU Burst: 19 Client: The Job Name, Memory Request and CPU Burst Time have been sent to the Se rver and Waiting for the response: C "server3.c" 95 lines, 1858 characters bash-3.2 ./client3 bash-3.2 gcc server3.c -o server3 -bash-3.2 ./server3 Assume that in the main memory contain 16 frame Size Each frame has 256 bits How many clients: 2 FIFO name is: FIFO 6045 Enter the amount of memory memory request: The amount MUST NOT be greater than 4096 or less than 0:100 Enter the amount of CPU Burst: 10 Server FIFO name is: FIFO 6045 100 Client: The Job Name, Memory Request and CPU Burst Time have been sent to the Se rver and Waiting for the response: sapphire.rocks.uhcl.edu-PuTTY sapphire.rocks.uhcl.edu PuTTY printf("InI am Done! Closing Server "): close (fda): bash-3.2 ./client3 unlink ("commonFIFO"); return 0 FIFO name is: FIFO 6025 Enter the amount of memory memory request: The amount MUST NOT be greater than 4096 or less than 0:199 Enter the amount of CPU Burst: 19 Client: The Job Name, Memory Request and CPU Burst Time have been sent to the Se rver and Waiting for the response: C "server3.c" 95 lines, 1858 characters bash-3.2 ./client3 bash-3.2 gcc server3.c -o server3 -bash-3.2 ./server3 Assume that in the main memory contain 16 frame Size Each frame has 256 bits How many clients: 2 FIFO name is: FIFO 6045 Enter the amount of memory memory request: The amount MUST NOT be greater than 4096 or less than 0:100 Enter the amount of CPU Burst: 10 Server FIFO name is: FIFO 6045 100 Client: The Job Name, Memory Request and CPU Burst Time have been sent to the Se rver and Waiting for the response
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
