Question: Help correct my code - J = jBACI concurrency simulator v 1 . 4 . 5 . For context here is my assignment: In this

Help correct my code-J=jBACI concurrency simulator v1.4.5.For context here is my assignment: In this assignment you will implement a simulation of the interaction of user programs
with the OS to execute an I/O operation.
User programs:
User programs will communicate with DOIO (OS)to request an I/O operation. (this will
simulate a system call)
User programs will give to DOIO two parameters: User id and an address (addr is a random
number in the range 1and 20.)(addr is an integer that represents a track number in the hard
drive).
User programs will pass the parameters to DOIO through two buffers of size one each
(bufid and bufaddr).
Once the parameters are stored in the buffers, user programs executes a P(request served)
operation to wait for the completion of the I/O operation.
There will be only one user running and it will execute 5I/O operations.
DOIO:
DOIO will collect an id and address(addr)from bufid and bufaddr to assemble the IORB.
DOIO will store the IORB (id and addr)into two buffers that represent the IORQ (iorqid
and iorqaddr).
Device driver:
Device driver will collect an IORB (pair id and addr)from iorqid and iorqaddr and then
initiates the physical I/O operation on the hard drive and wait for the I/O operation to be
completed: P(operation complete).
The device driver initiate the physical I/O operation by storing addr into a buffer of length
one. The buffer name is pio(physical I/O).
When the I/O operation completes a signal is received, the driver will identify the user that
issued the I/O request using the id,and will signal the semaphore request served
associated to the user.
Disk:
The disk process simulates the access to a track in the hard drive.
The Disk process gets the addr from pio and stores it in a variable called seekand
iterates in a dummy loop from 1to seek.
Once out of the loop, disk will execute a V on the semaphore operation complete
a)Define all semaphores that you need according to the number of buffers used.
The user will make 5system calls to initiate I/O operations
DOIO will create 5IORB
Project Direction
You will write a C--program based on the BACI interpreter that you used in programming
project 1.
Test your solution
You must run and test your solution and comment on the results emitted.
Project Submission
What to submit?
Submit the source code(.cm file)and the output file showing the results:
Example for the print out of results is:
User 1executes system call SIO or DOIO
DOIO assembles IORB and inserts it in IORQ
Driver initiates I/O operation for user 1
Disk Completes I/O operation (disk does not know what process initiated the I/O operation)
Driver signal user 1(operation complete)
User 1executes system call SIO or DOIO
DOIO assembles IORB and inserts it in IORQ
And so on... The code I have so far which is not compiling: semaphore request_served[5];
semaphore operation_complete;
int bufid;
int bufaddr;
int iorqid[5];
int iorqaddr[5];
int pio;
void user_program(){
int addr;
for (int i =1; i <=5; i++){
addr =random(1,20);
bufid =user_id;
bufaddr =addr;
P(request_served[user_id]);
}
}
void DOIO(){
int user_id;
int addr;
for (int i =1; i <=5; i++){
user_id =bufid;
addr =bufaddr;
iorqid[i]=user_id;
iorqaddr[i]=addr;
}
}
void device_driver(){
int user_id;
int addr;
for (int i =1; i <=5; i++){
user_id =iorqid[i];
addr =iorqaddr[i];
pio =addr;
P(operation_complete);
V(request_served[user_id]);
}
}
void disk_process(){
int seek;
while (1){
seek =pio;
for (int i =1; i <=seek; i++){
}
V(operation_complete);
}
}
main(){
initialsem(request_served[1],0);
initialsem(request_served[2],0);
initialsem(request_served[3],0);
initialsem(request_served[4],0);
initialsem(request_served[5],0);
initialsem(operation_complete, 0);
cobegin
user_program();
DOIO();
device_driver();
disk_process();
}
} and must be for a .cm file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!