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]
3 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]3 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
The following changes took place last year in Pavolik Company’s balance sheet accounts:
irinina [24]

Answer:

1. $260

2. $103

Explanation:

1. Calculation to determine the net cash provided by operating activities for the year

PAVOLIK COMPANY

STATEMENT OF CASH FLOWS PARTIAL (USING INDIRECT METHOD)

FOR THE YEAR ENDED

Particulars Amount

Cash flow from operating activities

Net Income $100

Adjustments to reconcile net income to net cash provided by operating activities

Adjustment for non cash effects

Depreciation $82

Loss on sale of land $21

Gain on sale of investments -$25

Change in operating assets & liabilities

Increase in accounts receivable -$24

Decrease in inventory $58

Increase in prepaid expenses -$19

Increase in accounts payable $62

Decrease in accrued liabilities -$24

Increase in income taxes payable $29

Net cash flow from operating activities (a) $260

Therefore Using the indirect method the net cash provided by operating activities for the year is $260

2. Preparation of a statement of cash flows for the year

PAVOLIK COMPANY

STATEMENT OF CASH FLOWS (USING INDIRECT METHOD)

FOR THE YEAR ENDED

Particulars Amount

$

Cash flow from operating activities (a) $260

Cash Flow from Investing activities

Property,plant and equipment purchased -$395

Long term investment sold $46

Land sold $24

Net cash Flow from Investing activities (b) -$325

(-$395+$46+$24)

Cash Flow from Financing activities

Cash dividends paid -$18

Common stock purchased -$96

Bonds issued $204

Net cash Flow from Financing activities (c) $90

(+$204-$18-$96)

Net Change in cash c=a+b+c -$25

Beginning cash balance $128

Closing cash balance $103

($128-$25)

Therefore the statement of cash flows for the year is $103

4 0
3 years ago
What were two most challenging educational experiences? Explain why they were challenging
Tresset [83]

to me it would actually have to be college course math because im not really good at trigonometry

3 0
4 years ago
Innovative Products reported net income of $219,000. Beginning and ending inventory balances were $44,500 and $46,500, respectiv
andrew11 [14]

Answer:

$213,500

Explanation:

Given the information above, first, we'll determine increase in inventory

Increase inventory = Ending inventory - Beginning inventory

Increase inventory = $46,500 - $44,500

Increase inventory = $2,000

We will also calculate decrease in account payable

Decrease in accounts payable = Beginning accounts payable - Ending accounts payable

Decrease in accounts payable = $40,500 - $37,000

Decrease in accounts payable = $3,500

Therefore,

Net operating cash flows = Net income - Increase inventory - Decrease in accounts payable

Net operating cash flows = $219,000 - $2,000 - $3,5000 = $213,500

3 0
3 years ago
The marketing department wants to buy two new computers. One computer will be used for their graphic artist to create graphics a
BartSMP [9]

Answer:

Explanation:

While buying a computer , the potential purpose and usage of the computer should as well as the component of the computer to buy should be considered in order to make a right selection .

As graphics designing software is processor intensive , a processor with a very high speed of at least 1 Ghz and an adequate RAM to aid faster process at once , minimum of 8Gb is required.

However , considering the function of a secretary which is to track billing and hours , a computer with a slower process will definitely perform the task

8 0
3 years ago
Please help! ♡
bearhunter [10]
Well social disorganization could lead to Lee's loyalty people or follower and with out an organization things or people aren't put to play e which can lead them to think they can do what ever they want whenever
4 0
3 years ago
Other questions:
  • Southern Security makes safes for storing valuables. When Ed sold safes for the company, he would deal with a prospect's concern
    11·1 answer
  • Strategic business units that have a relatively low market share but have the potential to grow are best categorized under _____
    7·1 answer
  • Josh's weekly budget for lunch is $24. He eats only pizza and burgers. Each pizza costs $6 and each burger costs $3. Josh knows
    10·1 answer
  • Classify each cost as being either variable or fixed with respect to the number of units produced and sold. Also classify each c
    9·1 answer
  • The price of a gallon of gasoline in bonland is? $3.20. however, just before the? election, the government decides to fix the pr
    6·1 answer
  • Flora, who owns and operates Garden Fresh Organic Farms, agrees to sell Harvesters Grocery a minimum quantity of fresh fruits an
    8·2 answers
  • Ticker IBS is traded on the Pacific, Gulf and Atlantic stock Exchanges. The sequence of bids in the consolidated record is:
    11·1 answer
  • What are the three main forms of legal ownership of a business
    9·1 answer
  • ASAP!! Discuss Maslow’s Hierarchy of Needs Theory. In your opinion, is it a good motivator for employees to
    8·1 answer
  • Will mark brainliest please help!!!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!