Find Jobs
Hire Freelancers

bankers algorithm,passing a virtual address on the command line

$10 USD

Closed
Posted over 8 years ago

$10 USD

Paid on delivery
2) Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a C program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows: ./[login to view URL] 19986 Your program would output: The address 19986 contains: page number = 4 offset = 3602 Writing this program will require using the appropriate data type to store 32 bits. We encourage you to use unsigned data types as well. 1)bankers algorithm For this project, you will write a multi threaded program that implements the banker’s algorithm discussed in Section 7.5.3. Several customers request and [login to view URL] the system in a safe state. A request that leaves the system in an unsafe state will be [login to view URL] programming assignment combines three separate topics: (1)multi threading,(2)preventing race conditions,and(3)deadlock avoidance. The Banker The banker will consider requests from n customers for m resources types. as outlined in Section 7.5.3. The banker will keep track of the resources using the following data structures: /* these may be any values >= 0 */ #define NUMBER OF CUSTOMERS 5 #define NUMBER OF RESOURCES 3 /* the available amount of each resource */ int available[NUMBER OF RESOURCES]; /*the maximum demand of each customer */ int maximum[NUMBER OF CUSTOMERS][NUMBER OF RESOURCES]; /* the amount currently allocated to each customer */ int allocation[NUMBER OF CUSTOMERS][NUMBER OF RESOURCES]; /* the remaining need of each customer */ int need[NUMBER OF CUSTOMERS][NUMBER OF RESOURCES]; The Customers Create n customer threads that request and release resources from the bank. The customers will continually loop, requesting and then releasing random numbers of resources. The customers’ requests for resources will be bounded by their respective values in the need array. The banker will grant a request if it satisfies the safety algorithm outlined in Section 7.5.3.1. If a request does not leave the system in a safe state, the banker will deny it. Function prototypes for requesting and releasing resources are as follows: int request resources(int customer num, int request[]); int release resources(int customer num, int release[]); These two functions should return 0 if successful (the request has been granted)and –1 if unsuccessful. Multiple threads(customers)will concurrently access shared data through these two functions. Therefore, access must be controlled through mutex locks to prevent race conditions. Both the Pthreads and Windows APIs provide mutex locks. The use of Pthreads mutex locks is covered in Section 5.9.4;mutex locks for Windows systems are described in the project entitled“Producer–Consumer Problem” at the end of Chapter5. Implementation You should invoke your program by passing the number of resources of each type on the command line. For example, if there were three resource types, with ten instances of the first type, five of the second type, and seven of the third type, you would invoke your program follows: ./[login to view URL] 10 5 7 The available array would be initialized to these values. You may initialize the maximum array(which holds the maximum demand of each customer)using any method you find convenient.
Project ID: 9000262

About the project

5 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
5 freelancers are bidding on average $61 USD for this job
User Avatar
I am very proficient in c, c++. I have 16 years c++ developing experience now, and I have worked for 6 years. My work is online game developing, and mainly focus on server side, the language is c++ under linux. I used c++ to make many great projects, for example, I made the tools which can convert java files to c++ scripts which has the same effect, of course garbage collection included. I also made our own mobile game using c++, I even can show you the demo of client. Trust me, please let expert help you.
$150 USD in 1 day
4.9 (55 reviews)
6.2
6.2
User Avatar
Hi there! I'm a Professional Software developer and Data Analyst for a well known Software House in Islamabad named PacSquare Pvt Ltd. If I get this job, I assure you that you'll get my best services in return. Please consider my proposal, and discuss additional Info for this specific Project. Thanks for Reading! Best, Maher p.s. I read the details but they are in a little confusing format. But i got the requirements clear somehow. Please discuss over chat
$40 USD in 1 day
5.0 (35 reviews)
4.9
4.9
User Avatar
A proposal has not yet been provided
$50 USD in 1 day
4.9 (13 reviews)
3.6
3.6
User Avatar
hi , i am a c programmer and linux/unix system admin and worked with multithreading and IPC and i know python and shell script
$55 USD in 3 days
4.8 (1 review)
0.5
0.5
User Avatar
Hi. I already have the implementation of the second problem. I can send it just right now. I claim only $5 for it, another $5 is minimum fee of the website so don't think that I'm too greedy :)
$10 USD in 0 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
0.0
0
Member since Nov 29, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.