answer.
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
vaieri [72.5K]
2 years ago
15

Suppose two threads execute the following C code concurrently, accessing shared variables a, b, and c: Initialization int a = 4;

int b = 0; int c = 0; Thread 1 Thread 2 if (a < 0) { b = 10; c = b-a; a = -3; } else { c = b + a; } What is the total number of possible values for c after both threads complete? You can assume that reads and writes of the variables are atomic and that the order of statements within each thread is preserved in the code generated by the C compiler?
Computers and Technology
1 answer:
Oksanka [162]2 years ago
6 0

Answer:

Therefore, there are 4 possible values for c after both threads complete

c = 4, 14, 3, 13

Explanation:

Initialization:

int a = 4;

int b = 0;

int c = 0;

Thread 1:

if (a < 0)

{

c = b - a;

}

else

{ c = b + a; }

Thread 2:

b = 10;

a = -3;

We have to consider all the possible cases.

Case 1: a = 4, b = 0, c = 0

if (a < 0) false

{

c = b - a;

}

else

{ c = b + a; }  c = 0 + 4 = 4

c = 4

Case 2: a = 4, b = 10, c = 0

if (a < 0) false

{

c = b - a;

}

else

{ c = b + a; }  c = 10 + 4 = 14

c = 14

Case 3: a = -3, b = 0, c = 0

if (a < 0) true

{

c = b - a; c = 0 - (-3) = 3

}

else

{ c = b + a; }  

c = 3

Case 4: a = -3, b = 10, c = 0

if (a < 0) true

{

c = b - a; c = 10 - (-3) = 13

}

else

{ c = b + a; }  

c = 13

Therefore, there are 4 possible values for c after both threads complete

c = 4, 14, 3, 13

You might be interested in
Within a word processing program, predesigned files that have layout and some page elements already completed are called text bo
Angelina_Jolie [31]

Answer:

I think D, Your welcome :)

Explanation:

 

7 0
2 years ago
A small e-commerce company uses a series of Robotic Process Automation solutions to manage the backup of data from individual wo
Vaselesa [24]

Answer:

Cloud.

Explanation:

Cloud computing can be defined as a form of data computing which requires the use of shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offer individuals and businesses a fast, secured, effective and efficient way of providing services over the internet.

Basically, cloud computing comprises three (3) service models and these include;

1. Platform as a Service (PaaS).

2. Software as a Service (SaaS).

3. Infrastructure as a Service (IaaS).

Additionally, the two (2) main characteristics of cloud computing are;

I. Measured service: it allows cloud service providers to monitor and measure the level of service used by various clients with respect to subscriptions.

II. Resource pooling: this allows cloud service providers to serve multiple customers or clients with services that are scalable and provisional.

For example, the provisioning of On-demand computing resources such as storage, network, virtual machines (VMs), etc., so as to enable the end users install various software applications, database and servers.

Hence, the technology that could be combined by the small e-commerce company with its current automated processes is cloud storage.

9 0
2 years ago
Allison wants to use equations to simplify the process of explaining something to the Sales team, but the default eq
yarga [219]

Answer:

Search for something that fits her needs

Explanation:

There are several approaches to problem solving, the approach that will be employed depends on our definition of the problem. Not all processes can be modeled by mathematical equations, some processes are simply theoretical and can be explained by simple logic.

If Allison does not find the needed equations among the available default equations, she can come up with an equation that addresses the process at hand. If she cannot come up with any, she can use other approaches that fit her needs to explain the required concept to the team.

7 0
2 years ago
Read 2 more answers
Which sources could provide reliable evidence for your claim? Check all that apply. a step-by-step guide listed at www.gettingto
kozerog [31]
The correct answer is:
<span>an article from the New York Times</span>a book by an educational researcher and  professor<span>a report from the US Department of Education at www.ed.gov</span>
7 0
2 years ago
Read 2 more answers
1. Create a view named customer_addresses that shows the shipping and billing addresses for each customer.
Verdich [7]

Answer:

Answer given below

Explanation:

1.

CREATE VIEW CustomerAddresses AS

SELECT custo. CustomerID, EmailAddress , LastName ,FirstName,

bill.Line1 AS BillLine1, bill.Line2 AS BillLine2, bill.City AS BillCity, bill.State AS BillState, bill.ZipCode AS BillZip,

ship.Line1 AS ShipLine1, ship.Line2 AS ShipLine2, ship.City AS ShipCity, ship.State AS ShipState, ship.ZipCode AS ShipZip

FROM Customers custo , Addresses ship , Addresses bill

WHERE custo. BillingAddressID= bill.AddressID AND custo.ShippingAddressID= ship. AddressID;

2.

SELECT CustomerID, LastName, FirstName, BillLine1 FROM CustomerAddresses;

3.

CREATE VIEW OrderItemProducts

AS

SELECT Orders.OrderID, OrderDate, TaxAmount, ShipDate,

ItemPrice, DiscountAmount, (ItemPrice- DiscountAmount) AS FinalPrice,

Quantity, and (Quantity * (ItemPrice-DiscountAmount)) AS ItemTotal,

ProductName FROM

Orders, OrderItems, Products

WHERE

Orders.OrderID = OrderItems.OrderID AND

OrderItems.ProductID = Products. ProductID;

4.

CREATE VIEW ProductSummary

AS

SELECT distinct

ProductName, COUNT(OrderID) AS OrderCount, SUM(ItemTotal) AS OrderTotal

FROM

OrderItemProducts

GROUP BY ProductName;

5.

SELECT ProductName, OrderTotal

FROM ProductSummary P

WHERE 5> (select count(*) FROM ProductSummary S

WHERE P.OrderTotal<S.OrderTotal)

ORDER BY OrderTotal;

5 0
2 years ago
Other questions:
  • What permanent magnets of a motor are replaced with more powerful ones, what effect do you think this would have on motor rotati
    12·2 answers
  • Software code is tested, debugged, fixed, verified, and then:
    11·1 answer
  • If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
    8·1 answer
  • Which of the following is an Internet supervisory protocol? O DNS IP O both A and B O neither A nor B
    12·1 answer
  • A company wants to publish Knowledge articles to its Customer Community. The articles should be organized for easy navigation by
    6·1 answer
  • Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list o
    12·1 answer
  • Janeal spends her day looking at the stock and bond markets and evaluating how the portfolios of the businesses she serves will
    5·1 answer
  • A machine is having issues, so the user is responsible for getting the machine serviced. Which stage of the hardware lifecycle d
    13·1 answer
  • (Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
    12·1 answer
  • In the file BankAccount.java, build a class called BankAccount that manages checking and savings accounts. The class has three p
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!