1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lena [83]
4 years ago
14

Assume you have a system that does not provide a usleep(unsigned long usec) call to suspend the execution of the thread for a gi

ven amount of time, say in ?secs. how would you implement this function using condition variables?
Business
1 answer:
Ilia_Sergeevich [38]4 years ago
4 0

#include <iostream>

#include <time.h>

using namespace std;

//usleep function declaration

void usleep(int microseconds);

//usleep function definition

void usleep(int microseconds) // Cross-platform sleep function

{

clock_t time_end;

time_end = clock() + microseconds * CLOCKS_PER_SEC / 1000000; //as 1 microsecond is 1/1000000 of a second.

while (clock() < time_end);

}

int main()

{

cout << "Before calling User defined usleep" << endl;

usleep(4000000);

cout << "After calling User defined usleep" << endl;

}

You might be interested in
Using a 14% cost of capital, calculate the net present value for each of the independent projects shown in the following table,
jenyasd209 [6]

Answer:

For project A ,

NPV = $-4,351.65

The project A isn't acceptable because the NPV is negative

For project B ,

NPV = $67,678.24

The project is acceptable because the NPV is postive

For project C,

NPV = $-76,528.17

The project C isnt acceptable because the NPV is negative

For project D,

NPV = $98,189.82

Project D is acceptable because the NPV is postive.

For project E ,

NPV = $8,548.44

Project E is acceptable because the NPV is postive.

Explanation:

Net present value is the present value of after tax cash flows from an investment less the amount invested.

Net present value can be calculated using a financial calculator

For project A,

Cash flow in year 0 =  -20,000

Cash flow each year from year 1-10 = 3,000

I = 14%

NPV = $-4,351.65

The project A shouldn't be embarked on because the NPV is negative

For Project B,

Cash flow in year 0 = $ -600,000

Cash flow in year 1 = 120,000

Cash flow in year 2 = 145,000

Cash flow in year 3 = 170,000

Cash flow in year 4 = 190,000

Cash flow in year 5 =220,000

Cash flow in year 6= 240,000 

I = 14%

NPV = $67,678.24

The project should be embarked on because the NPV is postive.

For Pr. C ,

Cash flow in year 0 = -150,000, 

Cash flow in year 1 = 18,000

Cash flow in year 2 = 17,000

Cash flow in year 3 = 16,000

Cash flow in year 4 = 15,000

Cash flow in year 5 = 14,000,

Cash flow in year 6 = 13,000

Cash flow in year 7 = 12,000

Cash flow in year 8 = 11,000

Cash flow in year 9= 10,000

I = 14%

NPV = $-76,528.17

The project C shouldn't be embarked on because the NPV is negative

For Pr. D,

Cash flow in year 0 = -760,000

Cash flow each year from year 1 to 8 = 185,000 

I = 14%

NPV = $98,189.82

Project D should be embarked on because the NPV is postive.

For Pr. E,

Cash flow in year 0 = -100,000

Cash flow each year for year 1 to 3 = 0 cash flow in year 4 = 25,000

Cash flow in year 5 = 36,000

Cssh flpw in year 6 = 0

Cash flow in year 7 = 60,000

Cash flow in year 8 = 72,000

Cash flow in year 9 = 84,000.

I = 14%

NPV = $8,548.44

Project E is profitable and can be undertaken.

To find the NPV using a financial calacutor:

1. Input the cash flow values by pressing the CF button. After inputting the value, press enter and the arrow facing a downward direction.

2. After inputting all the cash flows, press the NPV button, input the value for I, press enter and the arrow facing a downward direction.

3. Press compute

I hope my answer helps you

7 0
3 years ago
which tool would the government most likely employ during a period of inflation to stabilize the economy ?
Scorpion4ik [409]

They would LOWER THE CASH RATE so the value of the dollar can hopefully go back up again

3 0
3 years ago
Colby and carleton own a business. most of their friends and colleagues would say colby, who manages the business on a daily bas
Ad libitum [116K]

Colby would rate low on openness to experience, while Carleton would rate high on this dimension based on the five-factor model.

Since Colby’s thinking is conventional, he would most likely stick with the common and proven methods in handling a business, thus, the rationale on his low rating to openness to experience.

7 0
3 years ago
Which of the following is NOT a characteristic of a market in equilibrium?
iren2701 [21]

B. All consumers are able to purchase an amount equal to their quantity demanded.

6 0
3 years ago
the gdp of a country hasn’t improved in the past three years. the central bank decided to take a measure that will increase the
Brut [27]
Generally, the Central Bank will reduce the interest rate to allow banks to lend money at a lower rate, thus infusing the macro-economy with funding on medium to large ticket items.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Bronco, Inc., imposes a payback cutoff of three years for its international investment projects. Year Cash Flow (A) Cash Flow (B
    7·1 answer
  • On february​ 1, a corporation has 30 comma 00030,000 shares of $ 1$1 par value common stock issued and outstanding. the corporat
    5·1 answer
  • Matt and Meg Comer are married and file a joint tax return. They do not have any children. Matt works as a history professor at
    8·1 answer
  • Sweet Cream is an ice cream manufacturer. It sells Guilt-Free, a zero-calorie ice cream, which competes with Flavor Bell's Moo S
    15·1 answer
  • You own a local coffeeshop. recently, you noticed that customers were doodling on your white paper cups. intrigued, you set up a
    11·1 answer
  • Financial statements of Kansas Ltd (Fr) for 2X13 are authorized by management and auditors on February 15, 2X13 for issuance on
    14·1 answer
  • Is debtors control a current asset, owners equity, income or current liability
    5·1 answer
  • Choose the correct word in brackets to complete the following:(1) Which fluctuate more-long-term or short-term interest rates? W
    7·1 answer
  • Why do Marketers segment a market?
    7·1 answer
  • A model for enabling on-demand access to compute resources such as networking, analysis, storage and compute is called.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!