Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE COMPLETE IN C-- In this assignment you will implement a simulation of the interaction of user programs with the OS to execute an I/O

PLEASE COMPLETE IN C--

In this assignment you will implement a simulation of the interaction of user programs with the OS to execute an I/O operation on two different devices.

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 three parameters: User id, device number (dev is a random number in the range 1 and 2 that represents device one or device two) and an address (addr is a random number in the range 1 and 20.) (addr is an integer that represents a track number in the hard drive).

User programs will pass the parameters to DOIO through three buffers of size one each (bufid, bufdev, and bufaddr).

Once the parameters are stored in the buffers, user programs executes a p(request_served[ index ]) operation to wait for the completion of the I/O operation. You will need a semaphore array request_served[5].

There will be five users running concurrently and each will execute 5 I/O operations.

DOIO:

DOIO will collect and id, device(dev), and address(addr) from bufid, bufdev, and bufaddr to assemble the IORB.

DOIO will check on device number to decide which one of the two devices will get the IORB.

Once the device has been selected, DOIO will store the IORB (id and addr) into the two buffers that represent the IORQ (iorqid and iorqaddr) of the selected device. Notice that you need separate buffers (one for each device: iorqid and iorqaddr and iorqid2 and iorqaddr2).

DOIO must wait to receive signals from Device drivers indicating that all request have been served. Then DOIO will shut down both Disks.

Device drivers (1 and 2):

Device drivers will collect an IORB (made up of id and addr) from iorqid and iorqaddr and then initiate the physical I/O operation on the hard drive it controls and wait for the I/O operation to be completed: p(operation_complete).

The device driver initiates 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 Device 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.

When the last request has been served, both drivers have to signal DOIO to indicate that all requests have been handled and both drivers will emit a message: Driver 1 (2) stops

Disk (1 and 2):

The Disk processes 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 1 to seek.

Once out of the loop, disk will execute a v on the semaphore operation_complete

Disk will operate continuously until DOIO shuts them down.

Note:

Define all semaphores that you need according to the number of buffers used.

Each user will make 5 system calls to initiate I/O operations

DOIO will create 25 IORB

The sum of the I/O operations executed by drivers must add up 25. You will need a shared variable to control the total number of I/O operations because it is not known before hand the numbers of I/O operations initiated by each Device driver.

Once Drivers have served all request they have to signal DOIO.

Once DOIO receives signasl from Drivers indicating all request have been served. DOIO will shut down both Disks.

Project Direction

You will write the program C-- based on the BACI interpreter that you used in programming project 1.

Example for the print out of results:

User 1 executes system call SIO or DOIO

DOIO assembles IORB and inserts it in IORQ for user 1

User 2 executes system call SIO or DOIO

Driver initiates I/O operation for user 1

User 3 executes system call SIO or DOIO

User 4 executes system call SIO or DOIO

DOIO assembles IORB and inserts it in IORQ for user 2

Disk Completes I/O operation (disk does not know what process initiated the I/O operation)

Driver signal user 1 (operation complete)

User 1 executes system call SIO or DOIO

DOIO assembles IORB and inserts it in IORQ

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

In pure competition there are a number of sellers. LO,1

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago