Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help correct my code - J = jBACI concurrency simulator v 1 . 4 . 5 . For context here is my assignment: In this
Help correct my code JjBACI concurrency simulator v 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 IO operation.
User programs:
User programs will communicate with DOIO OS to request an IO 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 and 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 Prequest served
operation to wait for the completion of the IO operation.
There will be only one user running and it will execute IO operations.
DOIO:
DOIO will collect an id and addressaddr 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 IO operation on the hard drive and wait for the IO operation to be
completed: Poperation complete
The device driver initiate the physical IO operation by storing addr into a buffer of length
one. The buffer name is piophysical IO
When the IO operation completes a signal is received, the driver will identify the user that
issued the IO 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 seek and
iterates in a dummy loop from to 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 system calls to initiate IO operations
DOIO will create IORB
Project Direction
You will write a C program based on the BACI interpreter that you used in programming
project
Test your solution
You must run and test your solution and comment on the results emitted.
Project Submission
What to submit?
Submit the source codecm file and the output file showing the results:
Example for the print out of results is:
User executes system call SIO or DOIO
DOIO assembles IORB and inserts it in IORQ
Driver initiates IO operation for user
Disk Completes IO operation disk does not know what process initiated the IO operation
Driver signal user operation complete
User executes 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 requestserved;
semaphore operationcomplete;
int bufid;
int bufaddr;
int iorqid;
int iorqaddr;
int pio;
void userprogram
int addr;
for int i ; i ; i
addr random;
bufid userid;
bufaddr addr;
Prequestserveduserid;
void DOIO
int userid;
int addr;
for int i ; i ; i
userid bufid;
addr bufaddr;
iorqidi userid;
iorqaddri addr;
void devicedriver
int userid;
int addr;
for int i ; i ; i
userid iorqidi;
addr iorqaddri;
pio addr;
Poperationcomplete;
Vrequestserveduserid;
void diskprocess
int seek;
while
seek pio;
for int i ; i seek; i
Voperationcomplete;
main
initialsemrequestserved;
initialsemrequestserved;
initialsemrequestserved;
initialsemrequestserved;
initialsemrequestserved;
initialsemoperationcomplete, ;
cobegin
userprogram;
DOIO;
devicedriver;
diskprocess;
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